Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit 31e54f1

Browse files
committed
Added new sniffs from PHP_CodeSniffer 3.4.0
- no spaces around incrementation/decrementation - no spaces after nullable oparator in nullable type declaration
1 parent a701226 commit 31e54f1

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

src/ZendCodingStandard/ruleset.xml

+4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
100100
<!-- Detects unconditional if- and elseif-statements -->
101101
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
102+
<!-- Disallow spaces before/after incrementation/decrementation operators -->
103+
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
102104

103105
<!-- Forbid inline comments after closing curly bracket, like // end if etc -->
104106
<rule ref="WebimpressCodingStandard.Commenting.NoInlineCommentAfterCurlyClose"/>
@@ -308,6 +310,8 @@
308310
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
309311
<!-- Require ? when default value is null -->
310312
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
313+
<!-- Disallow space after nullable operator -->
314+
<rule ref="PSR12.Functions.NullableTypeDeclaration"/>
311315
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
312316
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
313317
<!-- Require space around colon in return types -->

test/expected-report.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test/fixable/anonymous-classes.php 11 0
77
test/fixable/array-indentation.php 47 1
88
test/fixable/class-name-resolution.php 15 0
99
test/fixable/class-properties.php 6 0
10-
test/fixable/classes-traits-interfaces.php 16 1
10+
test/fixable/classes-traits-interfaces.php 17 1
1111
test/fixable/closures.php 19 0
1212
test/fixable/commenting.php 26 0
1313
test/fixable/concatenation-spacing.php 21 0
@@ -22,9 +22,9 @@ test/fixable/LowCaseTypes.php 2 0
2222
test/fixable/method-and-function-arguments.php 16 0
2323
test/fixable/method-and-function-calls.php 15 0
2424
test/fixable/namespaces-spacing.php 7 0
25-
test/fixable/naming.php 11 0
25+
test/fixable/naming.php 12 0
2626
test/fixable/new-with-parentheses.php 19 0
27-
test/fixable/not-spacing.php 20 1
27+
test/fixable/not-spacing.php 33 1
2828
test/fixable/operators.php 17 0
2929
test/fixable/return-type-on-methods.php 17 0
3030
test/fixable/semicolon-spacing.php 5 0
@@ -37,9 +37,9 @@ test/fixable/useless-semicolon.php 8 0
3737
test/fixable/variable-names.php 5 2
3838
test/fixable/visibility-declaration.php 1 0
3939
----------------------------------------------------------------------
40-
A TOTAL OF 426 ERRORS AND 6 WARNINGS WERE FOUND IN 33 FILES
40+
A TOTAL OF 441 ERRORS AND 6 WARNINGS WERE FOUND IN 33 FILES
4141
----------------------------------------------------------------------
42-
PHPCBF CAN FIX 364 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
42+
PHPCBF CAN FIX 377 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
4343
----------------------------------------------------------------------
4444

4545

test/fixable/not-spacing.php

+12
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,15 @@ public function twoLines()
4343
{
4444
}
4545
}
46+
47+
$a ++;
48+
$b --;
49+
-- $c;
50+
++ $d;
51+
52+
function nullableTypes(? int $int, ? \Complex\Type $ct) : ? string
53+
{
54+
return function (? bool $b) : ? float {
55+
return 0.0;
56+
};
57+
}

test/fixed/not-spacing.php

+12
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,15 @@ public function twoLines()
3838
{
3939
}
4040
}
41+
42+
$a++;
43+
$b--;
44+
--$c;
45+
++$d;
46+
47+
function nullableTypes(?int $int, ?Complex\Type $ct) : ?string
48+
{
49+
return function (?bool $b) : ?float {
50+
return 0.0;
51+
};
52+
}

0 commit comments

Comments
 (0)