Skip to content

Commit 497c411

Browse files
committed
Simplify AbstractFunctionParameterSniff::is_targetted_token() by only checking if the token after the function name is not an open parenthesis
1 parent c3fbb13 commit 497c411

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

WordPress/AbstractFunctionParameterSniff.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public function process_matched_token( $stackPtr, $group_name, $matched_content
8080

8181
/**
8282
* Verify if the current token is a function call. Behaves like the parent method, except that
83-
* it also returns false if the function name is used in the context of a first class callable
84-
* or an import.
83+
* it returns false if there is no opening parenthesis after the function name (likely a
84+
* function import) or if it is a first class callable.
8585
*
8686
* @param int $stackPtr The position of the current token in the stack.
8787
*
@@ -92,16 +92,10 @@ public function is_targetted_token( $stackPtr ) {
9292
return false;
9393
}
9494

95-
$ignore = Tokens::$emptyTokens;
96-
$ignore[ \T_BITWISE_AND ] = \T_BITWISE_AND;
97-
$prev = $this->phpcsFile->findPrevious( $ignore, ( $stackPtr - 1 ), null, true );
98-
$next = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
95+
$next = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
9996

100-
// Function import.
101-
if ( \T_STRING === $this->tokens[ $prev ]['code']
102-
&& 'function' === $this->tokens[ $prev ]['content']
103-
&& in_array( $this->tokens[ $next ]['code'], array( \T_AS, \T_SEMICOLON ), true )
104-
) {
97+
// Not a function call (likely a function import).
98+
if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $next ]['code'] ) {
10599
return false;
106100
}
107101

0 commit comments

Comments
 (0)