Developing in a team has many different challenges: one of them is working with code written by others. A first step to make it as easy as possible for others to read your code is to write a clean and documented code. But what is clean code? There are quite a few measures for checking code quality, one measure is pmd. A basic and less complex guarantee for clean code are coding guidelines. Until recently, there were quite a few different coding guidelines for PHP.
The PHP Framework Interoperability Group started to work on PHP Code guidelines some time ago. The first standard they released is PSR-0 which is a standard for autoloading classes. In my opinion PSR-0 is a huge success and makes it much easier to work with external libraries. Now they are looking into coding standards and coding guidelines with PSR-1 and PSR-2. These two standards are not approved yet but look really promising.
As always there can be endless discussions about coding standards (spaces vs. tabs, curly bracket on new line, underline in front of private and protected functions, …). PSR-2 fits our internal coding guidelines at Centralway to about 95%. One main difference is that we use underline in front of private and protected functions which I think is really helpful for the readability of the code. What I like most about PSR-1 and PSR-2 is that there is a MUST set and SHOULD set of coding guidelines. This will make it possible for a basic set to be implemented so that hopefully most of the developers will follow it in the future.
As we always want to be a little bit ahead we already started to discuss if we should migrate our coding guideslines to PSR-1 and partially to PSR-2. PSR-0 is already implemented. Both standards are not approved standards yet but hopefully will be quite soon. To migrate old projects to the new standards Fabien Potencier has written the PHP-CS-Fixer. We are still testing this script internally.
I personally think that as much projects as possible should agree on some basic coding standards as this will also help the open source community. It will make it much easier to use and contribute to open source projects.
Which coding guidelines are you using and what do you think of these new proposed standards?