Is there a Netbeans / PHPStorm plugin for writing / refactoring for PSR-1/2 compilation code (e.g. phphint.org)

As the name says:

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

phphint.org does just that, but offers only an online copy and paste tool, not a real-time integrated solution in the IDE.

What exactly am I looking for:

  • "real time" PSR code verification when entering
  • reform / reorganization projects in accordance with the PSR coding guidelines (1/2) (as far as possible)

In case you are interested in what I'm talking about: The PSR-1 Basic Encoding Standard and the PSR-2 Encoding Style Guide are the encoding rules published by the big PHP guys.

+6
source share
4 answers

To format PhpStorm code, you can install PSR1 / PSR2 simply:
File -> Settings -> Code Style -> PHP -> Set From... -> Predefined Style -> PSR1/PSR2

Details are on the JetBrain website.

And use Ctrl + Alt + L to format the code.

+9
source

Just take a look at the CS Fabien Potenciers CS latch on https://github.com/fabpot/PHP-CS-Fixer - I can’t talk about the quality of the output, but since this seems to be a one-time task, I don’t think you need to need a plugin.

PHPStorm, by default, correctly formats your code to PSR standards, and also refactors things such as the absence of curly braces for single-line structures, etc.

+4
source

For the second question you ask, it is actually already built into Netbeans, you just need to configure it correctly and press Ctrl + shift + F.

+1
source

In addition to the answer above - we need to use an external tool in phpStorm - a step-by-step explanation to configure it for PHPStorm:

before adding the tool: we need to install php-cs-fixer globally

command line launch: composer global require fabpot/php-cs-fixer after installation you can check it by entering the command line launch: php-cs-fixer

should give something like this what you see on the command line

as soon as everything is fine - - go to PHPStorm - go to settings - External Tools - add a new tool

add the following as per image below

phpstorm new external tool settings

Program: /Users/seramo/.composer/vendor/bin/php-cs-fixer (global path to php-cs-fixer - you can navigate and choose the right path for you)

Parameters: fix $FilePathRelativeToProjectRoot$ --level=psr2 (this is the command to execute in the file)

Working Directory: $ProjectFileDir$

Now save and apply.

in your file - menu -tools - External Tools - php-cs-fixer

the launch of this file must be fixed in accordance with PSR-2 standards.

In addition, you can assign a key to run this tool.

0
source

Source: https://habr.com/ru/post/950566/


All Articles