Skip to content

Commit fe41708

Browse files
committed
Still look for arrow func when var scope is 0
`findVariableScopeExceptArrowFunctions()` can return null if it finds no scope, but it can also return 0 which is the file level scope. The additional code to look for arrow function scope needs to operate even on 0.
1 parent d45a394 commit fe41708

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

VariableAnalysis/Lib/Helpers.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ public static function findVariableScope(File $phpcsFile, $stackPtr, $varName =
429429
$varName = isset($varName) ? $varName : self::normalizeVarName($token['content']);
430430

431431
$enclosingScopeIndex = self::findVariableScopeExceptArrowFunctions($phpcsFile, $stackPtr);
432-
if ($enclosingScopeIndex) {
432+
433+
if (!is_null($enclosingScopeIndex)) {
433434
$arrowFunctionIndex = self::getContainingArrowFunctionIndex($phpcsFile, $stackPtr, $enclosingScopeIndex);
434435
$isTokenInsideArrowFunctionBody = is_int($arrowFunctionIndex);
435436
if ($isTokenInsideArrowFunctionBody) {

0 commit comments

Comments
 (0)