Skip to content

Commit f3ad959

Browse files
committed
add phpcs.xml
1 parent 00f76b8 commit f3ad959

File tree

1 file changed

+154
-0
lines changed

1 file changed

+154
-0
lines changed

phpcs.xml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<?xml version="1.0"?>
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd">
3+
<description>The coding standard for PHP_CodeSniffer itself.</description>
4+
5+
<file>autoload.php</file>
6+
<file>bin</file>
7+
<file>scripts</file>
8+
<file>src</file>
9+
<file>tests</file>
10+
11+
<exclude-pattern>*/src/Standards/*/Tests/*\.(inc|css|js)$</exclude-pattern>
12+
<exclude-pattern>*/tests/Core/*/*\.(inc|css|js)$</exclude-pattern>
13+
14+
<arg name="basepath" value="."/>
15+
<arg name="colors"/>
16+
<arg name="parallel" value="75"/>
17+
<arg value="np"/>
18+
19+
<!-- Don't hide tokenizer exceptions -->
20+
<rule ref="Internal.Tokenizer.Exception">
21+
<type>error</type>
22+
</rule>
23+
24+
<!-- Include the whole PEAR standard -->
25+
<rule ref="PEAR">
26+
<exclude name="PEAR.NamingConventions.ValidFunctionName"/>
27+
<exclude name="PEAR.NamingConventions.ValidVariableName"/>
28+
<exclude name="PEAR.Commenting.ClassComment"/>
29+
<exclude name="PEAR.Commenting.FileComment.MissingCategoryTag"/>
30+
<exclude name="PEAR.Commenting.FileComment.MissingPackageTag"/>
31+
<exclude name="PEAR.Commenting.FileComment.MissingLinkTag"/>
32+
<exclude name="PEAR.Commenting.FileComment.MissingVersion"/>
33+
<exclude name="PEAR.Commenting.InlineComment"/>
34+
</rule>
35+
36+
<!-- Include some sniffs from other standards that don't conflict with PEAR -->
37+
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
38+
<rule ref="Squiz.Arrays.ArrayDeclaration"/>
39+
<rule ref="Squiz.Commenting.ClosingDeclarationComment"/>
40+
<rule ref="Squiz.ControlStructures.ControlSignature"/>
41+
<rule ref="Squiz.ControlStructures.ElseIfDeclaration"/>
42+
<rule ref="Squiz.Commenting.BlockComment"/>
43+
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
44+
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
45+
<rule ref="Squiz.Commenting.InlineComment"/>
46+
<rule ref="Squiz.Commenting.LongConditionClosingComment"/>
47+
<rule ref="Squiz.Commenting.PostStatementComment"/>
48+
<rule ref="Squiz.Commenting.VariableComment"/>
49+
<rule ref="Squiz.Formatting.OperatorBracket"/>
50+
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing"/>
51+
<rule ref="Squiz.Operators.ComparisonOperatorUsage"/>
52+
<rule ref="Squiz.PHP.DisallowInlineIf"/>
53+
<rule ref="Squiz.Scope.MethodScope"/>
54+
<rule ref="Squiz.Strings.ConcatenationSpacing"/>
55+
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing"/>
56+
<rule ref="Squiz.WhiteSpace.FunctionClosingBraceSpace"/>
57+
<rule ref="Squiz.WhiteSpace.FunctionSpacing"/>
58+
<rule ref="Squiz.WhiteSpace.MemberVarSpacing"/>
59+
<rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
60+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
61+
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
62+
<rule ref="Generic.Commenting.Todo"/>
63+
<rule ref="Generic.ControlStructures.DisallowYodaConditions"/>
64+
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
65+
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
66+
<rule ref="Generic.Formatting.SpaceAfterCast"/>
67+
<rule ref="Generic.NamingConventions.ConstructorName"/>
68+
<rule ref="Generic.PHP.DeprecatedFunctions"/>
69+
<rule ref="Generic.PHP.LowerCaseKeyword"/>
70+
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
71+
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
72+
<rule ref="PSR2.Classes.PropertyDeclaration"/>
73+
<rule ref="PSR2.Methods.MethodDeclaration"/>
74+
<rule ref="PSR2.Files.EndFileNewline"/>
75+
<rule ref="PSR12.Files.OpenTag"/>
76+
<rule ref="Zend.Files.ClosingTag"/>
77+
78+
<!-- PEAR uses warnings for inline control structures, so switch back to errors -->
79+
<rule ref="Generic.ControlStructures.InlineControlStructure">
80+
<properties>
81+
<property name="error" value="true"/>
82+
</properties>
83+
</rule>
84+
85+
<!-- We use custom indent rules for arrays -->
86+
<rule ref="Generic.Arrays.ArrayIndent"/>
87+
<rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
88+
<severity>0</severity>
89+
</rule>
90+
<rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
91+
<severity>0</severity>
92+
</rule>
93+
<rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
94+
<severity>0</severity>
95+
</rule>
96+
<rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNewLine">
97+
<severity>0</severity>
98+
</rule>
99+
100+
<!-- Check var names, but we don't want leading underscores for private vars -->
101+
<rule ref="Squiz.NamingConventions.ValidVariableName"/>
102+
<rule ref="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore">
103+
<severity>0</severity>
104+
</rule>
105+
106+
<!-- Only one argument per line in multi-line function calls -->
107+
<rule ref="PEAR.Functions.FunctionCallSignature">
108+
<properties>
109+
<property name="allowMultipleArguments" value="false"/>
110+
</properties>
111+
</rule>
112+
113+
<!-- Have 12 chars padding maximum and always show as errors -->
114+
<rule ref="Generic.Formatting.MultipleStatementAlignment">
115+
<properties>
116+
<property name="maxPadding" value="12"/>
117+
<property name="error" value="true"/>
118+
</properties>
119+
</rule>
120+
121+
<!-- Ban some functions -->
122+
<rule ref="Generic.PHP.ForbiddenFunctions">
123+
<properties>
124+
<property name="forbiddenFunctions" type="array">
125+
<element key="sizeof" value="count"/>
126+
<element key="delete" value="unset"/>
127+
<element key="print" value="echo"/>
128+
<element key="is_null" value="null"/>
129+
<element key="create_function" value="null"/>
130+
</property>
131+
</properties>
132+
</rule>
133+
134+
<!-- Private methods MUST not be prefixed with an underscore -->
135+
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
136+
<type>error</type>
137+
</rule>
138+
139+
<!-- Private properties MUST not be prefixed with an underscore -->
140+
<rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
141+
<type>error</type>
142+
</rule>
143+
144+
<!-- The testing bootstrap file uses string concats to stop IDEs seeing the class aliases -->
145+
<rule ref="Generic.Strings.UnnecessaryStringConcat">
146+
<exclude-pattern>tests/bootstrap\.php</exclude-pattern>
147+
</rule>
148+
149+
<!-- This test file specifically *needs* Windows line endings for testing purposes. -->
150+
<rule ref="Generic.Files.LineEndings.InvalidEOLChar">
151+
<exclude-pattern>tests/Core/Tokenizer/StableCommentWhitespaceWinTest\.php</exclude-pattern>
152+
</rule>
153+
154+
</ruleset>

0 commit comments

Comments
 (0)