PhpStorm now bundles WordPress coding style natively, starting from version 8.
- Go to
Project Settings
>Code Style
>PHP
. - Select
Set From...
(top right of window) >Predefined Style
>WordPress
.
No longer need to muck with this import! :)
Good job. Thanks.
What about this line:
<option name="ELSE_ON_NEW_LINE" value="true" />
But in codex there is no new line between "}" and "else".
Hmm, I am not sure if else
thing was as strongly worded in earlier versions of coding style. Might be oversight on my part.
For those looking for a 4 space width tab indent instead of Rarst's 2 spaces, you can find my code style file here:
https://github.com/Automattic/PhpStorm-Resources/blob/master/WordPress.xml
I made it from scratch and it's similar but has some other changes as well.
Pull requests welcome.
Updated for 4 spaces per tab, more mainstream and was causing issues with CodeSniffer because continuation indent didn't match.
@Rarst There was something about spaces vs tabs for JS. I believe lint/hint wanted spaces.
WP's JavaScript Coding Standards say tabs. I do little JS so no promises on state of it in this config. :)
Thanks @Rarst, for me under Mac OS X 10.9.1 and PhpStorm 7.0 I could find the file under this path:
~/Library/Preferences/WebIde70/codestyles
No more "config" folder before "codestyles"
I still have config
level on Windows. Best refer to linked part of manual on it.
@Rarst, thank you for that
@Rarst, this is amazing! Thank you soo much for creating it!
The file removes the space between ! and function. Seems to be a bug, because the codestyle for wordpress says there has to be a space between them.
See: http://make.wordpress.org/core/handbook/coding-standards/php/#space-usage
That shoudn't be the case (<option name="SPACE_AROUND_UNARY_OPERATOR" value="true" />
). Check your code style settings for changes (Project Settings > Code Style > PHP > Spaces > Around Operators > Unary Operators).
EAP should ship with native WP style as far as I know? If it's wrong in that one should probably be reported as bug...
Yeah, there seems to be mild upgrade issue with that setting going from 7 to 8, hit it too. :)
How to auto Complete for wordpress comments and function definition in PhpStorm?
/**
* The Header template for our theme
*
* Displays all of the <head> section and everything up till <div id="main">
*
* @package Hasan_WordPress
* @subpackage Hasan
* @since Hasan 1.0
*/
@momin-ctg you can use /** and press "Enter"
Thanks for taking the time. /five