Skip to content

Commit 45f7a0f

Browse files
committed
Add new sniffs and bump version
1 parent 2023c36 commit 45f7a0f

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

CHANGELOG.md

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

3+
## v0.7.x
4+
5+
### v0.7.0
6+
7+
> Requires Slevomat coding standards 6.4 or higher
8+
9+
**Added rules:**
10+
- SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration
11+
- SlevomatCodingStandard.ControlStructures.RequireMultiLineCondition
12+
- SlevomatCodingStandard.Functions.RequireMultiLineCall
13+
14+
**Added strict rules:**
15+
- SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition
16+
- SlevomatCodingStandard.Functions.RequireSingleLineCall
17+
18+
**Removed rule:**
19+
- SlevomatCodingStandard.Classes.UnusedPrivateElements - Is *deprecated*
20+
321
## v0.6.x
422

523
### v0.6.1

Rules/Parts/phpcs-slevomat.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
3131
</properties>
3232
</rule>
33-
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/> <!-- Check for private properties which are never read, only written -->
3433
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding"/> <!-- Replace static:: into self:: when class/method is final -->
34+
<rule ref="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration"/> <!-- @deprecated has to have explanation -->
3535
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/> <!-- Disable empty comments -->
3636
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/> <!-- Check valid inline @var doc -->
3737
<rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> <!-- Use single line comment for property -->
@@ -47,6 +47,7 @@
4747
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing"/> <!-- Return, break etc must have empty lines before, if not first in scope -->
4848
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/> <!-- Disable parentheses for some PHP constructs like break, return, echo -->
4949
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/> <!-- New must have () even when no params are passed -->
50+
<rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineCondition"/> <!-- Can fix when max line length of if, elseif, while, do-while is exceeded -->
5051
<rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineTernaryOperator"> <!-- Can fix too line length for ternary operator -->
5152
<properties>
5253
<property name="lineLengthLimit" value="120"/>
@@ -57,6 +58,7 @@
5758
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/> <!-- \Exception should be \Throwable -->
5859
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration"/> <!-- Spacing around PHP 7.4 arrow functions -->
5960
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction"/> <!-- Empty function must have a comment why is empty -->
61+
<rule ref="SlevomatCodingStandard.Functions.RequireMultiLineCall"/> <!-- Can fix when max line length of function call is exceeded -->
6062
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/> <!-- Use static closure if not using $this -->
6163
<rule ref="SlevomatCodingStandard.Functions.TrailingCommaInCall"/> <!-- PHP 7.3+ add trailing comma in multiline function call -->
6264
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/> <!-- Check unused variable in use() for closure -->

Rules/phpcs-strict.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,18 @@
4343
</rule>
4444
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/> <!-- Only comparison in condition, no assignment -->
4545
<rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator"/> <!-- Require ?: if possible -->
46+
<rule ref="SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition"> <!-- If condition can be placed on single line, it will force it -->
47+
<properties>
48+
<property name="alwaysForSimpleConditions" value="false"></property>
49+
</properties>
50+
</rule>
4651
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"> <!-- Check usage of if with only return true/false followed by return true/false -->
4752
<properties>
4853
<property name="assumeAllConditionExpressionsAreAlreadyBoolean" value="true"/>
4954
</properties>
5055
</rule>
5156
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/> <!-- Check when ternary operator can be shortened -->
57+
<rule ref="SlevomatCodingStandard.Functions.RequireSingleLineCall"/> <!-- If function call can be placed on single line, it will force it -->
5258
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/> <!-- Disallow use == or != and must use === and !== -->
5359
<rule ref="SlevomatCodingStandard.Operators.DisallowIncrementAndDecrementOperators"/> <!-- Disable use of $i++ must use $i += 1 etc.. -->
5460
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"> <!-- File must have declare strict types with correct spacing -->

SniffsList.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
- SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature
101101
- SlevomatCodingStandard.Classes.RequireSingleLineMethodSignature
102102
- SlevomatCodingStandard.Classes.TraitUseSpacing
103-
- SlevomatCodingStandard.Classes.UnusedPrivateElements
104103
- SlevomatCodingStandard.Classes.UselessLateStaticBinding
104+
- SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration
105105
- SlevomatCodingStandard.Commenting.EmptyComment
106106
- SlevomatCodingStandard.Commenting.ForbiddenAnnotations
107107
- SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration
@@ -113,15 +113,19 @@
113113
- SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing
114114
- SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses
115115
- SlevomatCodingStandard.ControlStructures.NewWithParentheses
116+
- SlevomatCodingStandard.ControlStructures.RequireMultiLineCondition
116117
- SlevomatCodingStandard.ControlStructures.RequireMultiLineTernaryOperator
117118
- SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator
118119
- SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator
120+
- SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition
119121
- SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn
120122
- SlevomatCodingStandard.ControlStructures.UselessTernaryOperator
121123
- SlevomatCodingStandard.Exceptions.DeadCatch
122124
- SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly
123125
- SlevomatCodingStandard.Functions.ArrowFunctionDeclaration
124126
- SlevomatCodingStandard.Functions.DisallowEmptyFunction
127+
- SlevomatCodingStandard.Functions.RequireMultiLineCall
128+
- SlevomatCodingStandard.Functions.RequireSingleLineCall
125129
- SlevomatCodingStandard.Functions.StaticClosure
126130
- SlevomatCodingStandard.Functions.TrailingCommaInCall
127131
- SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
],
1313
"require": {
1414
"php": "^7.1",
15-
"slevomat/coding-standard": "^6.3.2"
15+
"slevomat/coding-standard": "^6.4.0"
1616
}
1717
}

0 commit comments

Comments
 (0)