Skip to content

Commit 3a20079

Browse files
committed
Add getScopeModifiers
1 parent 2276459 commit 3a20079

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+
private static function getScopeModifiers()
390+
{
391+
if (defined('Tokens::SCOPE_MODIFIERS')) {
392+
return Tokens::SCOPE_MODIFIERS;
393+
}
394+
if (isset(Tokens::$scopeModifiers)) {
395+
return Tokens::$scopeModifiers;
396+
}
397+
return [];
398+
}
399+
385400
/**
386401
* Compatibility handler for phpcs 3.x/4.x
387402
* @param array $tokens
@@ -1675,7 +1690,7 @@ public static function isConstructorPromotion(File $phpcsFile, $stackPtr)
16751690
// 'readonly' keyword, and return true if the previous token is a
16761691
// visibility keyword (eg: `public`).
16771692
for ($i = $stackPtr - 1; $i > $functionIndex; $i--) {
1678-
if (in_array($tokens[$i]['code'], Tokens::$scopeModifiers, true)) {
1693+
if (in_array($tokens[$i]['code'], self::getScopeModifiers(), true)) {
16791694
return true;
16801695
}
16811696
if (in_array($tokens[$i]['code'], Tokens::$emptyTokens, true)) {

0 commit comments

Comments
 (0)