From f0ae45fd2d9db69d5a2fe64a415325e624ad4cca Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Mon, 27 Jun 2022 10:22:52 +0300 Subject: [PATCH] feat: enforce spaces between constants --- lib/Doctrine/ruleset.xml | 2 ++ tests/expected_report.txt | 2 +- tests/fixed/constants-var.php | 11 +++++++++++ tests/input/constants-var.php | 12 ++++++++++++ tests/php73-compatibility.patch | 2 +- tests/php74-compatibility.patch | 2 +- tests/php80-compatibility.patch | 2 +- tests/php81-compatibility.patch | 2 +- 8 files changed, 30 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ruleset.xml b/lib/Doctrine/ruleset.xml index abc6fb9b..9a49702c 100644 --- a/lib/Doctrine/ruleset.xml +++ b/lib/Doctrine/ruleset.xml @@ -122,6 +122,8 @@ + + diff --git a/tests/expected_report.txt b/tests/expected_report.txt index 1d5a7d3a..3ddb4fc3 100644 --- a/tests/expected_report.txt +++ b/tests/expected_report.txt @@ -48,7 +48,7 @@ tests/input/UselessConditions.php 20 0 ---------------------------------------------------------------------- A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES ---------------------------------------------------------------------- -PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +PHPCBF CAN FIX 316 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- diff --git a/tests/fixed/constants-var.php b/tests/fixed/constants-var.php index 8959c563..93405181 100644 --- a/tests/fixed/constants-var.php +++ b/tests/fixed/constants-var.php @@ -4,6 +4,8 @@ namespace ConstantsVar; +// phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses, Squiz.Classes.ClassFileName.NoMatch + const FOO = 123; const BAR_1 = 1; @@ -16,3 +18,12 @@ 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'; +} diff --git a/tests/input/constants-var.php b/tests/input/constants-var.php index 037e9bd7..dc8c2acf 100644 --- a/tests/input/constants-var.php +++ b/tests/input/constants-var.php @@ -4,6 +4,8 @@ namespace ConstantsVar; +// phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses, Squiz.Classes.ClassFileName.NoMatch + /** @var int */ const FOO = 123; @@ -16,3 +18,13 @@ class Bar protected const PROPERTY_1 = '1', PROPERTY_2 = '2'; } + + +class Spacing +{ + public const FOO = 'bar'; + public const BAR = 'bar'; + + + public const BAZ = 'baz'; +} diff --git a/tests/php73-compatibility.patch b/tests/php73-compatibility.patch index 8e056058..6624c51a 100644 --- a/tests/php73-compatibility.patch +++ b/tests/php73-compatibility.patch @@ -17,7 +17,7 @@ index 1d5a7d3..fae9e70 100644 -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 ---------------------------------------------------------------------- --PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +-PHPCBF CAN FIX 316 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +PHPCBF CAN FIX 317 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- diff --git a/tests/php74-compatibility.patch b/tests/php74-compatibility.patch index 55366f8b..fac90e53 100644 --- a/tests/php74-compatibility.patch +++ b/tests/php74-compatibility.patch @@ -39,7 +39,7 @@ index 1d5a7d3..91e97e7 100644 -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 ---------------------------------------------------------------------- --PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +-PHPCBF CAN FIX 316 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +PHPCBF CAN FIX 326 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- diff --git a/tests/php80-compatibility.patch b/tests/php80-compatibility.patch index c6923131..6660dd88 100644 --- a/tests/php80-compatibility.patch +++ b/tests/php80-compatibility.patch @@ -52,7 +52,7 @@ index 1d5a7d3..03460f2 100644 -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 ---------------------------------------------------------------------- --PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +-PHPCBF CAN FIX 316 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +PHPCBF CAN FIX 354 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- diff --git a/tests/php81-compatibility.patch b/tests/php81-compatibility.patch index 776b7858..5861405f 100644 --- a/tests/php81-compatibility.patch +++ b/tests/php81-compatibility.patch @@ -53,7 +53,7 @@ index 1d5a7d3..e9394b1 100644 -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 ---------------------------------------------------------------------- --PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +-PHPCBF CAN FIX 316 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +PHPCBF CAN FIX 360 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ----------------------------------------------------------------------