-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publishing the Phpstorm custom PSR coding style for others to reuse (…
…and to make sure I don't lose it, since we want to apply it again (eg. every year or so)) This fixes #3895 the mass conversion was applied in: [ae4b031]
- Loading branch information
Showing
2 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<code_scheme name="Piwik-codestyle"> | ||
<option name="RIGHT_MARGIN" value="160" /> | ||
<PHPCodeStyleSettings> | ||
<option name="ALIGN_KEY_VALUE_PAIRS" value="true" /> | ||
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" /> | ||
<option name="LOWER_CASE_NULL_CONST" value="true" /> | ||
</PHPCodeStyleSettings> | ||
<XML> | ||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" /> | ||
</XML> | ||
<codeStyleSettings language="JavaScript"> | ||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" /> | ||
<option name="KEEP_SIMPLE_BLOCKS_IN_ONE_LINE" value="true" /> | ||
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" /> | ||
</codeStyleSettings> | ||
<codeStyleSettings language="PHP"> | ||
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" /> | ||
<arrangement> | ||
<rules> | ||
<rule> | ||
<match> | ||
<TYPE>CONST</TYPE> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<AND> | ||
<TYPE>FIELD</TYPE> | ||
<MODIFIER>PUBLIC</MODIFIER> | ||
<MODIFIER>STATIC</MODIFIER> | ||
</AND> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<AND> | ||
<TYPE>FIELD</TYPE> | ||
<MODIFIER>PROTECTED</MODIFIER> | ||
<MODIFIER>STATIC</MODIFIER> | ||
</AND> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<AND> | ||
<TYPE>FIELD</TYPE> | ||
<MODIFIER>PRIVATE</MODIFIER> | ||
<MODIFIER>STATIC</MODIFIER> | ||
</AND> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<AND> | ||
<TYPE>FIELD</TYPE> | ||
<MODIFIER>PUBLIC</MODIFIER> | ||
</AND> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<AND> | ||
<TYPE>FIELD</TYPE> | ||
<MODIFIER>PROTECTED</MODIFIER> | ||
</AND> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<AND> | ||
<TYPE>FIELD</TYPE> | ||
<MODIFIER>PRIVATE</MODIFIER> | ||
</AND> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<TYPE>CONSTRUCTOR</TYPE> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<AND> | ||
<TYPE>METHOD</TYPE> | ||
<MODIFIER>PUBLIC</MODIFIER> | ||
<MODIFIER>STATIC</MODIFIER> | ||
</AND> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<AND> | ||
<TYPE>METHOD</TYPE> | ||
<MODIFIER>PROTECTED</MODIFIER> | ||
<MODIFIER>STATIC</MODIFIER> | ||
</AND> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<AND> | ||
<TYPE>METHOD</TYPE> | ||
<MODIFIER>PRIVATE</MODIFIER> | ||
<MODIFIER>STATIC</MODIFIER> | ||
</AND> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<AND> | ||
<TYPE>METHOD</TYPE> | ||
<MODIFIER>PUBLIC</MODIFIER> | ||
</AND> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<AND> | ||
<TYPE>METHOD</TYPE> | ||
<MODIFIER>PROTECTED</MODIFIER> | ||
</AND> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<AND> | ||
<TYPE>METHOD</TYPE> | ||
<MODIFIER>PRIVATE</MODIFIER> | ||
</AND> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<TYPE>TRAIT</TYPE> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<TYPE>INTERFACE</TYPE> | ||
</match> | ||
</rule> | ||
<rule> | ||
<match> | ||
<TYPE>CLASS</TYPE> | ||
</match> | ||
</rule> | ||
</rules> | ||
</arrangement> | ||
</codeStyleSettings> | ||
</code_scheme> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Phpstorm has an awesome feature called "Reformat code" which reformats all PHP code to follow a particular selected coding style. | ||
|
||
Piwik uses PSR coding standard for php source code. We use a slightly customized PSR style | ||
(because the default PSR style in Phpstorm results in some unwanted changes). | ||
|
||
Steps: | ||
* Use latest Phpstorm | ||
* Copy this Piwik_codestyle.xml file in your ~/.WebIde60/config/codestyles/ | ||
* If you use Windows or Mac see which path to copy at: http://intellij-support.jetbrains.com/entries/23358108 | ||
* Restart PhpStorm. | ||
* Select this coding in Settings>Code style. | ||
|
||
Phpstorm can also be configured to apply the style automatically before commit. | ||
|
||
You are now writing code that respects Piwik coding standards. Enjoy! | ||
|
||
Reference: http://piwik.org/participate/coding-standards/ | ||
|
1c41d3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, awesome, AWESOME!!!!
1c41d3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding a detailed specification for JS coding style as well?
1c41d3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be great! But I am not good enough Javascript ninja to have a clear opinion on the coding style. If anyone has some ideas (maybe we can use the default phpstorm provided...)
also more generally, we should think about the way Javascript should be written in Piwik (to have some kind of consistency) -- well discuss about that in a few weeks