Skip to content

Commit 0308bc4

Browse files
authored
Merge pull request #320 from simPod/enumspacing
feat: enable SlevomatCodingStandard.Classes.EnumCaseSpacing sniff
2 parents 3e88327 + 89c3e07 commit 0308bc4

File tree

9 files changed

+127
-45
lines changed

9 files changed

+127
-45
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"require": {
2525
"php": "^7.2 || ^8.0",
2626
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0.0",
27-
"slevomat/coding-standard": "^8.11",
27+
"slevomat/coding-standard": "^8.14",
2828
"squizlabs/php_codesniffer": "^3.7"
2929
},
3030
"config": {

lib/Doctrine/ruleset.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@
145145
<property name="linesCountBeforeClosingBrace" value="0"/>
146146
</properties>
147147
</rule>
148+
<!-- Enforce consistent enum case spacing -->
149+
<rule ref="SlevomatCodingStandard.Classes.EnumCaseSpacing" />
148150
<!-- Add one line around parent call in order to improve readability -->
149151
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
150152
<!-- Ensure that there are consistent blank lines between properties. -->

tests/expected_report.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tests/input/doc-comment-spacing.php 11 0
1919
tests/input/duplicate-assignment-variable.php 1 0
2020
tests/input/EarlyReturn.php 7 0
2121
tests/input/example-class.php 47 0
22-
tests/input/ExampleBackedEnum.php 3 0
22+
tests/input/ExampleBackedEnum.php 5 0
2323
tests/input/Exceptions.php 1 0
2424
tests/input/forbidden-comments.php 14 0
2525
tests/input/forbidden-functions.php 6 0
@@ -54,9 +54,9 @@ tests/input/use-ordering.php 1 0
5454
tests/input/useless-semicolon.php 2 0
5555
tests/input/UselessConditions.php 21 0
5656
----------------------------------------------------------------------
57-
A TOTAL OF 462 ERRORS AND 2 WARNINGS WERE FOUND IN 50 FILES
57+
A TOTAL OF 464 ERRORS AND 2 WARNINGS WERE FOUND IN 50 FILES
5858
----------------------------------------------------------------------
59-
PHPCBF CAN FIX 378 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
59+
PHPCBF CAN FIX 380 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
6060
----------------------------------------------------------------------
6161

6262

tests/fixed/ExampleBackedEnum.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@
66

77
enum ExampleBackedEnum: int
88
{
9+
case FOO = 0;
10+
case BAR = 1;
11+
12+
case BAZ = 2;
13+
14+
/** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */
15+
case BAM = 1234;
916
}

tests/input/ExampleBackedEnum.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,13 @@
66

77
enum ExampleBackedEnum : int
88
{
9+
case FOO = 0;
10+
case BAR = 1;
11+
12+
13+
case BAZ = 2;
14+
15+
16+
/** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */
17+
case BAM = 1234;
918
}

tests/php72-compatibility.patch

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
diff --git a/tests/expected_report.txt b/tests/expected_report.txt
2-
index d1e1fad..ea3b611 100644
2+
index 087995d..84c9474 100644
33
--- a/tests/expected_report.txt
44
+++ b/tests/expected_report.txt
5-
@@ -17,26 +17,23 @@
5+
@@ -17,26 +17,23 @@ tests/input/constants-var.php 6 0
66
tests/input/ControlStructures.php 28 0
77
tests/input/doc-comment-spacing.php 11 0
88
tests/input/duplicate-assignment-variable.php 1 0
99
-tests/input/EarlyReturn.php 7 0
1010
-tests/input/example-class.php 47 0
11-
-tests/input/ExampleBackedEnum.php 3 0
11+
-tests/input/ExampleBackedEnum.php 5 0
1212
-tests/input/Exceptions.php 1 0
1313
+tests/input/EarlyReturn.php 6 0
1414
+tests/input/example-class.php 41 0
@@ -37,7 +37,7 @@ index d1e1fad..ea3b611 100644
3737
tests/input/semicolon_spacing.php 3 0
3838
tests/input/single-line-array-spacing.php 5 0
3939
tests/input/spread-operator.php 6 0
40-
@@ -46,17 +43,16 @@
40+
@@ -46,17 +43,16 @@ tests/input/strings.php 3 0
4141
tests/input/superfluous-naming.php 11 0
4242
tests/input/test-case.php 8 0
4343
tests/input/trailing_comma_on_array.php 1 0
@@ -51,10 +51,10 @@ index d1e1fad..ea3b611 100644
5151
-tests/input/UselessConditions.php 21 0
5252
+tests/input/UselessConditions.php 20 0
5353
----------------------------------------------------------------------
54-
-A TOTAL OF 462 ERRORS AND 2 WARNINGS WERE FOUND IN 50 FILES
54+
-A TOTAL OF 464 ERRORS AND 2 WARNINGS WERE FOUND IN 50 FILES
5555
+A TOTAL OF 415 ERRORS AND 2 WARNINGS WERE FOUND IN 46 FILES
5656
----------------------------------------------------------------------
57-
-PHPCBF CAN FIX 378 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
57+
-PHPCBF CAN FIX 380 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5858
+PHPCBF CAN FIX 331 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5959
----------------------------------------------------------------------
6060

@@ -86,16 +86,23 @@ index fc734db..caf1dbb 100644
8686
foreach ($items as $item) {
8787
if (! $item->isItem()) {
8888
diff --git a/tests/fixed/ExampleBackedEnum.php b/tests/fixed/ExampleBackedEnum.php
89-
index cc38c54..fe54eb9 100644
89+
index fd701eb..fe54eb9 100644
9090
--- a/tests/fixed/ExampleBackedEnum.php
9191
+++ b/tests/fixed/ExampleBackedEnum.php
92-
@@ -3,7 +3,3 @@
92+
@@ -3,14 +3,3 @@
9393
declare(strict_types=1);
9494

9595
namespace ExampleBackedEnum;
9696
-
9797
-enum ExampleBackedEnum: int
9898
-{
99+
- case FOO = 0;
100+
- case BAR = 1;
101+
-
102+
- case BAZ = 2;
103+
-
104+
- /** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */
105+
- case BAM = 1234;
99106
-}
100107
diff --git a/tests/fixed/Exceptions.php b/tests/fixed/Exceptions.php
101108
index db7408b..9b146c6 100644
@@ -453,16 +460,25 @@ index 73944e3..a0e0b2e 100644
453460
echo 5;
454461
}
455462
diff --git a/tests/input/ExampleBackedEnum.php b/tests/input/ExampleBackedEnum.php
456-
index 0c47286..fe54eb9 100644
463+
index 3b09f47..fe54eb9 100644
457464
--- a/tests/input/ExampleBackedEnum.php
458465
+++ b/tests/input/ExampleBackedEnum.php
459-
@@ -3,7 +3,3 @@
466+
@@ -3,16 +3,3 @@
460467
declare(strict_types=1);
461468

462469
namespace ExampleBackedEnum;
463470
-
464471
-enum ExampleBackedEnum : int
465472
-{
473+
- case FOO = 0;
474+
- case BAR = 1;
475+
-
476+
-
477+
- case BAZ = 2;
478+
-
479+
-
480+
- /** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */
481+
- case BAM = 1234;
466482
-}
467483
diff --git a/tests/input/Exceptions.php b/tests/input/Exceptions.php
468484
index 3aaa30f..9b146c6 100644

tests/php73-compatibility.patch

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
diff --git a/tests/expected_report.txt b/tests/expected_report.txt
2-
index d1e1fad..9a78bc1 100644
2+
index 087995d..cd61b3f 100644
33
--- a/tests/expected_report.txt
44
+++ b/tests/expected_report.txt
5-
@@ -17,26 +17,23 @@
5+
@@ -17,26 +17,23 @@ tests/input/constants-var.php 6 0
66
tests/input/ControlStructures.php 28 0
77
tests/input/doc-comment-spacing.php 11 0
88
tests/input/duplicate-assignment-variable.php 1 0
99
-tests/input/EarlyReturn.php 7 0
1010
-tests/input/example-class.php 47 0
11-
-tests/input/ExampleBackedEnum.php 3 0
11+
-tests/input/ExampleBackedEnum.php 5 0
1212
-tests/input/Exceptions.php 1 0
1313
+tests/input/EarlyReturn.php 6 0
1414
+tests/input/example-class.php 41 0
@@ -37,7 +37,7 @@ index d1e1fad..9a78bc1 100644
3737
tests/input/semicolon_spacing.php 3 0
3838
tests/input/single-line-array-spacing.php 5 0
3939
tests/input/spread-operator.php 6 0
40-
@@ -46,17 +43,17 @@
40+
@@ -46,17 +43,17 @@ tests/input/strings.php 3 0
4141
tests/input/superfluous-naming.php 11 0
4242
tests/input/test-case.php 8 0
4343
tests/input/trailing_comma_on_array.php 1 0
@@ -52,10 +52,10 @@ index d1e1fad..9a78bc1 100644
5252
-tests/input/UselessConditions.php 21 0
5353
+tests/input/UselessConditions.php 20 0
5454
----------------------------------------------------------------------
55-
-A TOTAL OF 462 ERRORS AND 2 WARNINGS WERE FOUND IN 50 FILES
55+
-A TOTAL OF 464 ERRORS AND 2 WARNINGS WERE FOUND IN 50 FILES
5656
+A TOTAL OF 417 ERRORS AND 2 WARNINGS WERE FOUND IN 47 FILES
5757
----------------------------------------------------------------------
58-
-PHPCBF CAN FIX 378 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
58+
-PHPCBF CAN FIX 380 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5959
+PHPCBF CAN FIX 333 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
6060
----------------------------------------------------------------------
6161

@@ -87,16 +87,23 @@ index fc734db..caf1dbb 100644
8787
foreach ($items as $item) {
8888
if (! $item->isItem()) {
8989
diff --git a/tests/fixed/ExampleBackedEnum.php b/tests/fixed/ExampleBackedEnum.php
90-
index cc38c54..fe54eb9 100644
90+
index fd701eb..fe54eb9 100644
9191
--- a/tests/fixed/ExampleBackedEnum.php
9292
+++ b/tests/fixed/ExampleBackedEnum.php
93-
@@ -3,7 +3,3 @@
93+
@@ -3,14 +3,3 @@
9494
declare(strict_types=1);
9595

9696
namespace ExampleBackedEnum;
9797
-
9898
-enum ExampleBackedEnum: int
9999
-{
100+
- case FOO = 0;
101+
- case BAR = 1;
102+
-
103+
- case BAZ = 2;
104+
-
105+
- /** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */
106+
- case BAM = 1234;
100107
-}
101108
diff --git a/tests/fixed/Exceptions.php b/tests/fixed/Exceptions.php
102109
index db7408b..9b146c6 100644
@@ -415,16 +422,25 @@ index 73944e3..a0e0b2e 100644
415422
echo 5;
416423
}
417424
diff --git a/tests/input/ExampleBackedEnum.php b/tests/input/ExampleBackedEnum.php
418-
index 0c47286..fe54eb9 100644
425+
index 3b09f47..fe54eb9 100644
419426
--- a/tests/input/ExampleBackedEnum.php
420427
+++ b/tests/input/ExampleBackedEnum.php
421-
@@ -3,7 +3,3 @@
428+
@@ -3,16 +3,3 @@
422429
declare(strict_types=1);
423430

424431
namespace ExampleBackedEnum;
425432
-
426433
-enum ExampleBackedEnum : int
427434
-{
435+
- case FOO = 0;
436+
- case BAR = 1;
437+
-
438+
-
439+
- case BAZ = 2;
440+
-
441+
-
442+
- /** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */
443+
- case BAM = 1234;
428444
-}
429445
diff --git a/tests/input/Exceptions.php b/tests/input/Exceptions.php
430446
index 3aaa30f..9b146c6 100644

tests/php74-compatibility.patch

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
diff --git a/tests/expected_report.txt b/tests/expected_report.txt
2-
index d1e1fad..ed67841 100644
2+
index 087995d..5284a56 100644
33
--- a/tests/expected_report.txt
44
+++ b/tests/expected_report.txt
5-
@@ -17,26 +17,23 @@
5+
@@ -17,26 +17,23 @@ tests/input/constants-var.php 6 0
66
tests/input/ControlStructures.php 28 0
77
tests/input/doc-comment-spacing.php 11 0
88
tests/input/duplicate-assignment-variable.php 1 0
99
-tests/input/EarlyReturn.php 7 0
1010
-tests/input/example-class.php 47 0
11-
-tests/input/ExampleBackedEnum.php 3 0
11+
-tests/input/ExampleBackedEnum.php 5 0
1212
-tests/input/Exceptions.php 1 0
1313
+tests/input/EarlyReturn.php 6 0
1414
+tests/input/example-class.php 44 0
@@ -35,7 +35,7 @@ index d1e1fad..ed67841 100644
3535
tests/input/semicolon_spacing.php 3 0
3636
tests/input/single-line-array-spacing.php 5 0
3737
tests/input/spread-operator.php 6 0
38-
@@ -46,17 +43,17 @@
38+
@@ -46,17 +43,17 @@ tests/input/strings.php 3 0
3939
tests/input/superfluous-naming.php 11 0
4040
tests/input/test-case.php 8 0
4141
tests/input/trailing_comma_on_array.php 1 0
@@ -50,10 +50,10 @@ index d1e1fad..ed67841 100644
5050
-tests/input/UselessConditions.php 21 0
5151
+tests/input/UselessConditions.php 20 0
5252
----------------------------------------------------------------------
53-
-A TOTAL OF 462 ERRORS AND 2 WARNINGS WERE FOUND IN 50 FILES
53+
-A TOTAL OF 464 ERRORS AND 2 WARNINGS WERE FOUND IN 50 FILES
5454
+A TOTAL OF 426 ERRORS AND 2 WARNINGS WERE FOUND IN 47 FILES
5555
----------------------------------------------------------------------
56-
-PHPCBF CAN FIX 378 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
56+
-PHPCBF CAN FIX 380 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5757
+PHPCBF CAN FIX 342 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5858
----------------------------------------------------------------------
5959

@@ -85,16 +85,23 @@ index fc734db..caf1dbb 100644
8585
foreach ($items as $item) {
8686
if (! $item->isItem()) {
8787
diff --git a/tests/fixed/ExampleBackedEnum.php b/tests/fixed/ExampleBackedEnum.php
88-
index cc38c54..fe54eb9 100644
88+
index fd701eb..fe54eb9 100644
8989
--- a/tests/fixed/ExampleBackedEnum.php
9090
+++ b/tests/fixed/ExampleBackedEnum.php
91-
@@ -3,7 +3,3 @@
91+
@@ -3,14 +3,3 @@
9292
declare(strict_types=1);
9393

9494
namespace ExampleBackedEnum;
9595
-
9696
-enum ExampleBackedEnum: int
9797
-{
98+
- case FOO = 0;
99+
- case BAR = 1;
100+
-
101+
- case BAZ = 2;
102+
-
103+
- /** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */
104+
- case BAM = 1234;
98105
-}
99106
diff --git a/tests/fixed/Exceptions.php b/tests/fixed/Exceptions.php
100107
index db7408b..9b146c6 100644
@@ -355,16 +362,25 @@ index 73944e3..a0e0b2e 100644
355362
echo 5;
356363
}
357364
diff --git a/tests/input/ExampleBackedEnum.php b/tests/input/ExampleBackedEnum.php
358-
index 0c47286..fe54eb9 100644
365+
index 3b09f47..fe54eb9 100644
359366
--- a/tests/input/ExampleBackedEnum.php
360367
+++ b/tests/input/ExampleBackedEnum.php
361-
@@ -3,7 +3,3 @@
368+
@@ -3,16 +3,3 @@
362369
declare(strict_types=1);
363370

364371
namespace ExampleBackedEnum;
365372
-
366373
-enum ExampleBackedEnum : int
367374
-{
375+
- case FOO = 0;
376+
- case BAR = 1;
377+
-
378+
-
379+
- case BAZ = 2;
380+
-
381+
-
382+
- /** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */
383+
- case BAM = 1234;
368384
-}
369385
diff --git a/tests/input/Exceptions.php b/tests/input/Exceptions.php
370386
index 3aaa30f..9b146c6 100644

0 commit comments

Comments
 (0)