Skip to content

Commit 5322f32

Browse files
committed
Add more rules
1 parent 1a855d5 commit 5322f32

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## v0.9.x
4+
5+
### v0.9.0
6+
7+
**Added rules:**
8+
- Generic.CodeAnalysis.JumbledIncrementer
9+
- Generic.Functions.CallTimePassByReference
10+
- Generic.PHP.BacktickOperator
11+
- Generic.PHP.DiscourageGoto
12+
- Generic.VersionControl.GitMergeConflict
13+
- SlevomatCodingStandard.Classes.ClassConstantVisibility
14+
- SlevomatCodingStandard.Functions.UselessParameterDefaultValue
15+
16+
**Added strict rules:**
17+
- Generic.CodeAnalysis.ForLoopWithTestFunctionCall - *By default produce only a Warning*
18+
319
## v0.8.x
420

521
### v0.8.0

Rules/Parts/phpcs-generic.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@
2121
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/><!-- empty catch statements are allowed - Squiz check comment inside empty catch -->
2222
</rule>
2323
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/> <!-- for without iterators can be while -->
24+
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/> <!-- Accidentally incrementing iterator of outer loop inside inner loop -->
2425
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/> <!-- Disable if(true) etc... -->
2526
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/> <!-- When final is for class and for method again -->
2627
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/> <!-- When method only calls parent, nothing more -->
2728
<rule ref="Generic.Files.InlineHTML"/> <!-- Disables Inline HTML inside file -->
29+
<rule ref="Generic.Functions.CallTimePassByReference"/> <!-- Cannot use reference in function call -->
2830
<rule ref="Generic.Formatting.NoSpaceAfterCast"/> <!-- Disable space after cast, ie (int) $var -->
2931
<rule ref="Generic.NamingConventions.ConstructorName"/> <!-- Check of usage old constructor naming -->
32+
<rule ref="Generic.PHP.BacktickOperator"/> <!-- Backtick is used to call shell -->
3033
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/> <!-- No chars before PHP opening tag -->
3134
<rule ref="Generic.PHP.DeprecatedFunctions"/> <!-- Disable deprecated function -->
35+
<rule ref="Generic.PHP.DiscourageGoto"/> <!-- goto cannot be used -->
3236
<rule ref="Generic.PHP.ForbiddenFunctions"> <!-- Ban listed functions -->
3337
<properties>
3438
<property name="forbiddenFunctions" type="array">
@@ -45,6 +49,7 @@
4549
<property name="allowMultiline" value="true"/> <!-- But splitting into multiple lines is allowed -->
4650
</properties>
4751
</rule>
52+
<rule ref="Generic.VersionControl.GitMergeConflict"/> <!-- Detect git merge conflict artifacts -->
4853
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing"> <!-- No extra spaces inside parentheses -->
4954
<properties>
5055
<property name="ignoreNewlines" value="true"/>

Rules/Parts/phpcs-slevomat.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/> <!-- Multiline array must have trailing comma -->
77
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
8+
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility" /> <!-- Constants must have visibility operator -->
89
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing"> <!-- Proper spacing for constants with and without docblock -->
910
<properties>
1011
<property name="maxLinesCountBeforeWithoutComment" value="0"/>
@@ -61,10 +62,11 @@
6162
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration"/> <!-- Spacing around PHP 7.4 arrow functions -->
6263
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction"/> <!-- Empty function must have a comment why is empty -->
6364
<rule ref="SlevomatCodingStandard.Functions.RequireMultiLineCall"/> <!-- Can fix when max line length of function call is exceeded -->
64-
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/> <!-- Use static closure if not using $this -->
6565
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/> <!-- PHP 7.3+ add trailing comma in multiline function call -->
6666
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/> <!-- PHP 8.0+ add trailing comma in multiline function declaration -->
67+
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/> <!-- Use static closure if not using $this -->
6768
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/> <!-- Check unused variable in use() for closure -->
69+
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue" />
6870
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/> <!-- Namespace use sort alphabetically -->
6971
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/> <!-- Group use namespaces declaration is disallowed -->
7072
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions"/> <!-- Exception is always fully qualified class names -->

Rules/phpcs-strict.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<config name="installed_paths" value="../../slevomat/coding-standard"/>
55

66
<!-- Generic -->
7+
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
78
<rule ref="Generic.Formatting.SpaceAfterNot"> <!-- Checks there is 0 lines after ! operator -->
89
<properties>
910
<property name="spacing" value="0"/>

SniffsList.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# All used sniffs
22

3-
### Generic (37 sniffs)
3+
### Generic (43 sniffs)
44
- Generic.Arrays.ArrayIndent
55
- Generic.Arrays.DisallowLongArraySyntax
66
- Generic.Classes.DuplicateClassName
77
- Generic.CodeAnalysis.AssignmentInCondition
88
- Generic.CodeAnalysis.EmptyStatement
99
- Generic.CodeAnalysis.ForLoopShouldBeWhileLoop
10+
- Generic.CodeAnalysis.ForLoopWithTestFunctionCall
11+
- Generic.CodeAnalysis.JumbledIncrementer
1012
- Generic.CodeAnalysis.UnconditionalIfStatement
1113
- Generic.CodeAnalysis.UnnecessaryFinalModifier
1214
- Generic.CodeAnalysis.UselessOverridingMethod
@@ -19,19 +21,23 @@
1921
- Generic.Formatting.DisallowMultipleStatements
2022
- Generic.Formatting.NoSpaceAfterCast
2123
- Generic.Formatting.SpaceAfterNot
24+
- Generic.Functions.CallTimePassByReference
2225
- Generic.Functions.FunctionCallArgumentSpacing
2326
- Generic.NamingConventions.ConstructorName
2427
- Generic.NamingConventions.UpperCaseConstantName
28+
- Generic.PHP.BacktickOperator
2529
- Generic.PHP.CharacterBeforePHPOpeningTag
2630
- Generic.PHP.DeprecatedFunctions
2731
- Generic.PHP.DisallowAlternativePHPTags
2832
- Generic.PHP.DisallowShortOpenTag
33+
- Generic.PHP.DiscourageGoto
2934
- Generic.PHP.ForbiddenFunctions
3035
- Generic.PHP.LowerCaseConstant
3136
- Generic.PHP.LowerCaseKeyword
3237
- Generic.PHP.LowerCaseType
3338
- Generic.PHP.NoSilencedErrors
3439
- Generic.Strings.UnnecessaryStringConcat
40+
- Generic.VersionControl.GitMergeConflict
3541
- Generic.WhiteSpace.ArbitraryParenthesesSpacing
3642
- Generic.WhiteSpace.DisallowSpaceIndent - *Depends on selected indentation configuration*
3743
- Generic.WhiteSpace.DisallowTabIndent - *Depends on selected indentation configuration*
@@ -89,6 +95,7 @@
8995
- SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement
9096
- SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace
9197
- SlevomatCodingStandard.Arrays.TrailingArrayComma
98+
- SlevomatCodingStandard.Classes.ClassConstantVisibility
9299
- SlevomatCodingStandard.Classes.ConstantSpacing
93100
- SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants
94101
- SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition
@@ -132,6 +139,7 @@
132139
- SlevomatCodingStandard.Functions.StaticClosure
133140
- SlevomatCodingStandard.Functions.RequireTrailingCommaInCall
134141
- SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure
142+
- SlevomatCodingStandard.Functions.UselessParameterDefaultValue
135143
- SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses
136144
- SlevomatCodingStandard.Namespaces.DisallowGroupUse
137145
- SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions

0 commit comments

Comments
 (0)