Jump to content

I like Allman style and tabs. Convince me to use PSR-2.


Recommended Posts

I like my braces style and I like my tabs.  But I also realize there is benefit to using PSR-2 for more standard code when it comes to collaborating and contributing to open-source (some of which demand it).


What compelling arguments can you make that I should switch to PSR-2 for all my PHP coding?

Link to comment
Share on other sites

The easy and less rude (to PHP-FIG) way to answer that is that (a) they're recommendations for a standard and (b) they're aimed towards establishing a common practice for open-source projects and not necessarily for individuals.


Personally I don't care for all their standards either. Especially about code style. They're not official and they don't even represent the PHP community as a whole.

Link to comment
Share on other sites

The cool folks over at Sensio Labs have a tool you can use to format your existing code:  http://cs.sensiolabs.org/  


So even if you don't want to code in a particular style there's an option to let them format it for you.  Also gives you an easy way to mod things and see how they look in  different style.

Link to comment
Share on other sites

The coding indentation style is something like which side of the road you are driving. It doesn’t make any difference except if you are driving opposite in others in this road. Yes there are numerous studies that suggest the one side of the road over the other as I guess there could be with indentation style. That means that if you have any important reason to have your code PSR-2 “compliant” then you should abandon Allman style and use their rules.


Allman style is wired in my brain , even in some projects that I had to write in K&R , I eventually wrote in Allman and then had a second IDE (Eclipse) with K&R configurations to change it and make the commits and updates in SVN. I really can’t understand why people prefer other indention style but equally I can’t understand why some people think the blue color relates to sadness and therefore dislike it. I can be friend and coworker with a person that hates blue , it is a matter of taste. So yes I can work in a non Allman style environment, but my taste in coding indention probably wont change.



Many things have being wrote about Allman vs everything else, many times when I talk to a person that is strongly opposed to Allman I ask “in how many OOP languages do you write code this epoch ? ”. The answer is usually from none to one. I were a Java enthusiastic at mid 90’s , all the official books from Sun were in Allman , luckily this went well with my previous programming indentation style experience in C and C++. When PHP became really OOP (after version 5) I jumped in. I can see that Allman is in decline in amateurs code, that’s sad for me , but again it is a matter of taste.

Edited by kon
  • Like 1
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.