by pdenton · 5y ago · 0 comments
The FIG standard that forbids TAB for indentation (which is perfectly legal in PHP), the notion that classes should be either abstract or final, the micro-optimizations (thou must use single quotes, things like that).
I don't think anyone can tell anyone how to write PHP, because nobody knows how to get it right (myself included). Yet in my many years of coding in PHP, there's been more and more tooling and so-called "standards" that do exactly this.
If you're not writing a framework or library for others to use, nothing the FIG says is necessarily relevant to you.
And in fact, even if you are, Doctrine, Guzzle, Laravel, and Symfony have all left the FIG, so it has even less relevance now.
So...it's a group that used to make standards for a very specific audience, and now mostly doesn't, in part because all of the most important members of that audience got fed up and left.
That's your biggest beef with PHP? Just adopt whatever standards you like.
After using more languages with a distinction between strings and characters, a string in single quotes starts to look weird.
Although there are several questionable "best practices" in general, I have found that stricter typing in PHP has generally been a plus.
The PSR's also reflect this tendency. They're a mix of extremely useful standardization (e.g. PSR-4) and hardcode nitpicking about whitespace (e.g. PSR-12). Take what you need, focus on maintainability and interoperability, and ignore the noise.
Writing code isn't an exact science and much like in probably any other profession, this requires us to twist and bend or even break the rules in order to create something beautiful. As a programmer, it's desirable to adhere to SOLID principles but without freedom of expression this is pretty much impossible.
A good mix of constraints and creativity can take years to develop and should probably keep developing over time as one exercises the art.
If you or your team don't care about that and want to do something different, there's nothing stopping you. Even the Symfony team, who contributed to these standards and largely follow them, have gone their own way when they thought it was worth the trade-off.
It's true that the PHP community has a bit of an inferiority complex which result sometimes in abuse of patterns, like suddenly someday everyone wanted to do refactor everything with DDD/CQRS/etc for no good reason.