]> git.openstreetmap.org Git - nominatim.git/blob - phpcs.xml
PHP code style rule to enforce single quotes
[nominatim.git] / phpcs.xml
1 <?xml version="1.0"?>
2 <ruleset name="Nominatim Standard">
3
4   <description>Nominatim coding standard</description>
5
6   <!-- based on another standard, you can find it here -->
7   <!-- /usr/share/php/PHP/CodeSniffer/Standards/PSR2/ruleset.xml -->
8   <!-- https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/PSR2/ruleset.xml -->
9   <rule ref="PSR2"/>
10
11   <rule ref="Generic.Files.LineLength">
12     <properties>
13      <property name="lineLimit" value="194"/>
14      <property name="absoluteLineLimit" value="194"/>
15     </properties>
16   </rule>
17
18
19   <!-- "A file should declare new symbols (classes, functions, constants, etc.) and cause no
20     other side effects, or it should execute logic with side effects, but should not do both."
21     ... we have too many script and includes to be able to enforce that.
22      -->
23   <rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
24     <severity>0</severity>
25   </rule>
26
27
28
29   <!-- **************************************************************
30        DOCUMENTATION
31        ************************************************************** -->
32
33   <rule ref="PEAR.Commenting.FunctionComment.Missing">
34     <severity>0</severity>
35   </rule>
36
37
38
39
40   <!-- **************************************************************
41        COMMENTS
42        ************************************************************** -->
43
44   <!-- any comments in the lines before function() are better than forcing
45        a PHPdoc style right now -->
46   <rule ref="PEAR.Commenting.FunctionComment.WrongStyle">
47     <severity>0</severity>
48   </rule>
49
50   <!-- We allow comments after statements -->
51   <rule ref="Squiz.Commenting.PostStatementComment.Found">
52     <severity>0</severity>
53   </rule>
54   <!-- ... even without space e.g. //some words -->
55   <rule ref="Squiz.Commenting.InlineComment.NoSpaceBefore">
56     <severity>0</severity>
57   </rule>
58   <!-- blank lines after inline comments are fine -->
59   <rule ref="Squiz.Commenting.InlineComment.SpacingAfter">
60     <severity>0</severity>
61   </rule>
62
63   <!-- Comments don't have to start uppercase -->
64   <rule ref="Squiz.Commenting.InlineComment.NotCapital">
65     <severity>0</severity>
66   </rule>
67   <!-- Comments don't have to end with one of .!? -->
68   <rule ref="Squiz.Commenting.InlineComment.InvalidEndChar">
69     <severity>0</severity>
70   </rule>
71   <!-- Empty comments are fine -->
72   <rule ref="Squiz.Commenting.InlineComment.Empty">
73     <severity>0</severity>
74   </rule>
75
76
77
78
79   <!-- **************************************************************
80        INDENTATION, SPACING
81        ************************************************************** -->
82
83   <!-- We don't need 2 blank lines after function -->
84   <rule ref="Squiz.WhiteSpace.FunctionSpacing.After">
85     <severity>0</severity>
86   </rule>
87
88   <!-- Aligned looks nicer, but causes too many warnings currently -->
89   <rule ref="Generic.Formatting.MultipleStatementAlignment.NotSame">
90     <severity>0</severity>
91   </rule>
92   <rule ref="Generic.Formatting.MultipleStatementAlignment.NotSameWarning">
93     <severity>0</severity>
94   </rule>
95
96   <!-- Aligned looks nicer, but causes too many warnings currently -->
97   <rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
98     <severity>0</severity>
99   </rule>
100
101
102
103
104
105
106
107   <!-- **************************************************************
108        VARIABLES
109        ************************************************************** -->
110
111   <!-- CONST_this_var is fine, we don't need ConstThisVar -->
112   <rule ref="Generic.NamingConventions.UpperCaseConstantName.ConstantNotUpperCase">
113     <severity>0</severity>
114   </rule>
115
116   <!-- simply disagree with "Each line in an array declaration must end in a comma" -->
117   <rule ref="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast">
118     <severity>0</severity>
119   </rule>
120   <rule ref="Squiz.Arrays.ArrayDeclaration.NoComma">
121     <severity>0</severity>
122   </rule>
123
124   <!-- We allow "$abc = array($aPoint[1], $aPoint[2])" -->
125   <rule ref="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed">
126     <severity>0</severity>
127   </rule>
128
129
130
131
132
133   <!-- **************************************************************
134        STRING QUOTING
135        ************************************************************** -->
136
137   <!-- Prefer single quoted strings -->
138   <rule ref="Squiz.Strings.DoubleQuoteUsage" />
139
140   <!-- We allow variabled inside double-quoted strings "abc $somevar" -->
141   <rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
142     <severity>0</severity>
143   </rule>
144
145
146
147
148
149   <!-- **************************************************************
150        CONTROL STRUCTURES
151        ************************************************************** -->
152
153   <!-- we allow "if (a) echo 'b'" without brackets -->
154   <rule ref="Generic.ControlStructures.InlineControlStructure.NotAllowed">
155     <severity>0</severity>
156   </rule>
157
158   <!-- We allow "if (a)". No need for "if (a === TRUE)" -->
159   <rule ref="Squiz.Operators.ComparisonOperatorUsage.ImplicitTrue">
160     <severity>0</severity>
161   </rule>
162   <!-- ... same for "if (!a)" -->
163   <rule ref="Squiz.Operators.ComparisonOperatorUsage.NotAllowed">
164     <severity>0</severity>
165   </rule>
166
167
168
169 </ruleset>