afaqurk/linux-dash — pull request #151 by commonquail (2014-02-18 23:07:27+00:00)
Title: Close #135: adopt full PSR-2 compliance.

With two exceptions this is supposed to be a purely stylistic change with no functional implications. It achieves full PSR-2 compliance as reported by PHP_CodeSniffer.

The choice of PSR-2 is mainly one of practicality. It is mostly a modern standard and by virtue of being PSR it is well known, and it is used by several mainstream frameworks.

On Debian systems,

sudo apt-get install php-pear && sudo pear install PHP_CodeSniffer

will install the phpcs binary along with a handful of standards, including PSR-2. It can then be invoked to print to stdout with

phpcs --standard=PSR2 sh

PHP_CodeSniffer's default standard is PEAR. You can change this with

sudo phpcs --config-set default_standard PSR2

and henceforth simply call

phpcs sh

Unfortunately PHP_CodeSniffer does not support project specific configuration settings, so it isn't possible to distribute these.

The two exceptions are warnings concerning mixing symbol definition and logic. One file defined a runtime constant, another a convenience function. Because of linux-dash's current architecture these definitions should have had no impact on program behaviour outside their respective files and so could be safely left in. I opted to resolve the warnings anyway because

1. the warnings are good advice;
2. there would be virtually no runtime or maintenance cost;
3. it achieves full PSR-2 compliance to the extent we can verify;
4. it makes invoking phpcs as simple as possible; and
5. there are no side effects from skipping the relevant sniffs.