Skip to content

Commit e96bbea

Browse files
committed
Merge branch 'feature/pear-functioncallsignature-bugfix' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents f77bddb + 5777573 commit e96bbea

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $
546546
// If we are within an argument we should be ignoring commas
547547
// as these are not signaling the end of an argument.
548548
if ($inArg === false && $tokens[$i]['code'] === T_COMMA) {
549-
$next = $phpcsFile->findNext([T_WHITESPACE, T_COMMENT], ($i + 1), $closeBracket, true);
549+
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), $closeBracket, true);
550550
if ($next === false) {
551551
continue;
552552
}

src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,29 @@ $deprecated_functions = [
390390

391391
$deprecated_functions = [
392392
'the_category_ID'
393-
=> function_call( // 7 spaces, not 8. This is the problem line.
393+
=> function_call( // 9 spaces, not 8. This is the problem line.
394394
$a,
395395
$b
396396
),
397397
];
398+
399+
// phpcs:set PEAR.Functions.FunctionCallSignature allowMultipleArguments false
400+
401+
printf(
402+
'<select name="%1$s" id="%2$s">%3$s</select>',
403+
$obj->getName(), // Trailing comment.
404+
$obj->getID(), // phpcs:ignore Standard.Category.SniffName -- for reasons.
405+
$option
406+
);
407+
408+
// Handling of PHP 7.3 trailing comma's.
409+
functionCall($args, $foo,);
410+
functionCall(
411+
$args, $foo,
412+
);
413+
functionCall(
414+
$args,
415+
$foo,
416+
);
417+
418+
// phpcs:set PEAR.Functions.FunctionCallSignature allowMultipleArguments true

src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,30 @@ $deprecated_functions = [
403403

404404
$deprecated_functions = [
405405
'the_category_ID'
406-
=> function_call( // 7 spaces, not 8. This is the problem line.
406+
=> function_call( // 9 spaces, not 8. This is the problem line.
407407
$a,
408408
$b
409409
),
410410
];
411+
412+
// phpcs:set PEAR.Functions.FunctionCallSignature allowMultipleArguments false
413+
414+
printf(
415+
'<select name="%1$s" id="%2$s">%3$s</select>',
416+
$obj->getName(), // Trailing comment.
417+
$obj->getID(), // phpcs:ignore Standard.Category.SniffName -- for reasons.
418+
$option
419+
);
420+
421+
// Handling of PHP 7.3 trailing comma's.
422+
functionCall($args, $foo,);
423+
functionCall(
424+
$args,
425+
$foo,
426+
);
427+
functionCall(
428+
$args,
429+
$foo,
430+
);
431+
432+
// phpcs:set PEAR.Functions.FunctionCallSignature allowMultipleArguments true

src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public function getErrorList($testFile='FunctionCallSignatureUnitTest.inc')
111111
394 => 1,
112112
395 => 1,
113113
396 => 1,
114+
411 => 1,
114115
];
115116

116117
}//end getErrorList()

0 commit comments

Comments
 (0)