PSR-12 is an extension of PSR-2, and therefore also an extension of PSR-1. The basis of PSR-12 is PSR-2 and therefore a list of differences is provided below to assist with migration but it should be considered as an independent specification.
From the php-fig site. Long story short, while not mandatory, it covers more code cases than PSR-2.
I'd like to use it in PhpStorm. Unfortunately, by default, storm doesn't offer this option. At predefined styles you have a fairly comprehensive list, but not comprehensive enough.
Of course, I can always define the style myself doing it by hand, but that doesn't strike me as a good idea. Mostly because I WILL miss something and if there are any updates to the PSR I can't easily update it. Not to mention I can't share it properly with my team. Except maybe exporting my .idea folder.
I googled around for a plugin or something of that sort but came up empty handed.
In the editor, select a code fragment you want to reformat. Before reformatting, you can take a look at the code style settings that are applied to the selected code: press Alt+Enter and click Adjust code style settings. From the main menu, select Code | Reformat Code or press Ctrl+Alt+L .
PSR-12 seeks to provide a set way that both coding style tools can implement, projects can declare adherence to and developers can easily relate on between different projects for these coding style reducing cognitive friction.
To be able to run an application from PhpStorm, you first need to configure a PHP interpreter as described in Configure local PHP interpreters and Configure remote PHP interpreters. After that, you can do any of the following: Run a single script from the code editor. Create and run a dedicated run/debug configuration.
Manage a code style scheme From the list, select one of the following options: Rename: change the name of the selected scheme. Export: export your code style settings to the desired location. Import: import WebStorm XML code style settings, JSCS config file, or Eclipse XML Profile.
You cannot add custom entry there as a user unless you write a plugin that will do that.
WI-48160 / WI-45330 -- watch these tickets (star/vote/comment) to get notified on any progress.
The implementation of these tickets will bring a new entry in that list.
UPDATE 2019-10-08: PSR-12 Code Style preset has been added for 2019.3 version (currently in EAP stage).
You can now add it from the dropdown, must've changed some time in the past 2 years.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With