Skip to content

Commit 0c3efa7

Browse files
committed
Ruleset: prevent sniff conflict
PHPCS 3.6.2 introduced a new sniff to the PSR12 standard, which enforces no blank line at the start of a class. That sniff conflicts with the `Squiz.WhiteSpace.FunctionSpacing` sniff when the `spacingBeforeFirst` property is set to `1`. As the property setting predates the new sniff, excluding the new sniff will prevent a lot of unnecessary code churn in repos using this standard. This does, however, require raising the minimum PHPCS version to PHPCS 3.6.2 as otherwise a "sniff not found" error could be displayed. Ref: https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.6.2
1 parent 4ffddc2 commit 0c3efa7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

PHPCSDev/ruleset.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
<!-- Allow for the first condition of a multi-line control structure to be on the same line
4747
as the control structure keyword. -->
4848
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.FirstExpressionLine"/>
49+
50+
<!-- This standard enforces a blank line before each function, which conflicts with this
51+
PHPCS 3.6.2+ PSR12 sniff when a function is the first content of a class. -->
52+
<exclude name="PSR12.Classes.OpeningBraceSpace.Found"/>
4953
</rule>
5054

5155

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"require" : {
2323
"php" : ">=5.4",
24-
"squizlabs/php_codesniffer" : "^3.5.0",
24+
"squizlabs/php_codesniffer" : "^3.6.2",
2525
"phpcompatibility/php-compatibility" : "^9.0.0 || ^10.0.0",
2626
"dealerdirect/phpcodesniffer-composer-installer" : "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7"
2727
},

0 commit comments

Comments
 (0)