Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Netbeans/PHPStorm plugin for writing/refactoring to PSR-1/2-compilant code (like phphint.org)

As the title says:

Is there a Netbeans/PHPStorm plugin for writing/refactoring to PSR-compilant code ?

phphint.org does exactly that, but offers only an online-copy&paste-tool, not an IDE-integrated real time solution.

What exactly i'm searching for is:

  1. "real time" PSR-code checking while typing
  2. reformating/refactoring projects to fit PSR (1/2) coding guidelines (as far as possible)

In case you are wondering what i'm talking about: PSR-1 Basic Coding Standard and PSR-2 Coding Style Guide are Coding Guidelines published by the big PHP guys.

like image 310
Sliq Avatar asked Jul 29 '13 17:07

Sliq


2 Answers

For PhpStorm code formatting can be set to PSR1/PSR2 simply:
File -> Settings -> Code Style -> PHP -> Set From... -> Predefined Style -> PSR1/PSR2

Details are on the JetBrain's web site too.

And use Ctrl + Alt + L to reformat code.

like image 148
Andron Avatar answered Sep 24 '22 20:09

Andron


Just have a look at Fabien Potenciers CS fixer at https://github.com/fabpot/PHP-CS-Fixer - I cannot tell you about the quality of the output, but as this seems to be a one time task, I don't think you'd need a plugin for this.

PHPStorm does format your code well to PSR standards by default, and it will also refactor stuff like missing curly braces for one-line if structures etc.

like image 22
Sven Avatar answered Sep 23 '22 20:09

Sven