Skip to content
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

Closed
mnapoli opened this Issue Jun 25, 2015 · 5 comments

Comments

Projects
None yet
3 participants
@mnapoli
Copy link
Contributor

commented Jun 25, 2015

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:

  • we should stop distributing a custom PhpStorm config and encourage using the PSR-2 default config instead
  • we (as in contributors) should switch to the PSR-2 config

Thoughts?

@mnapoli mnapoli added the RFC label Jun 25, 2015

@mnapoli mnapoli added this to the Short term milestone Jun 25, 2015

@mattab

This comment has been minimized.

Copy link
Member

commented Jun 25, 2015

👍

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 Phpstorm

From 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/

Related: #7731 #7955

mattab pushed a commit to matomo-org/developer-documentation that referenced this issue Jan 18, 2016

@mattab mattab closed this in efcb492 Jan 18, 2016

@mattab

This comment has been minimized.

Copy link
Member

commented Jan 18, 2016

Piwik is now using PSR2 as suggested. the dev documentation was updated to remove link to our custom PSR file (which was also removed).

@mattab

This comment has been minimized.

Copy link
Member

commented Jan 18, 2016

See also: follow up issue Automatically convert our code base to use a consistent code style #9545

@edgreenberg

This comment has been minimized.

Copy link

commented Sep 25, 2016

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?

@mattab

This comment has been minimized.

Copy link
Member

commented Sep 26, 2016

Hello @edgreenberg
AFAIK there is no warning or notice that the code is not compliant with PSR2 and one has to apply manually, or directly code in PSR2 style

@mattab mattab added answered and removed answered labels Oct 5, 2016

@mattab mattab modified the milestones: 3.0.0-b1, Mid term Oct 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.