Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.

Commit 1869c9f

Browse files
committed
PHPStorm WP code style settings xml file
1 parent d6cb4cc commit 1869c9f

File tree

2 files changed

+93
-1
lines changed

2 files changed

+93
-1
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,22 @@ By default PHPCS has a command line interface to run the same checks. For exampl
3838
./phpcsx --standard=JustcodedWordpress /var/www/wordpress/wp-content/themes/my-theme/
3939
```
4040

41-
## PHPStorm code templates configuration
41+
## PHPStorm configuration
42+
43+
### Code style import
44+
45+
PHPStorm has it's own built-in WordPress and PSR-2 code styles presets, however they follow only must rules and it some cases are not accurate.
46+
We updated code styles to work with current repository rulesets. You can find code styles inside `phpstorm` directory in this repository.
47+
48+
To import a code style:
49+
50+
- Open Settings
51+
- Navigate Editor > Code Style
52+
- Click on wheel icon near a "Scheme" and choose "Import scheme"
53+
- Select xml file to import
54+
- Select new "Wordpress theme"
55+
56+
### Code templates configuration
4257

4358
We belive that all code should be well documented and this means that all properties and methods should have a proper descriptions.
4459
However some methods are self-explanatory like getters or setters. You can configure you PHPStorm to autocomplete short method name to help you minimize you text typing for self-explanatory methods.

phpstorm/Wordpress-CodeStyle.xml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<code_scheme name="Wordpress" version="173">
2+
<HTMLCodeStyleSettings>
3+
<option name="HTML_ALIGN_ATTRIBUTES" value="false" />
4+
</HTMLCodeStyleSettings>
5+
<JSCodeStyleSettings>
6+
<option name="USE_CHAINED_CALLS_GROUP_INDENTS" value="true" />
7+
</JSCodeStyleSettings>
8+
<PHPCodeStyleSettings>
9+
<option name="ALIGN_KEY_VALUE_PAIRS" value="true" />
10+
<option name="ALIGN_PHPDOC_PARAM_NAMES" value="true" />
11+
<option name="ALIGN_ASSIGNMENTS" value="true" />
12+
<option name="PHPDOC_BLANK_LINES_AROUND_PARAMETERS" value="true" />
13+
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
14+
<option name="LOWER_CASE_NULL_CONST" value="true" />
15+
<option name="VARIABLE_NAMING_STYLE" value="SNAKE_CASE" />
16+
<option name="BLANK_LINES_BEFORE_RETURN_STATEMENT" value="1" />
17+
<option name="KEEP_RPAREN_AND_LBRACE_ON_ONE_LINE" value="true" />
18+
<option name="SPACES_AROUND_VAR_WITHIN_BRACKETS" value="true" />
19+
<option name="ALIGN_CLASS_CONSTANTS" value="true" />
20+
<option name="SPACE_BEFORE_UNARY_NOT" value="true" />
21+
<option name="SPACE_AFTER_UNARY_NOT" value="true" />
22+
<option name="SPACE_BETWEEN_TERNARY_QUEST_AND_COLON" value="true" />
23+
</PHPCodeStyleSettings>
24+
<codeStyleSettings language="HTML">
25+
<indentOptions>
26+
<option name="USE_TAB_CHARACTER" value="true" />
27+
</indentOptions>
28+
</codeStyleSettings>
29+
<codeStyleSettings language="JavaScript">
30+
<indentOptions>
31+
<option name="INDENT_SIZE" value="2" />
32+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
33+
<option name="TAB_SIZE" value="2" />
34+
</indentOptions>
35+
</codeStyleSettings>
36+
<codeStyleSettings language="PHP">
37+
<option name="RIGHT_MARGIN" value="140" />
38+
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
39+
<option name="BLANK_LINES_AFTER_PACKAGE" value="1" />
40+
<option name="CLASS_BRACE_STYLE" value="1" />
41+
<option name="METHOD_BRACE_STYLE" value="1" />
42+
<option name="SPECIAL_ELSE_IF_TREATMENT" value="true" />
43+
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
44+
<option name="ALIGN_MULTILINE_FOR" value="false" />
45+
<option name="SPACE_AROUND_UNARY_OPERATOR" value="true" />
46+
<option name="SPACE_WITHIN_PARENTHESES" value="true" />
47+
<option name="SPACE_WITHIN_METHOD_CALL_PARENTHESES" value="true" />
48+
<option name="SPACE_WITHIN_METHOD_PARENTHESES" value="true" />
49+
<option name="SPACE_WITHIN_IF_PARENTHESES" value="true" />
50+
<option name="SPACE_WITHIN_WHILE_PARENTHESES" value="true" />
51+
<option name="SPACE_WITHIN_FOR_PARENTHESES" value="true" />
52+
<option name="SPACE_WITHIN_CATCH_PARENTHESES" value="true" />
53+
<option name="SPACE_WITHIN_SWITCH_PARENTHESES" value="true" />
54+
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACES" value="true" />
55+
<option name="SPACE_AFTER_TYPE_CAST" value="true" />
56+
<option name="CALL_PARAMETERS_WRAP" value="1" />
57+
<option name="METHOD_PARAMETERS_WRAP" value="5" />
58+
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
59+
<option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
60+
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
61+
<option name="PARENTHESES_EXPRESSION_LPAREN_WRAP" value="true" />
62+
<option name="PARENTHESES_EXPRESSION_RPAREN_WRAP" value="true" />
63+
<option name="FOR_STATEMENT_LPAREN_ON_NEXT_LINE" value="true" />
64+
<option name="FOR_STATEMENT_RPAREN_ON_NEXT_LINE" value="true" />
65+
<option name="ARRAY_INITIALIZER_WRAP" value="5" />
66+
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
67+
<option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
68+
<option name="IF_BRACE_FORCE" value="3" />
69+
<option name="DOWHILE_BRACE_FORCE" value="3" />
70+
<option name="WHILE_BRACE_FORCE" value="3" />
71+
<option name="FOR_BRACE_FORCE" value="3" />
72+
<option name="WRAP_ON_TYPING" value="0" />
73+
<indentOptions>
74+
<option name="USE_TAB_CHARACTER" value="true" />
75+
</indentOptions>
76+
</codeStyleSettings>
77+
</code_scheme>

0 commit comments

Comments
 (0)