Skip to content

Commit

Permalink
Merge pull request #497 from rodrigoprimo/test-coverage-function-call…
Browse files Browse the repository at this point in the history
…-argument-spacing

Generic/FunctionCallArgumentSpacing: improve code coverage
  • Loading branch information
jrfnl authored May 23, 2024
2 parents 870843b + e9b9777 commit 0c6c929
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,8 @@ $foo = new MyClass(
$obj,
'getMethod',
);

#[AttributeName(1, 2)]
#[AttributeName(1,2)]

$callable = myCallable(...);
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,8 @@ $foo = new MyClass(
$obj,
'getMethod',
);

#[AttributeName(1, 2)]
#[AttributeName(1, 2)]

$callable = myCallable(...);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// Intentional parse error (missing closing parenthesis).
// This should be the only test in this file.
// Testing that the sniff is *not* triggered.

myFunction(
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,51 @@ 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<int, int>
*/
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,
177 => 1,
];

default:
return [];
}//end switch

}//end getErrorList()

Expand Down

0 comments on commit 0c6c929

Please sign in to comment.