From 5a8c69c1fc722e77e00c15d7f0a2606224340f07 Mon Sep 17 00:00:00 2001 From: Vladyslav Startsev Date: Sun, 30 Dec 2018 00:34:04 +0200 Subject: [PATCH 1/2] Add failing test to reproduce bug with associative arrays PHPCBF is adding two commas when fixing missing trailing commas on associative arrays. --- tests/expected_report.txt | 5 +++-- tests/fixed/trailing_comma_on_array.php | 8 ++++++++ tests/input/trailing_comma_on_array.php | 8 ++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tests/fixed/trailing_comma_on_array.php create mode 100644 tests/input/trailing_comma_on_array.php diff --git a/tests/expected_report.txt b/tests/expected_report.txt index 31ba75c8..263e3faf 100644 --- a/tests/expected_report.txt +++ b/tests/expected_report.txt @@ -24,13 +24,14 @@ tests/input/return_type_on_methods.php 17 0 tests/input/semicolon_spacing.php 3 0 tests/input/static-closures.php 1 0 tests/input/test-case.php 8 0 +tests/input/trailing_comma_on_array.php 1 0 tests/input/traits-uses.php 11 0 tests/input/UnusedVariables.php 1 0 tests/input/useless-semicolon.php 2 0 ---------------------------------------------------------------------- -A TOTAL OF 215 ERRORS AND 0 WARNINGS WERE FOUND IN 24 FILES +A TOTAL OF 216 ERRORS AND 0 WARNINGS WERE FOUND IN 25 FILES ---------------------------------------------------------------------- -PHPCBF CAN FIX 185 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +PHPCBF CAN FIX 186 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- diff --git a/tests/fixed/trailing_comma_on_array.php b/tests/fixed/trailing_comma_on_array.php new file mode 100644 index 00000000..f4ae3f96 --- /dev/null +++ b/tests/fixed/trailing_comma_on_array.php @@ -0,0 +1,8 @@ + 'value', + 'key2' => 'value', +]; diff --git a/tests/input/trailing_comma_on_array.php b/tests/input/trailing_comma_on_array.php new file mode 100644 index 00000000..aeb1a729 --- /dev/null +++ b/tests/input/trailing_comma_on_array.php @@ -0,0 +1,8 @@ + 'value', + 'key2' => 'value' +]; From 7da946c0d8a43a83c08ee388fa31e61f87245a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Fri, 4 Jan 2019 12:18:47 +0100 Subject: [PATCH 2/2] Exclude conflicting sniff This is already solved by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma. More info: https://github.com/slevomat/coding-standard/issues/490 --- lib/Doctrine/ruleset.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Doctrine/ruleset.xml b/lib/Doctrine/ruleset.xml index 064542a3..3a86fa70 100644 --- a/lib/Doctrine/ruleset.xml +++ b/lib/Doctrine/ruleset.xml @@ -375,6 +375,7 @@ +