Firstly, I support PHP_CodeSniffer, so I am clearly prone to this area. But I also worked on some large codebases for 10 years as a PHP developer, so I hope I can provide some specific reasons why coding standards are good. I could write a blog series on this topic, but I’ll just tell you a little about how PHP_CodeSniffer came about, so you can understand what the tool solved for me.
I worked on several major CMS projects. The first had a bunch of code behind it and a relatively small development team. We did not have any standards. But we had no real problems. The team was small and stayed together for a long time. We are used to each other.
Then we built a new CMS. We started working with several developers. Then I was part of a team of two developers. Again, coding standards did not cause us any problems. I and other developers came from the same background and already set some recommendations that we were guided by. We did not need PHPCS then.
But this team grew as a developer at a time and eventually reached 12 full-time developers, and a lot came and went. Some came from the old CMS, and some came from outside the company. Everyone had different backgrounds and a different approach to development. It was obvious who wrote what code because the styles were so different. Whenever you worked on something complicated, you first need to adapt to their style, because it was just not the way you used to see the code. It’s like reading Shakespeare for the first time. You need to get used to it before you can read at your natural pace.
For developers, this is extra time to stop and figure out a different coding style - it's just wasted time. This is a chance for the idea to slip away while you are bogged down with a step, indent, and staple. In the end, all this does not matter. But let me tell you, they are very important if they force developers to disrupt their flow. So we needed a way to get them out of the way and let developers do what they do best.
At the same time, we delved a lot more into JavaScript. The new language in which the style was generally thrown out the window. The code was copied / pasted from sample sites and pressed together. Studying the development of complex code in a new language, it made sense to find a way to make our JS look like our PHP. We can minimize it later, but we had to quickly switch between languages ​​in order to maintain the flow.
So for this PHP_CodeSniffer was born. This helps developers work with the same coding style so that formatting and other flame problems are completely eliminated. This allows you to treat your JS as your PHP. I use it to detect product-specific odors, such as untranslated strings, or developers who don’t use our correct class inclusion code. I also use it for language-specific odors to make sure that the JS comma that kills IE is not left. You can use it the way you want. It comes with heaps of sniffs that are easily combined using an XML rule file . You can also write your own. You can integrate third-party tools to make it a one-stop shop for static code analysis. You can be as serious about code standards and flavors as you like.
PHP_CodeSniffer, like any dev tool, should work for you. You are not working for this. If it causes too many errors that you don’t need, adjust the standard to remove the ones you don’t need or turn errors into warnings. But if my story sounds like something you are experiencing or may pass in the future, it's worth taking a look at PHP_CodeSniffer to see if it can help you.
I hope this helps you and others understand why coding standards are really important for some projects and developers. This is not about the details. It's about removing the coding style from the list of things that cause developers to lose focus.