Skip to content

Commit 6e0df17

Browse files
committed
Fixed bug #3273 : Squiz.Functions.FunctionDeclarationArgumentSpacing reports line break as 0 spaces between parenthesis
1 parent 6825333 commit 6e0df17

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
139139
- Fixed bug #3219 : Generic.Formatting.MultipleStatementAlignment false positive for empty anonymous classes and closures
140140
- Fixed bug #3258 : Squiz.Formatting.OperatorBracket duplicate error messages for unary minus
141141
-- Thanks to Juliette Reinders Folmer for the patch
142+
- Fixed bug #3273 : Squiz.Functions.FunctionDeclarationArgumentSpacing reports line break as 0 spaces between parenthesis
142143
</notes>
143144
<contents>
144145
<dir name="/">

src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,14 @@ public function processBracket($phpcsFile, $openBracket)
120120
$next = $phpcsFile->findNext(T_WHITESPACE, ($openBracket + 1), $closeBracket, true);
121121
if ($next === false) {
122122
if (($closeBracket - $openBracket) !== 1) {
123+
if ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']) {
124+
$found = 'newline';
125+
} else {
126+
$found = $tokens[($openBracket + 1)]['length'];
127+
}
128+
123129
$error = 'Expected 0 spaces between parenthesis of function declaration; %s found';
124-
$data = [$tokens[($openBracket + 1)]['length']];
130+
$data = [$found];
125131
$fix = $phpcsFile->addFixableError($error, $openBracket, 'SpacingBetween', $data);
126132
if ($fix === true) {
127133
$phpcsFile->fixer->replaceToken(($openBracket + 1), '');
@@ -131,7 +137,7 @@ public function processBracket($phpcsFile, $openBracket)
131137
// No params, so we don't check normal spacing rules.
132138
return;
133139
}
134-
}
140+
}//end if
135141

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

0 commit comments

Comments
 (0)