Skip to content

Commit b241dcf

Browse files
committed
Add getEmptyTokens
1 parent 3a20079 commit b241dcf

File tree

2 files changed

+57
-40
lines changed

2 files changed

+57
-40
lines changed

VariableAnalysis/Lib/Helpers.php

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Helpers
1919
public static function getPossibleEndOfFileTokens()
2020
{
2121
return array_merge(
22-
array_values(Tokens::$emptyTokens),
22+
array_values(self::getEmptyTokens()),
2323
[
2424
T_INLINE_HTML,
2525
T_CLOSE_TAG,
@@ -242,7 +242,7 @@ public static function getFunctionIndexForFunctionParameter(File $phpcsFile, $st
242242
return null;
243243
}
244244

245-
$nonFunctionTokenTypes = Tokens::$emptyTokens;
245+
$nonFunctionTokenTypes = self::getEmptyTokens();
246246
$nonFunctionTokenTypes[] = T_STRING;
247247
$nonFunctionTokenTypes[] = T_BITWISE_AND;
248248
$functionPtr = self::getIntOrNull($phpcsFile->findPrevious($nonFunctionTokenTypes, $startOfArguments - 1, null, true, null, true));
@@ -284,7 +284,7 @@ public static function getUseIndexForUseImport(File $phpcsFile, $stackPtr)
284284
{
285285
$tokens = $phpcsFile->getTokens();
286286

287-
$nonUseTokenTypes = Tokens::$emptyTokens;
287+
$nonUseTokenTypes = self::getEmptyTokens();
288288
$nonUseTokenTypes[] = T_VARIABLE;
289289
$nonUseTokenTypes[] = T_ELLIPSIS;
290290
$nonUseTokenTypes[] = T_COMMA;
@@ -318,7 +318,7 @@ public static function findFunctionCall(File $phpcsFile, $stackPtr)
318318
$openPtr = self::findContainingOpeningBracket($phpcsFile, $stackPtr);
319319
if (is_int($openPtr)) {
320320
// First non-whitespace thing and see if it's a T_STRING function name
321-
$functionPtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $openPtr - 1, null, true, null, true);
321+
$functionPtr = $phpcsFile->findPrevious(self::getEmptyTokens(), $openPtr - 1, null, true, null, true);
322322
if (is_int($functionPtr) && $tokens[$functionPtr]['code'] === T_STRING) {
323323
return $functionPtr;
324324
}
@@ -346,7 +346,7 @@ public static function findFunctionCallArguments(File $phpcsFile, $stackPtr)
346346
}
347347

348348
// $stackPtr is the function name, find our brackets after it
349-
$openPtr = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
349+
$openPtr = $phpcsFile->findNext(self::getEmptyTokens(), $stackPtr + 1, null, true, null, true);
350350
if (($openPtr === false) || ($tokens[$openPtr]['code'] !== T_OPEN_PARENTHESIS)) {
351351
return [];
352352
}
@@ -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 getEmptyTokens()
390+
{
391+
if (defined('Tokens::EMPTY_TOKENS')) {
392+
return Tokens::EMPTY_TOKENS;
393+
}
394+
if (isset(Tokens::$emptyTokens)) {
395+
return Tokens::$emptyTokens;
396+
}
397+
return [];
398+
}
399+
385400
/**
386401
* Compatibility handler for phpcs 3.x/4.x
387402
* @return array
@@ -442,7 +457,7 @@ public static function getNextAssignPointer(File $phpcsFile, $stackPtr)
442457
$tokens = $phpcsFile->getTokens();
443458

444459
// Is the next non-whitespace an assignment?
445-
$nextPtr = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
460+
$nextPtr = $phpcsFile->findNext(self::getEmptyTokens(), $stackPtr + 1, null, true, null, true);
446461
if (is_int($nextPtr)
447462
&& self::hasAssignmentToken($tokens, $nextPtr)
448463
// Ignore double arrow to prevent triggering on `foreach ( $array as $k => $v )`.
@@ -515,7 +530,8 @@ public static function getVariablesInsideCompact(File $phpcsFile, $stackPtr, $ar
515530

516531
foreach ($arguments as $argumentPtrs) {
517532
$argumentPtrs = array_values(array_filter($argumentPtrs, function ($argumentPtr) use ($tokens) {
518-
return isset(Tokens::$emptyTokens[$tokens[$argumentPtr]['code']]) === false;
533+
$emptyTokens = self::getEmptyTokens();
534+
return isset($emptyTokens[$tokens[$argumentPtr]['code']]) === false;
519535
}));
520536
if (empty($argumentPtrs)) {
521537
continue;
@@ -762,14 +778,14 @@ public static function isArrowFunction(File $phpcsFile, $stackPtr)
762778
return false;
763779
}
764780
// Make sure next non-space token is an open parenthesis
765-
$openParenIndex = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true);
781+
$openParenIndex = $phpcsFile->findNext(self::getEmptyTokens(), $stackPtr + 1, null, true);
766782
if (! is_int($openParenIndex) || $tokens[$openParenIndex]['code'] !== T_OPEN_PARENTHESIS) {
767783
return false;
768784
}
769785
// Find the associated close parenthesis
770786
$closeParenIndex = $tokens[$openParenIndex]['parenthesis_closer'];
771787
// Make sure the next token is a fat arrow
772-
$fatArrowIndex = $phpcsFile->findNext(Tokens::$emptyTokens, $closeParenIndex + 1, null, true);
788+
$fatArrowIndex = $phpcsFile->findNext(self::getEmptyTokens(), $closeParenIndex + 1, null, true);
773789
if (! is_int($fatArrowIndex)) {
774790
return false;
775791
}
@@ -801,14 +817,14 @@ public static function getArrowFunctionOpenClose(File $phpcsFile, $stackPtr)
801817
return null;
802818
}
803819
// Make sure next non-space token is an open parenthesis
804-
$openParenIndex = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true);
820+
$openParenIndex = $phpcsFile->findNext(self::getEmptyTokens(), $stackPtr + 1, null, true);
805821
if (! is_int($openParenIndex) || $tokens[$openParenIndex]['code'] !== T_OPEN_PARENTHESIS) {
806822
return null;
807823
}
808824
// Find the associated close parenthesis
809825
$closeParenIndex = $tokens[$openParenIndex]['parenthesis_closer'];
810826
// Make sure the next token is a fat arrow or a return type
811-
$fatArrowIndex = $phpcsFile->findNext(Tokens::$emptyTokens, $closeParenIndex + 1, null, true);
827+
$fatArrowIndex = $phpcsFile->findNext(self::getEmptyTokens(), $closeParenIndex + 1, null, true);
812828
if (! is_int($fatArrowIndex)) {
813829
return null;
814830
}
@@ -930,7 +946,7 @@ private static function isListAssignment(File $phpcsFile, $listOpenerIndex)
930946
// If $listOpenerIndex is the open parenthesis of `list($a) = $b;`, then
931947
// match that too.
932948
if ($tokens[$listOpenerIndex]['code'] === T_OPEN_PARENTHESIS) {
933-
$previousTokenPtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $listOpenerIndex - 1, null, true);
949+
$previousTokenPtr = $phpcsFile->findPrevious(self::getEmptyTokens(), $listOpenerIndex - 1, null, true);
934950
if (
935951
isset($tokens[$previousTokenPtr])
936952
&& $tokens[$previousTokenPtr]['code'] === T_LIST
@@ -946,7 +962,7 @@ private static function isListAssignment(File $phpcsFile, $listOpenerIndex)
946962
//
947963
// Match `if (true) [$a] = $b;`
948964
if ($tokens[$listOpenerIndex]['code'] === T_OPEN_SQUARE_BRACKET) {
949-
$previousTokenPtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $listOpenerIndex - 1, null, true);
965+
$previousTokenPtr = $phpcsFile->findPrevious(self::getEmptyTokens(), $listOpenerIndex - 1, null, true);
950966
if (
951967
isset($tokens[$previousTokenPtr])
952968
&& $tokens[$previousTokenPtr]['code'] === T_CLOSE_PARENTHESIS
@@ -991,7 +1007,7 @@ public static function getListAssignments(File $phpcsFile, $listOpenerIndex)
9911007
}
9921008

9931009
// Find the assignment (equals sign) which, if this is a list assignment, should be the next non-space token
994-
$assignPtr = $phpcsFile->findNext(Tokens::$emptyTokens, $closePtr + 1, null, true);
1010+
$assignPtr = $phpcsFile->findNext(self::getEmptyTokens(), $closePtr + 1, null, true);
9951011

9961012
// If the next token isn't an assignment, check for nested brackets because we might be a nested assignment
9971013
if (! is_int($assignPtr) || $tokens[$assignPtr]['code'] !== T_EQUAL) {
@@ -1125,7 +1141,7 @@ public static function isVariableANumericVariable($varName)
11251141
public static function isVariableInsideElseCondition(File $phpcsFile, $stackPtr)
11261142
{
11271143
$tokens = $phpcsFile->getTokens();
1128-
$nonFunctionTokenTypes = Tokens::$emptyTokens;
1144+
$nonFunctionTokenTypes = self::getEmptyTokens();
11291145
$nonFunctionTokenTypes[] = T_OPEN_PARENTHESIS;
11301146
$nonFunctionTokenTypes[] = T_INLINE_HTML;
11311147
$nonFunctionTokenTypes[] = T_CLOSE_TAG;
@@ -1347,7 +1363,7 @@ public static function getFunctionIndexForFunctionCallArgument(File $phpcsFile,
13471363
return null;
13481364
}
13491365

1350-
$nonFunctionTokenTypes = Tokens::$emptyTokens;
1366+
$nonFunctionTokenTypes = self::getEmptyTokens();
13511367
$functionPtr = self::getIntOrNull($phpcsFile->findPrevious($nonFunctionTokenTypes, $startOfArguments - 1, null, true, null, true));
13521368
if (! is_int($functionPtr) || ! isset($tokens[$functionPtr]['code'])) {
13531369
return null;
@@ -1416,7 +1432,7 @@ public static function isVariableInsideIssetOrEmpty(File $phpcsFile, $stackPtr)
14161432
public static function isVariableArrayPushShortcut(File $phpcsFile, $stackPtr)
14171433
{
14181434
$tokens = $phpcsFile->getTokens();
1419-
$nonFunctionTokenTypes = Tokens::$emptyTokens;
1435+
$nonFunctionTokenTypes = self::getEmptyTokens();
14201436

14211437
$arrayPushOperatorIndex1 = self::getIntOrNull($phpcsFile->findNext($nonFunctionTokenTypes, $stackPtr + 1, null, true, null, true));
14221438
if (! is_int($arrayPushOperatorIndex1)) {
@@ -1518,7 +1534,7 @@ public static function isTokenVariableVariable(File $phpcsFile, $stackPtr)
15181534
{
15191535
$tokens = $phpcsFile->getTokens();
15201536

1521-
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
1537+
$prev = $phpcsFile->findPrevious(self::getEmptyTokens(), ($stackPtr - 1), null, true);
15221538
if ($prev === false) {
15231539
return false;
15241540
}
@@ -1529,7 +1545,7 @@ public static function isTokenVariableVariable(File $phpcsFile, $stackPtr)
15291545
return false;
15301546
}
15311547

1532-
$prevPrev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prev - 1), null, true);
1548+
$prevPrev = $phpcsFile->findPrevious(self::getEmptyTokens(), ($prev - 1), null, true);
15331549
if ($prevPrev !== false && $tokens[$prevPrev]['code'] === T_DOLLAR) {
15341550
return true;
15351551
}
@@ -1693,7 +1709,7 @@ public static function isConstructorPromotion(File $phpcsFile, $stackPtr)
16931709
if (in_array($tokens[$i]['code'], self::getScopeModifiers(), true)) {
16941710
return true;
16951711
}
1696-
if (in_array($tokens[$i]['code'], Tokens::$emptyTokens, true)) {
1712+
if (in_array($tokens[$i]['code'], self::getEmptyTokens(), true)) {
16971713
continue;
16981714
}
16991715
if ($tokens[$i]['content'] === 'readonly') {
@@ -1775,7 +1791,7 @@ private static function isTokenPossiblyPartOfTypehint(File $phpcsFile, $stackPtr
17751791
if ($token['content'] === '|') {
17761792
return true;
17771793
}
1778-
if (in_array($token['code'], Tokens::$emptyTokens)) {
1794+
if (in_array($token['code'], self::getEmptyTokens())) {
17791795
return true;
17801796
}
17811797
return false;
@@ -1847,7 +1863,7 @@ public static function isFunctionBodyEmpty(File $phpcsFile, $stackPtr)
18471863
$functionScopeStart = $tokens[$stackPtr]['scope_opener'];
18481864
$functionScopeEnd = $tokens[$stackPtr]['scope_closer'];
18491865
$tokensToIgnore = array_merge(
1850-
Tokens::$emptyTokens,
1866+
self::getEmptyTokens(),
18511867
[
18521868
T_RETURN,
18531869
T_SEMICOLON,

VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ protected function isGetDefinedVars(File $phpcsFile, $stackPtr)
409409
return false;
410410
}
411411
// Make sure this is a function call
412-
$parenPointer = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
412+
$parenPointer = $phpcsFile->findNext(Helpers::getEmptyTokens(), ($stackPtr + 1), null, true);
413413
if (! $parenPointer || $tokens[$parenPointer]['code'] !== T_OPEN_PARENTHESIS) {
414414
return false;
415415
}
@@ -800,7 +800,7 @@ protected function processVariableAsFunctionParameter(File $phpcsFile, $stackPtr
800800
$this->markVariableDeclaration($varName, ScopeType::PARAM, null, $stackPtr, $functionPtr);
801801

802802
// Are we pass-by-reference?
803-
$referencePtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $stackPtr - 1, null, true, null, true);
803+
$referencePtr = $phpcsFile->findPrevious(Helpers::getEmptyTokens(), $stackPtr - 1, null, true, null, true);
804804
if (($referencePtr !== false) && ($tokens[$referencePtr]['code'] === T_BITWISE_AND)) {
805805
Helpers::debug('processVariableAsFunctionParameter found pass-by-reference to scope', $outerScope);
806806
$varInfo = $this->getOrCreateVariableInfo($varName, $functionPtr);
@@ -860,7 +860,7 @@ protected function processVariableAsUseImportDefinition(File $phpcsFile, $stackP
860860

861861
// Are we pass-by-reference? If so, then any assignment to the variable in
862862
// the function scope also should count for the enclosing scope.
863-
$referencePtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $stackPtr - 1, null, true, null, true);
863+
$referencePtr = $phpcsFile->findPrevious(Helpers::getEmptyTokens(), $stackPtr - 1, null, true, null, true);
864864
if (is_int($referencePtr) && $tokens[$referencePtr]['code'] === T_BITWISE_AND) {
865865
Helpers::debug("variable '{$varName}' in function definition looks passed by reference");
866866
$varInfo = $this->getOrCreateVariableInfo($varName, $functionPtr);
@@ -918,7 +918,7 @@ protected function processVariableAsCatchBlock(File $phpcsFile, $stackPtr, $varN
918918
return false;
919919
}
920920

921-
$catchPtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $openPtr - 1, null, true, null, true);
921+
$catchPtr = $phpcsFile->findPrevious(Helpers::getEmptyTokens(), $openPtr - 1, null, true, null, true);
922922
if (($catchPtr !== false) && ($tokens[$catchPtr]['code'] === T_CATCH)) {
923923
// Scope of the exception var is actually the function, not just the catch block.
924924
$this->markVariableDeclaration($varName, ScopeType::LOCAL, null, $stackPtr, $currScope, true);
@@ -1045,11 +1045,11 @@ protected function processVariableAsStaticMember(File $phpcsFile, $stackPtr)
10451045
{
10461046
$tokens = $phpcsFile->getTokens();
10471047

1048-
$doubleColonPtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $stackPtr - 1, null, true);
1048+
$doubleColonPtr = $phpcsFile->findPrevious(Helpers::getEmptyTokens(), $stackPtr - 1, null, true);
10491049
if ($doubleColonPtr === false || $tokens[$doubleColonPtr]['code'] !== T_DOUBLE_COLON) {
10501050
return false;
10511051
}
1052-
$classNamePtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $doubleColonPtr - 1, null, true);
1052+
$classNamePtr = $phpcsFile->findPrevious(Helpers::getEmptyTokens(), $doubleColonPtr - 1, null, true);
10531053
$staticReferences = [
10541054
T_STRING,
10551055
T_SELF,
@@ -1062,7 +1062,7 @@ protected function processVariableAsStaticMember(File $phpcsFile, $stackPtr)
10621062
}
10631063
// "When calling static methods, the function call is stronger than the
10641064
// static property operator" so look for a function call.
1065-
$parenPointer = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
1065+
$parenPointer = $phpcsFile->findNext(Helpers::getEmptyTokens(), ($stackPtr + 1), null, true);
10661066
if ($parenPointer !== false && $tokens[$parenPointer]['code'] === T_OPEN_PARENTHESIS) {
10671067
return false;
10681068
}
@@ -1085,11 +1085,11 @@ protected function processVariableAsStaticOutsideClass(File $phpcsFile, $stackPt
10851085
/** @var array{conditions?: (int|string)[], content?: string}|null */
10861086
$token = $tokens[$stackPtr];
10871087

1088-
$doubleColonPtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $stackPtr - 1, null, true);
1088+
$doubleColonPtr = $phpcsFile->findPrevious(Helpers::getEmptyTokens(), $stackPtr - 1, null, true);
10891089
if ($doubleColonPtr === false || $tokens[$doubleColonPtr]['code'] !== T_DOUBLE_COLON) {
10901090
return false;
10911091
}
1092-
$classNamePtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $doubleColonPtr - 1, null, true);
1092+
$classNamePtr = $phpcsFile->findPrevious(Helpers::getEmptyTokens(), $doubleColonPtr - 1, null, true);
10931093
if ($classNamePtr === false) {
10941094
return false;
10951095
}
@@ -1147,7 +1147,7 @@ protected function processVariableAsAssignment(File $phpcsFile, $stackPtr, $varN
11471147
// referenced variable and therefore should count as both an assignment and
11481148
// a read.
11491149
$tokens = $phpcsFile->getTokens();
1150-
$referencePtr = $phpcsFile->findNext(Tokens::$emptyTokens, $assignPtr + 1, null, true, null, true);
1150+
$referencePtr = $phpcsFile->findNext(Helpers::getEmptyTokens(), $assignPtr + 1, null, true, null, true);
11511151
if (is_int($referencePtr) && $tokens[$referencePtr]['code'] === T_BITWISE_AND) {
11521152
Helpers::debug("processVariableAsAssignment: found reference variable for '{$varName}'");
11531153
$varInfo = $this->getOrCreateVariableInfo($varName, $currScope);
@@ -1271,7 +1271,7 @@ protected function processVariableAsListAssignment(File $phpcsFile, $stackPtr, $
12711271
return false;
12721272
}
12731273

1274-
$prevPtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $openPtr - 1, null, true, null, true);
1274+
$prevPtr = $phpcsFile->findPrevious(Helpers::getEmptyTokens(), $openPtr - 1, null, true, null, true);
12751275
if ((is_bool($prevPtr)) || ($tokens[$prevPtr]['code'] !== T_LIST)) {
12761276
return false;
12771277
}
@@ -1315,7 +1315,7 @@ protected function processVariableAsGlobalDeclaration(File $phpcsFile, $stackPtr
13151315

13161316
// Are we a global declaration?
13171317
// Search backwards for first token that isn't whitespace/comment, comma or variable.
1318-
$ignore = Tokens::$emptyTokens;
1318+
$ignore = Helpers::getEmptyTokens();
13191319
$ignore[T_VARIABLE] = T_VARIABLE;
13201320
$ignore[T_COMMA] = T_COMMA;
13211321

@@ -1388,7 +1388,7 @@ protected function processVariableAsStaticDeclaration(File $phpcsFile, $stackPtr
13881388

13891389
// Is the 'static' keyword an anonymous static function declaration? If so,
13901390
// this is not a static variable declaration.
1391-
$tokenAfterStatic = $phpcsFile->findNext(Tokens::$emptyTokens, $staticPtr + 1, null, true, null, true);
1391+
$tokenAfterStatic = $phpcsFile->findNext(Helpers::getEmptyTokens(), $staticPtr + 1, null, true, null, true);
13921392
$functionTokenTypes = [
13931393
T_FUNCTION,
13941394
T_CLOSURE,
@@ -1443,7 +1443,7 @@ protected function processVariableAsForeachLoopVar(File $phpcsFile, $stackPtr, $
14431443
if (! is_int($openParenPtr)) {
14441444
return false;
14451445
}
1446-
$foreachPtr = Helpers::getIntOrNull($phpcsFile->findPrevious(Tokens::$emptyTokens, $openParenPtr - 1, null, true));
1446+
$foreachPtr = Helpers::getIntOrNull($phpcsFile->findPrevious(Helpers::getEmptyTokens(), $openParenPtr - 1, null, true));
14471447
if (! is_int($foreachPtr)) {
14481448
return false;
14491449
}
@@ -1452,7 +1452,7 @@ protected function processVariableAsForeachLoopVar(File $phpcsFile, $stackPtr, $
14521452
if (! is_int($openParenPtr)) {
14531453
return false;
14541454
}
1455-
$foreachPtr = Helpers::getIntOrNull($phpcsFile->findPrevious(Tokens::$emptyTokens, $openParenPtr - 1, null, true));
1455+
$foreachPtr = Helpers::getIntOrNull($phpcsFile->findPrevious(Helpers::getEmptyTokens(), $openParenPtr - 1, null, true));
14561456
if (! is_int($foreachPtr)) {
14571457
return false;
14581458
}
@@ -1474,7 +1474,7 @@ protected function processVariableAsForeachLoopVar(File $phpcsFile, $stackPtr, $
14741474
}
14751475

14761476
// Are we pass-by-reference?
1477-
$referencePtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $stackPtr - 1, null, true, null, true);
1477+
$referencePtr = $phpcsFile->findPrevious(Helpers::getEmptyTokens(), $stackPtr - 1, null, true, null, true);
14781478
if (($referencePtr !== false) && ($tokens[$referencePtr]['code'] === T_BITWISE_AND)) {
14791479
Helpers::debug('processVariableAsForeachLoopVar: found foreach loop variable assigned by reference');
14801480
$varInfo->isDynamicReference = true;
@@ -1547,7 +1547,8 @@ protected function processVariableAsPassByReferenceFunctionCall(File $phpcsFile,
15471547
if ($ptr === $stackPtr) {
15481548
continue;
15491549
}
1550-
if (isset(Tokens::$emptyTokens[$tokens[$ptr]['code']]) === false) {
1550+
$emptyTokens = Helpers::getEmptyTokens();
1551+
if (isset($emptyTokens[$tokens[$ptr]['code']]) === false) {
15511552
return false;
15521553
}
15531554
}
@@ -1573,7 +1574,7 @@ protected function processVariableAsSymbolicObjectProperty(File $phpcsFile, $sta
15731574

15741575
// Are we a symbolic object property/function derefeference?
15751576
// Search backwards for first token that isn't whitespace, is it a "->" operator?
1576-
$objectOperatorPtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $stackPtr - 1, null, true, null, true);
1577+
$objectOperatorPtr = $phpcsFile->findPrevious(Helpers::getEmptyTokens(), $stackPtr - 1, null, true, null, true);
15771578
if (($objectOperatorPtr === false) || ($tokens[$objectOperatorPtr]['code'] !== T_OBJECT_OPERATOR)) {
15781579
return false;
15791580
}

0 commit comments

Comments
 (0)