From 7e550f4ce8f577558aa41e4d4bb98451eb14f251 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 13 May 2024 20:50:43 -0300 Subject: [PATCH 1/2] Generic/FunctionCallArgumentSpacing: rename test case file Doing this to be able to create tests with syntax errors on separate files --- ...FunctionCallArgumentSpacingUnitTest.1.inc} | 0 ...onCallArgumentSpacingUnitTest.1.inc.fixed} | 0 .../FunctionCallArgumentSpacingUnitTest.php | 74 ++++++++++--------- 3 files changed, 41 insertions(+), 33 deletions(-) rename src/Standards/Generic/Tests/Functions/{FunctionCallArgumentSpacingUnitTest.inc => FunctionCallArgumentSpacingUnitTest.1.inc} (100%) rename src/Standards/Generic/Tests/Functions/{FunctionCallArgumentSpacingUnitTest.inc.fixed => FunctionCallArgumentSpacingUnitTest.1.inc.fixed} (100%) diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc rename to src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc.fixed b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc.fixed similarity index 100% rename from src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc.fixed rename to src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc.fixed diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php index f630965f37..f976b48c73 100644 --- a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php @@ -26,42 +26,50 @@ final class FunctionCallArgumentSpacingUnitTest 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 test file to process. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [ - 5 => 1, - 6 => 1, - 7 => 2, - 8 => 1, - 11 => 1, - 12 => 1, - 13 => 1, - 42 => 3, - 43 => 3, - 45 => 1, - 46 => 2, - 79 => 1, - 82 => 1, - 93 => 1, - 105 => 1, - 107 => 1, - 108 => 2, - 114 => 1, - 115 => 1, - 119 => 1, - 125 => 2, - 130 => 2, - 131 => 1, - 132 => 2, - 133 => 2, - 134 => 1, - 154 => 2, - 155 => 1, - 162 => 2, - 170 => 1, - ]; + switch ($testFile) { + case 'FunctionCallArgumentSpacingUnitTest.1.inc': + return [ + 5 => 1, + 6 => 1, + 7 => 2, + 8 => 1, + 11 => 1, + 12 => 1, + 13 => 1, + 42 => 3, + 43 => 3, + 45 => 1, + 46 => 2, + 79 => 1, + 82 => 1, + 93 => 1, + 105 => 1, + 107 => 1, + 108 => 2, + 114 => 1, + 115 => 1, + 119 => 1, + 125 => 2, + 130 => 2, + 131 => 1, + 132 => 2, + 133 => 2, + 134 => 1, + 154 => 2, + 155 => 1, + 162 => 2, + 170 => 1, + ]; + + default: + return []; + }//end switch }//end getErrorList() From e9b977750363d614f1a8583842aeda9d70a5cdae Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 16 May 2024 15:50:46 -0300 Subject: [PATCH 2/2] Generic/FunctionCallArgumentSpacing: improve code coverage --- .../Functions/FunctionCallArgumentSpacingUnitTest.1.inc | 5 +++++ .../FunctionCallArgumentSpacingUnitTest.1.inc.fixed | 5 +++++ .../Functions/FunctionCallArgumentSpacingUnitTest.2.inc | 7 +++++++ .../Functions/FunctionCallArgumentSpacingUnitTest.php | 1 + 4 files changed, 18 insertions(+) create mode 100644 src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.2.inc diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc index 8bd067b3f9..29ef802d55 100644 --- a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc +++ b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc @@ -172,3 +172,8 @@ $foo = new MyClass( $obj, 'getMethod', ); + +#[AttributeName(1, 2)] +#[AttributeName(1,2)] + +$callable = myCallable(...); diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc.fixed index 69676524dc..3f0cb0fca6 100644 --- a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc.fixed @@ -172,3 +172,8 @@ $foo = new MyClass( $obj, 'getMethod', ); + +#[AttributeName(1, 2)] +#[AttributeName(1, 2)] + +$callable = myCallable(...); diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.2.inc b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.2.inc new file mode 100644 index 0000000000..f0ff633eed --- /dev/null +++ b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.2.inc @@ -0,0 +1,7 @@ + 1, 162 => 2, 170 => 1, + 177 => 1, ]; default: