Skip to content

Commit

Permalink
Add new sniffs and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
arxeiss committed Sep 7, 2020
1 parent 2023c36 commit 45f7a0f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## v0.7.x

### v0.7.0

> Requires Slevomat coding standards 6.4 or higher
**Added rules:**
- SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration
- SlevomatCodingStandard.ControlStructures.RequireMultiLineCondition
- SlevomatCodingStandard.Functions.RequireMultiLineCall

**Added strict rules:**
- SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition
- SlevomatCodingStandard.Functions.RequireSingleLineCall

**Removed rule:**
- SlevomatCodingStandard.Classes.UnusedPrivateElements - Is *deprecated*

## v0.6.x

### v0.6.1
Expand Down
4 changes: 3 additions & 1 deletion Rules/Parts/phpcs-slevomat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/> <!-- Check for private properties which are never read, only written -->
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding"/> <!-- Replace static:: into self:: when class/method is final -->
<rule ref="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration"/> <!-- @deprecated has to have explanation -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/> <!-- Disable empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/> <!-- Check valid inline @var doc -->
<rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> <!-- Use single line comment for property -->
Expand All @@ -47,6 +47,7 @@
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing"/> <!-- Return, break etc must have empty lines before, if not first in scope -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/> <!-- Disable parentheses for some PHP constructs like break, return, echo -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/> <!-- New must have () even when no params are passed -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineCondition"/> <!-- Can fix when max line length of if, elseif, while, do-while is exceeded -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineTernaryOperator"> <!-- Can fix too line length for ternary operator -->
<properties>
<property name="lineLengthLimit" value="120"/>
Expand All @@ -57,6 +58,7 @@
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/> <!-- \Exception should be \Throwable -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration"/> <!-- Spacing around PHP 7.4 arrow functions -->
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction"/> <!-- Empty function must have a comment why is empty -->
<rule ref="SlevomatCodingStandard.Functions.RequireMultiLineCall"/> <!-- Can fix when max line length of function call is exceeded -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/> <!-- Use static closure if not using $this -->
<rule ref="SlevomatCodingStandard.Functions.TrailingCommaInCall"/> <!-- PHP 7.3+ add trailing comma in multiline function call -->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/> <!-- Check unused variable in use() for closure -->
Expand Down
6 changes: 6 additions & 0 deletions Rules/phpcs-strict.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,18 @@
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/> <!-- Only comparison in condition, no assignment -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator"/> <!-- Require ?: if possible -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition"> <!-- If condition can be placed on single line, it will force it -->
<properties>
<property name="alwaysForSimpleConditions" value="false"></property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"> <!-- Check usage of if with only return true/false followed by return true/false -->
<properties>
<property name="assumeAllConditionExpressionsAreAlreadyBoolean" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/> <!-- Check when ternary operator can be shortened -->
<rule ref="SlevomatCodingStandard.Functions.RequireSingleLineCall"/> <!-- If function call can be placed on single line, it will force it -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/> <!-- Disallow use == or != and must use === and !== -->
<rule ref="SlevomatCodingStandard.Operators.DisallowIncrementAndDecrementOperators"/> <!-- Disable use of $i++ must use $i += 1 etc.. -->
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"> <!-- File must have declare strict types with correct spacing -->
Expand Down
6 changes: 5 additions & 1 deletion SniffsList.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
- SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature
- SlevomatCodingStandard.Classes.RequireSingleLineMethodSignature
- SlevomatCodingStandard.Classes.TraitUseSpacing
- SlevomatCodingStandard.Classes.UnusedPrivateElements
- SlevomatCodingStandard.Classes.UselessLateStaticBinding
- SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration
- SlevomatCodingStandard.Commenting.EmptyComment
- SlevomatCodingStandard.Commenting.ForbiddenAnnotations
- SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration
Expand All @@ -113,15 +113,19 @@
- SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing
- SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses
- SlevomatCodingStandard.ControlStructures.NewWithParentheses
- SlevomatCodingStandard.ControlStructures.RequireMultiLineCondition
- SlevomatCodingStandard.ControlStructures.RequireMultiLineTernaryOperator
- SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator
- SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator
- SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition
- SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn
- SlevomatCodingStandard.ControlStructures.UselessTernaryOperator
- SlevomatCodingStandard.Exceptions.DeadCatch
- SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly
- SlevomatCodingStandard.Functions.ArrowFunctionDeclaration
- SlevomatCodingStandard.Functions.DisallowEmptyFunction
- SlevomatCodingStandard.Functions.RequireMultiLineCall
- SlevomatCodingStandard.Functions.RequireSingleLineCall
- SlevomatCodingStandard.Functions.StaticClosure
- SlevomatCodingStandard.Functions.TrailingCommaInCall
- SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
],
"require": {
"php": "^7.1",
"slevomat/coding-standard": "^6.3.2"
"slevomat/coding-standard": "^6.4.0"
}
}

0 comments on commit 45f7a0f

Please # to comment.