| Lorenzo Alberton 2007-11-06, 4:12 am |
| Hi,
I think the excellent job done by Greg and Christian
with PHP_CodeSniffer and its integration in the QA
reports has highlighted a few gray zones in the standards.
I'd like to propose and discuss a few changes to the CS.
1) The page http://pear.php.net/manual/en/standards.funcalls.php
doesn't mention how to deal with very long function calls.
I think that these two PHP_CodeSniffer errors:
- Space after opening parenthesis of function call prohibited
- Space before closing parenthesis of function call prohibited
should be warnings, in case of a function call with many parameters.
In this case, I tend to leave one parameter per line, indented this way:
==============================
$obj->method(
$arg1,
$arg2,
$arg3,
$arg4
);
==============================
which IMHO is very readable and consistent with
the rest of CS directives about alignment.
2) Similarly, what to do when the number of conditions
in an "if" leads to using multiple lines? Is this OK?
==============================
if (($condition1
|| $condition2)
&& $condition3
&& $condition4
) {
//code here
}
==============================
3) "Equals sign not aligned with surrounding assignments;
expected 26 spaces but found 1 space"
maybe "26 spaces" is a bit too much to care?
I think it might decrease readability more than increasing it.
Maybe, after a certain limit (say, 6 spaces), the warning should
be dropped.
4) defines and spaces: isn't a parameter alignment better?
==============================
define('PEAR_ERROR_RETURN', 1);
define('PEAR_ERROR_PRINT', 2);
define('PEAR_ERROR_TRIGGER', 4);
define('PEAR_ERROR_DIE', 8);
define('PEAR_ERROR_CALLBACK', 16);
==============================
The current standard wants this instead:
==============================
define('PEAR_ERROR_RETURN', 1);
define('PEAR_ERROR_PRINT', 2);
define('PEAR_ERROR_TRIGGER', 4);
define('PEAR_ERROR_DIE', 8);
define('PEAR_ERROR_CALLBACK', 16);
==============================
These are the issues that pop to my mind, there might
be other ones (line length limit?), feel free to mention
them in the discussion.
Best regards,
--
Lorenzo Alberton
http://pear.php.net/user/quipo
________________________________________
________________________________
Quipo Free Internet: sicuro e veloce senza costi di attivazione e senza
canone, 2 e-mail da 25 Mb, 150 Mb di spazio web e molto di pił!
Registrati gratis: http://www.quipo.it
|