Skip to content

Commit ecc6746

Browse files
committed
feat: handle blank lines between class properties
1 parent 71c07d1 commit ecc6746

File tree

8 files changed

+63
-18
lines changed

8 files changed

+63
-18
lines changed

lib/Doctrine/ruleset.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@
137137
</rule>
138138
<!-- Add one line around parent call in order to improve readability -->
139139
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
140+
<!-- Ensure that there are consistent blank lines between properties. -->
141+
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing">
142+
<properties>
143+
<property name="minLinesCountBeforeWithComment" value="0" />
144+
</properties>
145+
</rule>
140146
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
141147
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
142148
<!-- https://github.com/slevomat/coding-standard#slevomatcodingstandardclassespropertydeclaration- -->

tests/expected_report.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ tests/input/arrow-functions-format.php 10 0
88
tests/input/assignment-operators.php 4 0
99
tests/input/binary_operators.php 9 0
1010
tests/input/class-references.php 10 0
11+
tests/input/ClassPropertySpacing.php 2 0
1112
tests/input/concatenation_spacing.php 49 0
1213
tests/input/constants-no-lsb.php 2 0
1314
tests/input/constants-var.php 7 0
@@ -50,9 +51,9 @@ tests/input/use-ordering.php 1 0
5051
tests/input/useless-semicolon.php 2 0
5152
tests/input/UselessConditions.php 21 0
5253
----------------------------------------------------------------------
53-
A TOTAL OF 435 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
54+
A TOTAL OF 437 ERRORS AND 0 WARNINGS WERE FOUND IN 47 FILES
5455
----------------------------------------------------------------------
55-
PHPCBF CAN FIX 368 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
56+
PHPCBF CAN FIX 370 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5657
----------------------------------------------------------------------
5758

5859

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Spacing;
6+
7+
final class ClassPropertySpacing
8+
{
9+
public bool $foo;
10+
11+
/** @var string[] */
12+
public array $bar;
13+
/** @var string[] */
14+
public array $baz;
15+
public int $qux;
16+
17+
public int $fred;
18+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Spacing;
6+
7+
final class ClassPropertySpacing
8+
{
9+
public bool $foo;
10+
11+
12+
/** @var string[] */
13+
public array $bar;
14+
/** @var string[] */
15+
public array $baz;
16+
public int $qux;
17+
18+
19+
public int $fred;
20+
}

tests/php72-compatibility.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ index 151bce4..0afca8c 100644
5151
-tests/input/UselessConditions.php 21 0
5252
+tests/input/UselessConditions.php 20 0
5353
----------------------------------------------------------------------
54-
-A TOTAL OF 435 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
55-
+A TOTAL OF 388 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
54+
-A TOTAL OF 437 ERRORS AND 0 WARNINGS WERE FOUND IN 47 FILES
55+
+A TOTAL OF 390 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
5656
----------------------------------------------------------------------
57-
-PHPCBF CAN FIX 368 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
58-
+PHPCBF CAN FIX 321 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
57+
-PHPCBF CAN FIX 370 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
58+
+PHPCBF CAN FIX 323 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5959
----------------------------------------------------------------------
6060

6161

tests/php73-compatibility.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ index 151bce4..94718eb 100644
5252
-tests/input/UselessConditions.php 21 0
5353
+tests/input/UselessConditions.php 20 0
5454
----------------------------------------------------------------------
55-
-A TOTAL OF 435 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
56-
+A TOTAL OF 390 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
55+
-A TOTAL OF 437 ERRORS AND 0 WARNINGS WERE FOUND IN 47 FILES
56+
+A TOTAL OF 392 ERRORS AND 0 WARNINGS WERE FOUND IN 44 FILES
5757
----------------------------------------------------------------------
58-
-PHPCBF CAN FIX 368 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
59-
+PHPCBF CAN FIX 323 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
58+
-PHPCBF CAN FIX 370 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
59+
+PHPCBF CAN FIX 325 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
6060
----------------------------------------------------------------------
6161

6262

tests/php74-compatibility.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ index 151bce4..08a098f 100644
5050
-tests/input/UselessConditions.php 21 0
5151
+tests/input/UselessConditions.php 20 0
5252
----------------------------------------------------------------------
53-
-A TOTAL OF 435 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
54-
+A TOTAL OF 399 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
53+
-A TOTAL OF 437 ERRORS AND 0 WARNINGS WERE FOUND IN 47 FILES
54+
+A TOTAL OF 401 ERRORS AND 0 WARNINGS WERE FOUND IN 44 FILES
5555
----------------------------------------------------------------------
56-
-PHPCBF CAN FIX 368 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
57-
+PHPCBF CAN FIX 332 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
56+
-PHPCBF CAN FIX 370 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
57+
+PHPCBF CAN FIX 334 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5858
----------------------------------------------------------------------
5959

6060

tests/php80-compatibility.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ index 151bce4..873691d 100644
2323
tests/input/useless-semicolon.php 2 0
2424
tests/input/UselessConditions.php 21 0
2525
----------------------------------------------------------------------
26-
-A TOTAL OF 435 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
27-
+A TOTAL OF 429 ERRORS AND 0 WARNINGS WERE FOUND IN 45 FILES
26+
-A TOTAL OF 437 ERRORS AND 0 WARNINGS WERE FOUND IN 47 FILES
27+
+A TOTAL OF 431 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
2828
----------------------------------------------------------------------
29-
-PHPCBF CAN FIX 368 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
30-
+PHPCBF CAN FIX 362 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
29+
-PHPCBF CAN FIX 370 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
30+
+PHPCBF CAN FIX 364 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
3131
----------------------------------------------------------------------
3232

3333

0 commit comments

Comments
 (0)