Skip to content

Commit 2845af7

Browse files
committed
Further fix for bug #310 (also fixes #332)
1 parent 0e42098 commit 2845af7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,15 @@ public function processBracket(PHP_CodeSniffer_File $phpcsFile, $openBracket)
170170

171171
// Take references into account when expecting the
172172
// location of whitespace.
173-
if ($phpcsFile->isReference(($nextParam - 1)) === true
174-
|| $tokens[($nextParam - 1)]['code'] === T_ELLIPSIS
175-
) {
176-
$whitespace = ($nextParam - 2);
173+
$checkToken = ($nextParam - 1);
174+
if ($tokens[$checkToken]['code'] === T_ELLIPSIS) {
175+
$checkToken--;
176+
}
177+
178+
if ($phpcsFile->isReference($checkToken) === true) {
179+
$whitespace = ($checkToken - 1);
177180
} else {
178-
$whitespace = ($nextParam - 1);
181+
$whitespace = $checkToken;
179182
}
180183

181184
if (empty($params) === false) {

CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ function myFunc( ) {}
5959
// @codingStandardsChangeSetting Squiz.Functions.FunctionDeclarationArgumentSpacing requiredSpacesBeforeClose 0
6060

6161
function myFunc($req, $opt=null, ...$params) {}
62+
function myFunc($param, &...$moreParams) {}

0 commit comments

Comments
 (0)