New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PhpStorm code style: switch to PSR-2 #8211
Comments
👍 years ago when I tried to convert all the codebase to PSR-2 back then Phpstorm did some weird things, this is why we customised the config. But it was long time ago, and it seems PSR1-2 conversion looks good today in phpstorm! How to enable PSR1/2 in PhpstormFrom application preferences, either scroll down to the Code Style section, then choose PHP, or type PHP in the search box, which will filter the options available for you and then click PHP under Code Style. Click PSR1/PSR2, then click OK in the bottom right of the preferences window. You don’t need to restart PHPStorm as the setting change applies immediately. http://www.matthewsetter.com/enforcing-psr1-and-psr2-with-phpstorm/ |
Piwik is now using PSR2 as suggested. the dev documentation was updated to remove link to our custom PSR file (which was also removed). |
See also: follow up issue |
Having followed the instructions in @mattab 's comment above, I find that using the reformat command ctrl-alt-shift-L reformats my code to PSR-2 (adding spaces, moving curly brackets, etc.) but if I type in code that is malformed, for instance public function foo(){ I do not get any notification that I've violated PSR-2. Are my expectations wrong? |
Hello @edgreenberg |
We encourage contributors to set up PhpStorm with our own code style configuration. It is described here as well as in the developer documentation.
I think we should remove that custom config and just use the PSR-2 configuration in PhpStorm. The current style in Piwik's codebase is still not consistent with PSR-2, and the PhpStorm config we distribute doesn't fix that. Using PSR-2 all the way would be much simpler, and less surprising for contributors and new team members.
To sum up:
Thoughts?
The text was updated successfully, but these errors were encountered: