Skip to content

Commit

Permalink
Fixed bug #3273 : Squiz.Functions.FunctionDeclarationArgumentSpacing …
Browse files Browse the repository at this point in the history
…reports line break as 0 spaces between parenthesis
  • Loading branch information
gsherwood committed Mar 16, 2021
1 parent 6825333 commit 6e0df17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Fixed bug #3219 : Generic.Formatting.MultipleStatementAlignment false positive for empty anonymous classes and closures
- Fixed bug #3258 : Squiz.Formatting.OperatorBracket duplicate error messages for unary minus
-- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3273 : Squiz.Functions.FunctionDeclarationArgumentSpacing reports line break as 0 spaces between parenthesis
</notes>
<contents>
<dir name="/">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ public function processBracket($phpcsFile, $openBracket)
$next = $phpcsFile->findNext(T_WHITESPACE, ($openBracket + 1), $closeBracket, true);
if ($next === false) {
if (($closeBracket - $openBracket) !== 1) {
if ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']) {
$found = 'newline';
} else {
$found = $tokens[($openBracket + 1)]['length'];
}

$error = 'Expected 0 spaces between parenthesis of function declaration; %s found';
$data = [$tokens[($openBracket + 1)]['length']];
$data = [$found];
$fix = $phpcsFile->addFixableError($error, $openBracket, 'SpacingBetween', $data);
if ($fix === true) {
$phpcsFile->fixer->replaceToken(($openBracket + 1), '');
Expand All @@ -131,7 +137,7 @@ public function processBracket($phpcsFile, $openBracket)
// No params, so we don't check normal spacing rules.
return;
}
}
}//end if

foreach ($params as $paramNumber => $param) {
if ($param['pass_by_reference'] === true) {
Expand Down

0 comments on commit 6e0df17

Please sign in to comment.