Skip to content

Generic/FunctionCallArgumentSpacing: improve code coverage #497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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