Skip to content

Commit 438a636

Browse files
committed
Add getFunctionNameTokens
1 parent b241dcf commit 438a636

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

VariableAnalysis/Lib/Helpers.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,21 @@ public static function findFunctionCallArguments(File $phpcsFile, $stackPtr)
382382
return $argPtrs;
383383
}
384384

385+
/**
386+
* Compatibility handler for phpcs 3.x/4.x
387+
* @return array
388+
*/
389+
public static function getFunctionNameTokens()
390+
{
391+
if (defined('Tokens::FUNCTION_NAME_TOKENS')) {
392+
return Tokens::FUNCTION_NAME_TOKENS;
393+
}
394+
if (isset(Tokens::$functionNameTokens)) {
395+
return Tokens::$functionNameTokens;
396+
}
397+
return [];
398+
}
399+
385400
/**
386401
* Compatibility handler for phpcs 3.x/4.x
387402
* @return array
@@ -1382,7 +1397,7 @@ public static function getFunctionIndexForFunctionCallArgument(File $phpcsFile,
13821397
}
13831398

13841399
$functionNameType = $tokens[$functionPtr]['code'];
1385-
if (! in_array($functionNameType, Tokens::$functionNameTokens, true)) {
1400+
if (! in_array($functionNameType, self::getFunctionNameTokens(), true)) {
13861401
// If the alleged function name is not a variable or a string, this is
13871402
// not a function call.
13881403
return null;

0 commit comments

Comments
 (0)