function Helpers::getPreviousArrowFunctionIndex
* Move back from the stackPtr to the start of the enclosing scope until we * find a 'fn' token that starts an arrow function, returning the index of * that token. Returns null if there are no arrow functions before stackPtr. * * Note that this does not guarantee that stackPtr is inside the arrow * function scope we find! * *
Parameters
File $phpcsFile: * @param int $stackPtr * @param int $enclosingScopeIndex * * @return ?int
1 call to Helpers::getPreviousArrowFunctionIndex()
- Helpers::getContainingArrowFunctionIndex in vendor/
sirbrillig/ phpcs-variable-analysis/ VariableAnalysis/ Lib/ Helpers.php - *
File
-
vendor/
sirbrillig/ phpcs-variable-analysis/ VariableAnalysis/ Lib/ Helpers.php, line 687
Class
Namespace
VariableAnalysis\LibCode
private static function getPreviousArrowFunctionIndex(File $phpcsFile, $stackPtr, $enclosingScopeIndex) {
$tokens = $phpcsFile->getTokens();
for ($index = $stackPtr - 1; $index > $enclosingScopeIndex; $index--) {
$token = $tokens[$index];
if ($token['content'] === 'fn' && self::isArrowFunction($phpcsFile, $index)) {
return $index;
}
}
return null;
}