Adapt the code to PSR-2
josgilmo opened this issue · comments
We have to set the coding standard of psr-2:
https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
And add the correct rules to our sniffer.
I've just tried a little bit php-cs-fixer. Looks promising but:
- I still don't see a way to warn me to skip using underscores on private properties. But this is not so much important because I do not tend to use them.
- I don't see a way to warn me to put docblocks on my source code. PSR-2 do not specifies this as it says on its conclusion (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md#7-conclusion), but I really believe it is important.
I think we may switch from phpcs to php-cs-fixer but we must find a way to ask us to put docblocks ( and maybe more things ) and block all pull requests if the code do not follow this guidelines.
Probably we need to research a little bit more.
Right now changes following PSR-2 can be viewed here: https://github.com/repejota/phpnats/compare/feature/php-cs-fixer
This can help a lot:
http://stackoverflow.com/questions/13767550/is-there-a-phpcs-standard-targeting-php-docblocks
Totally thinking on using a mix between php-cs-fixer and php-code-sniffer 😄
After a few tests, i'm not gonna use potencier's fixer. I will continue using php code sniffer using the PS2 standard.
- It has better support for PSR2
- It shows also errors about docblocks
- It is all installable throught composer