Skip to content

Commit 2276459

Browse files
committed
Add hasScopeOpener
1 parent f487ae3 commit 2276459

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

VariableAnalysis/Lib/Helpers.php

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

385+
/**
386+
* Compatibility handler for phpcs 3.x/4.x
387+
* @param array $tokens
388+
* @param int $tokenIndex
389+
* @return bool
390+
*/
391+
private static function hasScopeOpener($tokens, $tokenIndex)
392+
{
393+
if (defined('Tokens::SCOPE_OPENERS') && isset(Tokens::SCOPE_OPENERS[$tokens[$tokenIndex]['code']])) {
394+
return true;
395+
}
396+
if (isset(Tokens::$scopeOpeners) && isset(Tokens::$scopeOpeners[$tokens[$tokenIndex]['code']])) {
397+
return true;
398+
}
399+
return false;
400+
}
401+
385402
/**
386403
* Compatibility handler for phpcs 3.x/4.x
387404
* @param array $tokens
@@ -919,7 +936,7 @@ private static function isListAssignment(File $phpcsFile, $listOpenerIndex)
919936
isset($tokens[$previousTokenPtr])
920937
&& $tokens[$previousTokenPtr]['code'] === T_CLOSE_PARENTHESIS
921938
&& isset($tokens[$previousTokenPtr]['parenthesis_owner'])
922-
&& isset(Tokens::$scopeOpeners[$tokens[$tokens[$previousTokenPtr]['parenthesis_owner']]['code']])
939+
&& self::hasScopeOpener($tokens, $tokens[$previousTokenPtr]['parenthesis_owner'])
923940
) {
924941
return true;
925942
}

0 commit comments

Comments
 (0)