I’m a regular user of JetBrains PhpStorm coding package and recently I’ve been doing a bit of WordPress orientated work – so how can I ensure my code matches the WordPress coding standards? Well, using Rarst’s WordPress coding standards helps.
- Just download the file and save it as “WordPress.xml” into your Php Storm folder such as .WebIde40/config/codestyles (on Linux, this was /home/[username]/.WebIde40/config/codestyles : I did have to show hidden files in Nautilus: on Windows it’ll be something like C:\Users\[username]\.WebIde40\config\codestyles\ ). To find your configuration file easily, run the following commands:
- Linux: cd ~/.WebIde40/config/codestyles
- Mac OS X: cd ~/Library/Preferences/WebIde40/codestyles
- Windows: cd c:/Users/USERNAME/.WebIde40/config/codestyles
- Restart PhpStorm
- Load your project and go to “File -> Settings”
- Select “Project Settings -> Code Style”
- Select “Scheme: WordPress” and OK
- Select “Code -> Reformat code…” and wait for your code to be reformatted
This won’t catch every item (such as the Yoda conditions), but it’ll at least make it a bit closer.