Skip to content

Commit 2b5ad31

Browse files
VasekPurchartkukulich
authored andcommitted
Replace dev dependency on Consistence CS with local copy of rules
1 parent 1f24fb5 commit 2b5ad31

File tree

4 files changed

+155
-3
lines changed

4 files changed

+155
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![Code coverage](https://img.shields.io/coveralls/slevomat/coding-standard/master.svg?style=flat-square)](https://coveralls.io/github/slevomat/coding-standard?branch=master)
88
![PHPStan](https://img.shields.io/badge/style-level%205-brightgreen.svg?style=flat-square&label=phpstan)
99

10-
Slevomat Coding Standard for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) extends [Consistence Coding Standard](https://github.com/consistence/coding-standard) by providing sniffs with additional checks.
10+
Slevomat Coding Standard for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) complements [Consistence Coding Standard](https://github.com/consistence/coding-standard) by providing sniffs with additional checks.
1111

1212
## Table of contents
1313

build/ruleset-consistence.xml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Consistence">
3+
4+
<!-- copy of https://github.com/consistence/coding-standard/blob/master/Consistence/ruleset.xml for local checking usage -->
5+
6+
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
7+
<rule ref="Generic.Classes.DuplicateClassName"/>
8+
<rule ref="Generic.CodeAnalysis.EmptyStatement">
9+
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCATCH"/><!-- empty catch statements are allowed -->
10+
</rule>
11+
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
12+
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
13+
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
14+
<rule ref="Generic.Files.InlineHTML"/>
15+
<rule ref="Generic.Formatting.SpaceAfterCast"/>
16+
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
17+
<rule ref="Generic.NamingConventions.ConstructorName"/>
18+
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
19+
<rule ref="Generic.PHP.DeprecatedFunctions"/>
20+
<rule ref="Generic.PHP.DisallowAlternativePHPTags"/>
21+
<rule ref="Generic.PHP.ForbiddenFunctions"/>
22+
<rule ref="Generic.Strings.UnnecessaryStringConcat">
23+
<properties>
24+
<property name="allowMultiline" value="true"/>
25+
</properties>
26+
</rule>
27+
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
28+
<rule ref="Generic.WhiteSpace.ScopeIndent">
29+
<properties>
30+
<property name="tabIndent" value="true"/>
31+
</properties>
32+
</rule>
33+
<rule ref="PEAR.Classes.ClassDeclaration"/>
34+
<rule ref="PEAR.Commenting.InlineComment"/>
35+
<rule ref="PEAR.Formatting.MultiLineAssignment"/>
36+
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
37+
<rule ref="PSR2">
38+
<exclude name="Generic.Files.LineLength"/><!-- can not be suppressed -->
39+
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/><!-- don't check indentation with spaces -->
40+
<exclude name="PEAR.Functions.ValidDefaultValue"/><!-- we want to allow null as "default" value -->
41+
<exclude name="PSR2.Classes.ClassDeclaration"/><!-- we want whitespace around class body and rules for extends and implements, using PEAR instead -->
42+
<exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace"/><!-- we want to put first expression of multiline condition on next line -->
43+
<exclude name="PSR2.ControlStructures.SwitchDeclaration.caseIndent"/><!-- checked by more generic Generic.WhiteSpace.ScopeIndent.Incorrect -->
44+
<exclude name="PSR2.ControlStructures.SwitchDeclaration.defaultIndent"/><!-- checked by more generic Generic.WhiteSpace.ScopeIndent.Incorrect -->
45+
<exclude name="Squiz.Functions.LowercaseFunctionKeywords"/><!-- checked by more generic Generic.PHP.LowerCaseKeyword -->
46+
<exclude name="Squiz.ControlStructures.LowercaseDeclaration"/><!-- checked by more generic Generic.PHP.LowerCaseKeyword -->
47+
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.NewlineBeforeOpenBrace"/><!-- clashes with OpeningFunctionBraceBsdAllman -->
48+
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen"/><!-- we want to allow empty line in control structure e.g. in catch blocks, where it can improve readability -->
49+
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace"/><!-- we want to put first expression of multiline condition on next line -->
50+
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose"/><!-- we want to allow empty line in control structure e.g. in try blocks, where it can improve readability -->
51+
</rule>
52+
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
53+
<rule ref="Squiz.Arrays.ArrayDeclaration">
54+
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNewLine"/><!-- does not handle wrapped content -->
55+
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/><!-- expects closing brace at the same level as opening brace -->
56+
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/><!-- we don't want spacing with alignment -->
57+
<exclude name="Squiz.Arrays.ArrayDeclaration.FirstIndexNoNewline"/><!-- expects multi-value array always written on multiple lines -->
58+
<exclude name="Squiz.Arrays.ArrayDeclaration.FirstValueNoNewline"/><!-- expects multi-value array always written on multiple lines -->
59+
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/><!-- uses indentation of only single space -->
60+
<exclude name="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed"/><!-- even a single-value array can be written on multiple lines -->
61+
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/><!-- expects multi-value array always written on multiple lines -->
62+
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/><!-- multiple values can be written on a single line -->
63+
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/><!-- we don't want spacing with alignment -->
64+
</rule>
65+
<rule ref="Squiz.Classes.ClassFileName"/>
66+
<rule ref="Squiz.Classes.SelfMemberReference"/>
67+
<rule ref="Squiz.Commenting.DocCommentAlignment">
68+
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/><!-- space needed for indented annotations -->
69+
</rule>
70+
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
71+
<rule ref="Squiz.Commenting.FunctionComment">
72+
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/><!-- @throws are forbidden -->
73+
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/><!-- collection syntax such as string[] is not supported -->
74+
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/><!-- enforces incorrect types -->
75+
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/><!-- is not able to detect return types such as string|null as correct -->
76+
<exclude name="Squiz.Commenting.FunctionComment.InvalidThrows"/><!-- @throws are forbidden -->
77+
<exclude name="Squiz.Commenting.FunctionComment.Missing"/><!-- PHPDoc is not required on all methods -->
78+
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/><!-- comments are not required for @param -->
79+
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/><!-- void type is not used -->
80+
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/><!-- comments don't have to be sentences -->
81+
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/><!-- comments don't have to be sentences -->
82+
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/><!-- works only for code requiring PHP 7 code or better -->
83+
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamName"/><!-- we don't want spacing with alignment -->
84+
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamType"/><!-- we don't want spacing with alignment -->
85+
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNoFullStop"/><!-- @throws are forbidden -->
86+
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/><!-- @throws are forbidden -->
87+
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/><!-- doesn't work with self as typehint -->
88+
</rule>
89+
<rule ref="Squiz.Commenting.FunctionComment.DuplicateReturn">
90+
<message>Only 1 @return annotation is allowed in a function comment</message>
91+
</rule>
92+
<rule ref="Squiz.Commenting.FunctionComment.ExtraParamComment">
93+
<message>Extra @param annotation</message>
94+
</rule>
95+
<rule ref="Squiz.Commenting.FunctionComment.InvalidNoReturn">
96+
<message>Function has no return statement, but annotation @return is present</message>
97+
</rule>
98+
<rule ref="Squiz.Commenting.FunctionComment.MissingParamTag">
99+
<message>@param annotation for parameter "%s" missing</message>
100+
</rule>
101+
<rule ref="Squiz.Functions.GlobalFunction"/>
102+
<rule ref="Squiz.Operators.IncrementDecrementUsage">
103+
<exclude name="Squiz.Operators.IncrementDecrementUsage.NoBrackets"/><!-- afaik there is no need for brackets -->
104+
</rule>
105+
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
106+
<rule ref="Squiz.PHP.GlobalKeyword"/>
107+
<rule ref="Squiz.PHP.Heredoc"/>
108+
<rule ref="Squiz.PHP.InnerFunctions"/>
109+
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
110+
<rule ref="Squiz.PHP.NonExecutableCode"/>
111+
<rule ref="Squiz.Scope.StaticThisUsage"/>
112+
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
113+
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
114+
<message>Variable "%s" not allowed in double quoted string; use sprintf() instead</message>
115+
</rule>
116+
<rule ref="Squiz.Strings.ConcatenationSpacing">
117+
<properties>
118+
<property name="ignoreNewlines" value="true"/>
119+
<property name="spacing" value="1"/>
120+
</properties>
121+
</rule>
122+
<rule ref="Squiz.Strings.EchoedStrings"/>
123+
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
124+
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
125+
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
126+
<exclude name="Squiz.WhiteSpace.FunctionSpacing.After"/><!-- does not allow PHPUnit ignore comments -->
127+
<properties>
128+
<property name="spacing" value="1"/>
129+
</properties>
130+
</rule>
131+
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
132+
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
133+
<rule ref="Squiz.WhiteSpace.MemberVarSpacing"/>
134+
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
135+
<properties>
136+
<property name="ignoreNewlines" value="true"/>
137+
</properties>
138+
</rule>
139+
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
140+
<properties>
141+
<property name="ignoreNewlines" value="true"/>
142+
</properties>
143+
</rule>
144+
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
145+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
146+
<properties>
147+
<property name="ignoreBlankLines" value="false"/><!-- turned on by PSR2 -> turning off to be more general -->
148+
</properties>
149+
</rule>
150+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
151+
<severity>5</severity><!-- turned off by PSR2 -> turning on with default severity -->
152+
</rule>
153+
</ruleset>

build/ruleset.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<exclude name="SlevomatCodingStandard.Classes.ClassConstantVisibility"/><!-- PHP >= 7.1 only -->
55
<exclude name="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/><!-- PHP >= 7.1 only -->
66
</rule>
7-
<rule ref="vendor/consistence/coding-standard/Consistence/ruleset.xml">
7+
<rule ref="./ruleset-consistence.xml">
88
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedIF"/><!-- Allow empty if statements - usually with a comment -->
99
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedELSEIF"/><!-- Allow empty elseif statements - usually with a comment -->
1010
</rule>

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"squizlabs/php_codesniffer": "^2.8.1"
1313
},
1414
"require-dev": {
15-
"consistence/coding-standard": "^0.13",
1615
"jakub-onderka/php-parallel-lint": "^0.9.2",
1716
"phing/phing": "^2.16",
1817
"phpstan/phpstan": "^0.6.3",

0 commit comments

Comments
 (0)