diff --git a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php index 53a512a8d4..601ed46106 100644 --- a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php @@ -24,13 +24,16 @@ class FunctionCallArgumentSpacingSniff implements Sniff */ public function register() { - $tokens = Tokens::$functionNameTokens; - - $tokens[] = T_VARIABLE; - $tokens[] = T_CLOSE_CURLY_BRACKET; - $tokens[] = T_CLOSE_PARENTHESIS; - - return $tokens; + return[ + T_STRING, + T_ISSET, + T_UNSET, + T_SELF, + T_STATIC, + T_VARIABLE, + T_CLOSE_CURLY_BRACKET, + T_CLOSE_PARENTHESIS, + ]; }//end register() @@ -86,11 +89,14 @@ public function process(File $phpcsFile, $stackPtr) T_COMMA, T_VARIABLE, T_CLOSURE, + T_ANON_CLASS, T_OPEN_SHORT_ARRAY, ]; while (($nextSeparator = $phpcsFile->findNext($find, ($nextSeparator + 1), $closeBracket)) !== false) { - if ($tokens[$nextSeparator]['code'] === T_CLOSURE) { + if ($tokens[$nextSeparator]['code'] === T_CLOSURE + || $tokens[$nextSeparator]['code'] === T_ANON_CLASS + ) { // Skip closures. $nextSeparator = $tokens[$nextSeparator]['scope_closer']; continue; diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc index 8a24fa23ff..2747553cdb 100644 --- a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc +++ b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc @@ -133,3 +133,19 @@ my_function_call( ,'e' // phpcs:ignore Standard.Category.Sniff -- for reasons. , 'f' ); + +$foobar = php73_function_call_trailing_comma( + $foo, + $bar, +); + +$foobar = functionCallAnonClassParam( + new class() { + public $foo=1; + public function methodName($param='foo',$paramTwo='bar') { + $bar=false; + $foo = array(1,2,3); + } + }, + $args=array(), +); diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc.fixed b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc.fixed index 4e1fae5317..b8bb8faef4 100644 --- a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc.fixed @@ -133,3 +133,19 @@ my_function_call( 'e', // phpcs:ignore Standard.Category.Sniff -- for reasons. 'f' ); + +$foobar = php73_function_call_trailing_comma( + $foo, + $bar, +); + +$foobar = functionCallAnonClassParam( + new class() { + public $foo=1; + public function methodName($param='foo',$paramTwo='bar') { + $bar=false; + $foo = array(1,2,3); + } + }, + $args = array(), +); diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php index c7c5e8d002..2a9781d04c 100644 --- a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php @@ -52,6 +52,7 @@ public function getErrorList() 132 => 2, 133 => 2, 134 => 1, + 150 => 2, ]; }//end getErrorList()