Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enforce spaces between constants #274

Merged
merged 1 commit into from Jul 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Doctrine/ruleset.xml
Expand Up @@ -122,6 +122,8 @@
<property name="fixable" value="true"/>
</properties>
</rule>
<!-- Enforce consistent constant spacing -->
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing"/>
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
Expand Down
6 changes: 3 additions & 3 deletions tests/expected_report.txt
Expand Up @@ -10,7 +10,7 @@ tests/input/binary_operators.php 9 0
tests/input/class-references.php 10 0
tests/input/concatenation_spacing.php 49 0
tests/input/constants-no-lsb.php 2 0
tests/input/constants-var.php 6 0
tests/input/constants-var.php 7 0
tests/input/ControlStructures.php 28 0
tests/input/doc-comment-spacing.php 11 0
tests/input/duplicate-assignment-variable.php 1 0
Expand Down Expand Up @@ -46,9 +46,9 @@ tests/input/use-ordering.php 1 0
tests/input/useless-semicolon.php 2 0
tests/input/UselessConditions.php 20 0
----------------------------------------------------------------------
A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
A TOTAL OF 382 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
----------------------------------------------------------------------
PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
PHPCBF CAN FIX 317 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


13 changes: 13 additions & 0 deletions tests/fixed/constants-var.php
Expand Up @@ -4,6 +4,8 @@

namespace ConstantsVar;

// phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses, Squiz.Classes.ClassFileName.NoMatch

const FOO = 123;

const BAR_1 = 1;
Expand All @@ -16,3 +18,14 @@ class Bar
protected const PROPERTY_1 = '1';
protected const PROPERTY_2 = '2';
}

class Spacing
{
public const FOO = 'bar';
public const BAR = 'bar';

public const BAZ = 'baz';

/** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */
private const BAM = 1234;
}
15 changes: 15 additions & 0 deletions tests/input/constants-var.php
Expand Up @@ -4,6 +4,8 @@

namespace ConstantsVar;

// phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses, Squiz.Classes.ClassFileName.NoMatch

/** @var int */
const FOO = 123;

Expand All @@ -16,3 +18,16 @@ class Bar

protected const PROPERTY_1 = '1', PROPERTY_2 = '2';
}

class Spacing
{
public const FOO = 'bar';
public const BAR = 'bar';


public const BAZ = 'baz';
simPod marked this conversation as resolved.
Show resolved Hide resolved


/** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */
private const BAM = 1234;
}
8 changes: 4 additions & 4 deletions tests/php73-compatibility.patch
Expand Up @@ -14,11 +14,11 @@ index 1d5a7d3..fae9e70 100644
tests/input/useless-semicolon.php 2 0
tests/input/UselessConditions.php 20 0
----------------------------------------------------------------------
-A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
+A TOTAL OF 383 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
-A TOTAL OF 382 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
+A TOTAL OF 384 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 317 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-PHPCBF CAN FIX 317 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 319 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


Expand Down
8 changes: 4 additions & 4 deletions tests/php74-compatibility.patch
Expand Up @@ -36,11 +36,11 @@ index 1d5a7d3..91e97e7 100644
tests/input/useless-semicolon.php 2 0
tests/input/UselessConditions.php 20 0
----------------------------------------------------------------------
-A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
+A TOTAL OF 392 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
-A TOTAL OF 382 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
+A TOTAL OF 393 ERRORS AND 0 WARNINGS WERE FOUND IN 43 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 326 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-PHPCBF CAN FIX 317 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 328 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


Expand Down
10 changes: 5 additions & 5 deletions tests/php80-compatibility.patch
Expand Up @@ -2,7 +2,7 @@ diff --git a/tests/expected_report.txt b/tests/expected_report.txt
index 1d5a7d3..03460f2 100644
--- a/tests/expected_report.txt
+++ b/tests/expected_report.txt
@@ -14,23 +14,24 @@ tests/input/constants-var.php 6 0
@@ -14,23 +14,24 @@ tests/input/constants-var.php 7 0
tests/input/ControlStructures.php 28 0
tests/input/doc-comment-spacing.php 11 0
tests/input/duplicate-assignment-variable.php 1 0
Expand Down Expand Up @@ -49,11 +49,11 @@ index 1d5a7d3..03460f2 100644
-tests/input/UselessConditions.php 20 0
+tests/input/UselessConditions.php 21 0
----------------------------------------------------------------------
-A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
+A TOTAL OF 420 ERRORS AND 0 WARNINGS WERE FOUND IN 44 FILES
-A TOTAL OF 382 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
+A TOTAL OF 421 ERRORS AND 0 WARNINGS WERE FOUND IN 44 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 354 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-PHPCBF CAN FIX 317 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 356 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


Expand Down
10 changes: 5 additions & 5 deletions tests/php81-compatibility.patch
Expand Up @@ -2,7 +2,7 @@ diff --git a/tests/expected_report.txt b/tests/expected_report.txt
index 1d5a7d3..e9394b1 100644
--- a/tests/expected_report.txt
+++ b/tests/expected_report.txt
@@ -14,23 +14,25 @@ tests/input/constants-var.php 6 0
@@ -14,23 +14,25 @@ tests/input/constants-var.php 7 0
tests/input/ControlStructures.php 28 0
tests/input/doc-comment-spacing.php 11 0
tests/input/duplicate-assignment-variable.php 1 0
Expand Down Expand Up @@ -50,11 +50,11 @@ index 1d5a7d3..e9394b1 100644
-tests/input/UselessConditions.php 20 0
+tests/input/UselessConditions.php 21 0
----------------------------------------------------------------------
-A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
+A TOTAL OF 426 ERRORS AND 0 WARNINGS WERE FOUND IN 45 FILES
-A TOTAL OF 382 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
+A TOTAL OF 427 ERRORS AND 0 WARNINGS WERE FOUND IN 45 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 360 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-PHPCBF CAN FIX 317 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 362 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


Expand Down