Skip to content

Commit

Permalink
Merge pull request #295 from simPod/property-spacing
Browse files Browse the repository at this point in the history
feat: handle blank lines between class properties
  • Loading branch information
greg0ire authored Oct 15, 2022
2 parents 71c07d1 + ecc6746 commit f2488f5
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 18 deletions.
6 changes: 6 additions & 0 deletions lib/Doctrine/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@
</rule>
<!-- Add one line around parent call in order to improve readability -->
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
<!-- Ensure that there are consistent blank lines between properties. -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing">
<properties>
<property name="minLinesCountBeforeWithComment" value="0" />
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<!-- https://github.com/slevomat/coding-standard#slevomatcodingstandardclassespropertydeclaration- -->
Expand Down
5 changes: 3 additions & 2 deletions tests/expected_report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tests/input/arrow-functions-format.php 10 0
tests/input/assignment-operators.php 4 0
tests/input/binary_operators.php 9 0
tests/input/class-references.php 10 0
tests/input/ClassPropertySpacing.php 2 0
tests/input/concatenation_spacing.php 49 0
tests/input/constants-no-lsb.php 2 0
tests/input/constants-var.php 7 0
Expand Down Expand Up @@ -50,9 +51,9 @@ tests/input/use-ordering.php 1 0
tests/input/useless-semicolon.php 2 0
tests/input/UselessConditions.php 21 0
----------------------------------------------------------------------
A TOTAL OF 435 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
A TOTAL OF 437 ERRORS AND 0 WARNINGS WERE FOUND IN 47 FILES
----------------------------------------------------------------------
PHPCBF CAN FIX 368 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
PHPCBF CAN FIX 370 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


18 changes: 18 additions & 0 deletions tests/fixed/ClassPropertySpacing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Spacing;

final class ClassPropertySpacing
{
public bool $foo;

/** @var string[] */
public array $bar;
/** @var string[] */
public array $baz;
public int $qux;

public int $fred;
}
20 changes: 20 additions & 0 deletions tests/input/ClassPropertySpacing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Spacing;

final class ClassPropertySpacing
{
public bool $foo;


/** @var string[] */
public array $bar;
/** @var string[] */
public array $baz;
public int $qux;


public int $fred;
}
8 changes: 4 additions & 4 deletions tests/php72-compatibility.patch
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ index 151bce4..0afca8c 100644
-tests/input/UselessConditions.php 21 0
+tests/input/UselessConditions.php 20 0
----------------------------------------------------------------------
-A TOTAL OF 435 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
+A TOTAL OF 388 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
-A TOTAL OF 437 ERRORS AND 0 WARNINGS WERE FOUND IN 47 FILES
+A TOTAL OF 390 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 368 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 321 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-PHPCBF CAN FIX 370 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 323 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


Expand Down
8 changes: 4 additions & 4 deletions tests/php73-compatibility.patch
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ index 151bce4..94718eb 100644
-tests/input/UselessConditions.php 21 0
+tests/input/UselessConditions.php 20 0
----------------------------------------------------------------------
-A TOTAL OF 435 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
+A TOTAL OF 390 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
-A TOTAL OF 437 ERRORS AND 0 WARNINGS WERE FOUND IN 47 FILES
+A TOTAL OF 392 ERRORS AND 0 WARNINGS WERE FOUND IN 44 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 368 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 323 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-PHPCBF CAN FIX 370 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 325 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


Expand Down
8 changes: 4 additions & 4 deletions tests/php74-compatibility.patch
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ index 151bce4..08a098f 100644
-tests/input/UselessConditions.php 21 0
+tests/input/UselessConditions.php 20 0
----------------------------------------------------------------------
-A TOTAL OF 435 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
+A TOTAL OF 399 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
-A TOTAL OF 437 ERRORS AND 0 WARNINGS WERE FOUND IN 47 FILES
+A TOTAL OF 401 ERRORS AND 0 WARNINGS WERE FOUND IN 44 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 368 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 332 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-PHPCBF CAN FIX 370 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 334 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


Expand Down
8 changes: 4 additions & 4 deletions tests/php80-compatibility.patch
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ index 151bce4..873691d 100644
tests/input/useless-semicolon.php 2 0
tests/input/UselessConditions.php 21 0
----------------------------------------------------------------------
-A TOTAL OF 435 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
+A TOTAL OF 429 ERRORS AND 0 WARNINGS WERE FOUND IN 45 FILES
-A TOTAL OF 437 ERRORS AND 0 WARNINGS WERE FOUND IN 47 FILES
+A TOTAL OF 431 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 368 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 362 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-PHPCBF CAN FIX 370 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 364 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


Expand Down

0 comments on commit f2488f5

Please sign in to comment.