function Helpers::getVariablesDefinedByArrowFunction
*
Parameters
File $phpcsFile: * @param int $stackPtr * * @return string[]
1 call to Helpers::getVariablesDefinedByArrowFunction()
- Helpers::findVariableScope in vendor/
sirbrillig/ phpcs-variable-analysis/ VariableAnalysis/ Lib/ Helpers.php - *
File
-
vendor/
sirbrillig/ phpcs-variable-analysis/ VariableAnalysis/ Lib/ Helpers.php, line 1004
Class
Namespace
VariableAnalysis\LibCode
public static function getVariablesDefinedByArrowFunction(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile->getTokens();
$arrowFunctionToken = $tokens[$stackPtr];
$variableNames = [];
self::debug('looking for variables in arrow function token', $arrowFunctionToken);
for ($index = $arrowFunctionToken['parenthesis_opener']; $index < $arrowFunctionToken['parenthesis_closer']; $index++) {
$token = $tokens[$index];
if ($token['code'] === T_VARIABLE) {
$variableNames[] = self::normalizeVarName($token['content']);
}
}
self::debug('found these variables in arrow function token', $variableNames);
return $variableNames;
}