Welcome Guest, Not a member yet? Register   Sign In
variable naming convention question - from 1.7 General Style and Syntax guide
#1

[eluser]skattabrain[/eluser]
First of all ... /CodeIgniter/user_guide/general/styleguide.html is a great addition to the documentation. But I have a question ...

Quote:Variable Names

The guidelines for variable naming is very similar to that used for class methods. Namely, variables should contain only lowercase letters, use underscore separators, and be reasonably named to indicate their purpose and contents. Very short, non-word variables should only be used as iterators in for() loops.

Is using a single letter for things outside loops bad for the reason of not being obvious as to what the variable is? Or is there another reason?
#2

[eluser]xwero[/eluser]
That is the main reason indeed. Code is a way of communicating with other programmers so you should write code others understand.
#3

[eluser]skattabrain[/eluser]
understood ... was curious.
#4

[eluser]thomas.ernest[/eluser]
I've developed something [ci4php-cs] so that PHP_CodeSniffer [phpcs] support Code Igniter style guide [ci-style].

It is able to check variable naming: names longer than 3 chars except in for loops.

Feel free to give a try and share your feedbacks.

[phpcs] http://pear.php.net/package/PHP_CodeSniffer/
[ci-style] http://ellislab.com/codeigniter/user-gui...guide.html
[ci4php-cs] https://github.com/thomas-ernest/CodeIgn...odeSniffer




Theme © iAndrew 2016 - Forum software by © MyBB