I want my IDE (PhpStorm) to enforce PSR-2 compatible formatting on all of own files. Occasionally however, I have to submit patches on legacy code where I only want to commit functional changes, not changes in code style.
How can I enforce PSR-2 using PhpStorm on only a subset of files, preferably using a magic comment / marker in the files which should be enforced?
You can set up in project settings the code style you want to apply.
After this you just need to press right-click the directory in project view and from the context menu select Reformat Code (Ctrl+Alt+L).
Check the setting on the dialog was open and hit "run" button.
I hope I was helpful to you.
More information on: https://www.jetbrains.com/help/phpstorm/2017.1/reformatting-source-code.html#d425724e29