Open johnvanbreda opened 7 years ago
PSR-2 rules are not dissimilar to Drupal coding standards which are what I try to work to. Drupal's are more comprehensive so I slightly favour them. The coder project, https://www.drupal.org/project/coder, looks like it provides appropriate rules to use with Code Sniffer.
We have previously recommended Drupal standard. http://indicia-docs.readthedocs.io/en/latest/developing/coding-standards.html
I note PSR-2 incorporates use of PSR-1 which is another kettle of fish. But perhaps that was less on your mind.
I came to this suggestion having installed Visual Studio Code as an alternative to PHPStorm. This has a plugin for PHP Code Sniffer but I've discovered that the current implementation errors with the Drupal coding standard provided by Coder. So I investigated the others on offer and it seems the general consensus outside the Drupal community is that PSR2 is a good way to go in terms of standardising across the various frameworks. I don't have a strong opinion on this and the failing of my tools to work with the chosen standard isn't really a good reason for switching.
I wonder if that makes PSR-2 a lowest common denominator. Did you find https://www.drupal.org/docs/develop/development-tools/configuring-vscode ?
I've managed to get Visual Studio Code working with phpcs, by installing the phpcs plugin version 0.7.0 + phpcs 2.9.1 (the version installed by Composer when you install drupal/coder). The latest versions of the plugin and phpcs itself don't seem to behave nicely with each other.
Just looking at setting this up myself. Did you end up using Drupal or PSR-2 standards?
I'm using Drupal, and ESLint + AirBNB for JavaScript. I will try to update the docs to reflect this at some point. I'm still very happy with VS Code and have linted quite a lot of code recently (some in branches not yet committed).
For discussion - should we be adopting PSR-2 coding style for Indicia: https://en.wikipedia.org/wiki/PHP_Standard_Recommendation?
Although not adopted by the Drupal community it is widely used for PHP frameworks. As there are many standard tools which support it (e.g. PHP_code_sniffer) it becomes easy to apply the standards.
Personally I wouldn't suggest rewriting to meet the standards in a single go, but we could at least adopt the standards for any areas of new or edited code.