Skip to content

Commit bd99c1a

Browse files
author
Ethan Bray
authored
Add stricter set of rules for version 3 (#1)
1 parent 826aab0 commit bd99c1a

File tree

2 files changed

+133
-12
lines changed

2 files changed

+133
-12
lines changed

README.md

-11
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ The PHP coding standard for MessageCloud.
77
1. Require the package in your `composer.json`:
88
```json
99
{
10-
"repositories": [
11-
{
12-
"type": "vcs",
13-
"url": "[email protected]:MessageCloud/messagecloud-coding-standard.git"
14-
}
15-
],
1610
"require-dev": {
1711
"messagecloud/messagecloud-coding-standard": "^1.0"
1812
}
@@ -27,10 +21,5 @@ The PHP coding standard for MessageCloud.
2721

2822
<!-- Path to check -->
2923
<file>./src</file>
30-
31-
<!-- Allow test methods to be snake case -->
32-
<rule ref="PSR1.Methods.CamelCapsMethodName">
33-
<exclude-pattern>./test</exclude-pattern>
34-
</rule>
3524
</ruleset>
3625
```

ruleset.xml

+133-1
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,136 @@
102102

103103
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
104104
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
105-
</ruleset>
105+
106+
<!-- Forbid PHP 4 constructors -->
107+
<rule ref="Generic.NamingConventions.ConstructorName"/>
108+
109+
<!-- Forbid deprecated functions -->
110+
<rule ref="Generic.PHP.DeprecatedFunctions"/>
111+
112+
<!-- Forbid comments starting with # -->
113+
<rule ref="PEAR.Commenting.InlineComment"/>
114+
115+
<!-- Disallow else if in favour of elseif -->
116+
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
117+
<type>error</type>
118+
</rule>
119+
120+
<!-- Forbid dead code -->
121+
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
122+
123+
<!-- Forbid assignments in conditions -->
124+
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
125+
126+
<!-- Require new instances with parentheses -->
127+
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
128+
129+
<!-- Forbid usage of conditions when a simple return can be used -->
130+
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
131+
132+
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
133+
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
134+
135+
<!-- Require using Throwable instead of Exception -->
136+
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
137+
138+
<!-- Require use statements to be alphabetically sorted -->
139+
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
140+
141+
<!-- Forbid weak comparisons -->
142+
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
143+
144+
<!-- Require no spacing after spread operator -->
145+
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
146+
147+
<!-- Forbid useless parentheses -->
148+
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
149+
150+
<!-- Require ? when default value is null -->
151+
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
152+
153+
<!-- Forbid uses of multiple traits separated by comma -->
154+
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
155+
156+
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
157+
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
158+
<properties>
159+
<property name="linesCountAfterLastUse" value="1"/>
160+
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
161+
<property name="linesCountBeforeFirstUse" value="0"/>
162+
<property name="linesCountBetweenUses" value="0"/>
163+
</properties>
164+
</rule>
165+
166+
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
167+
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
168+
169+
<!-- Forbid `global` -->
170+
<rule ref="Squiz.PHP.GlobalKeyword"/>
171+
172+
<!-- Forbid functions inside functions -->
173+
<rule ref="Squiz.PHP.InnerFunctions"/>
174+
175+
<!-- Require PHP function calls in lowercase -->
176+
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
177+
178+
<!-- Forbid dead code -->
179+
<rule ref="Squiz.PHP.NonExecutableCode"/>
180+
181+
<!-- Forbid class being in a file with different name -->
182+
<rule ref="Squiz.Classes.ClassFileName"/>
183+
184+
<!-- Force whitespace before and after concatenation -->
185+
<rule ref="Squiz.Strings.ConcatenationSpacing">
186+
<properties>
187+
<property name="spacing" value="1"/>
188+
<property name="ignoreNewlines" value="true"/>
189+
</properties>
190+
</rule>
191+
192+
<!-- Forbid strings in `"` unless necessary -->
193+
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
194+
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
195+
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
196+
</rule>
197+
198+
<!-- Forbid braces around string in `echo` -->
199+
<rule ref="Squiz.Strings.EchoedStrings"/>
200+
201+
<!-- Forbid spaces in type casts -->
202+
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
203+
204+
<!-- Forbid blank line after function opening brace -->
205+
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
206+
207+
<!-- Require 1 line before and after function, except at the top and bottom -->
208+
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
209+
<properties>
210+
<property name="spacing" value="1" />
211+
<property name="spacingBeforeFirst" value="0"/>
212+
<property name="spacingAfterLast" value="0"/>
213+
</properties>
214+
</rule>
215+
216+
<!-- Require space after language constructs -->
217+
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
218+
219+
<!-- Require space around logical operators -->
220+
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
221+
222+
<!-- Forbid spaces before semicolon `;` -->
223+
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
224+
225+
<!-- Forbid spaces around `->` operator -->
226+
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
227+
<properties>
228+
<property name="ignoreNewlines" value="true"/>
229+
</properties>
230+
</rule>
231+
232+
<!-- Forbid useless alias for classes, constants and functions -->
233+
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
234+
235+
<!-- Require /* @var type $foo */ and similar simple inline annotations to be replaced by assert() -->
236+
<rule ref="SlevomatCodingStandard.PHP.RequireExplicitAssertion"/>
237+
</ruleset>

0 commit comments

Comments
 (0)