Skip to content

Commit 6c54889

Browse files
committed
Add getOoScopeTokens
1 parent 438a636 commit 6c54889

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 getOoScopeTokens()
390+
{
391+
if (defined('Tokens::OO_SCOPE_TOKENS')) {
392+
return Tokens::OO_SCOPE_TOKENS;
393+
}
394+
if (isset(Tokens::$ooScopeTokens)) {
395+
return Tokens::$ooScopeTokens;
396+
}
397+
return [];
398+
}
399+
385400
/**
386401
* Compatibility handler for phpcs 3.x/4.x
387402
* @return array
@@ -680,7 +695,7 @@ private static function getStartOfTokenScope(File $phpcsFile, $stackPtr)
680695
if (in_array($scopeCode, $functionTokenTypes, true) || self::isArrowFunction($phpcsFile, $scopePtr)) {
681696
return $scopePtr;
682697
}
683-
if (isset(Tokens::$ooScopeTokens[$scopeCode]) === true) {
698+
if (isset(self::getOoScopeTokens()[$scopeCode]) === true) {
684699
$inClass = true;
685700
}
686701
}

0 commit comments

Comments
 (0)