From a7910252b3be840eaf53f887e76780aef10babf7 Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Sat, 13 Jul 2024 23:21:13 +0100 Subject: [PATCH 1/2] Generic/SpreadOperatorSpacingAfter: rename unit test case file to allow for adding more --- ... SpreadOperatorSpacingAfterUnitTest.1.inc} | 0 ...dOperatorSpacingAfterUnitTest.1.inc.fixed} | 0 .../SpreadOperatorSpacingAfterUnitTest.php | 32 ++++++++++++------- 3 files changed, 20 insertions(+), 12 deletions(-) rename src/Standards/Generic/Tests/WhiteSpace/{SpreadOperatorSpacingAfterUnitTest.inc => SpreadOperatorSpacingAfterUnitTest.1.inc} (100%) rename src/Standards/Generic/Tests/WhiteSpace/{SpreadOperatorSpacingAfterUnitTest.inc.fixed => SpreadOperatorSpacingAfterUnitTest.1.inc.fixed} (100%) diff --git a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.inc b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.inc rename to src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc.fixed similarity index 100% rename from src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.inc.fixed rename to src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc.fixed diff --git a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php index 90842320e2..97217b37ca 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php @@ -26,21 +26,29 @@ final class SpreadOperatorSpacingAfterUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [ - 12 => 1, - 13 => 1, - 20 => 2, - 40 => 1, - 41 => 1, - 46 => 2, - 60 => 1, - 61 => 1, - 66 => 2, - ]; + switch ($testFile) { + case 'SpreadOperatorSpacingAfterUnitTest.1.inc': + return [ + 12 => 1, + 13 => 1, + 20 => 2, + 40 => 1, + 41 => 1, + 46 => 2, + 60 => 1, + 61 => 1, + 66 => 2, + ]; + + default: + return []; + }//end switch }//end getErrorList() From 530e7ab670729e5d57d8ad9b4fb2e5bc1253b6a7 Mon Sep 17 00:00:00 2001 From: Bill Ruddock Date: Sat, 13 Jul 2024 23:30:53 +0100 Subject: [PATCH 2/2] Generic/SpreadOperatorSpacingAfter: move parse error test to its own file --- .../Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc | 3 --- .../WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc.fixed | 3 --- .../Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.2.inc | 4 ++++ 3 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.2.inc diff --git a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc index fb5c181429..d30cd847a9 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc +++ b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc @@ -74,6 +74,3 @@ $map = array_map(strtolower(...), $map); // Ignore PHP 8.1 first class callable declarations. $map = array_map(strtolower( ... ), $map); - -// Intentional parse error. This has to be the last test in the file. -function bar( ... diff --git a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc.fixed index 9388acfc63..dcce703d0f 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.1.inc.fixed @@ -69,6 +69,3 @@ $map = array_map(strtolower(...), $map); // Ignore PHP 8.1 first class callable declarations. $map = array_map(strtolower( ... ), $map); - -// Intentional parse error. This has to be the last test in the file. -function bar( ... diff --git a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.2.inc b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.2.inc new file mode 100644 index 0000000000..6a753a2a14 --- /dev/null +++ b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.2.inc @@ -0,0 +1,4 @@ +