function VariableAnalysisSniff::processVariableAsClassProperty
* Process a class property that is being defined. * * Property definitions are ignored currently because all property access is * legal, even to undefined properties. * * Can be called for any token and will return false if the variable is not * of this type. * *
Parameters
File $phpcsFile: * @param int $stackPtr * * @return bool
1 call to VariableAnalysisSniff::processVariableAsClassProperty()
- VariableAnalysisSniff::processVariable in vendor/
sirbrillig/ phpcs-variable-analysis/ VariableAnalysis/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php - * Process a normal variable in the code. * * Most importantly, this function determines if the variable use is a "read" * (using the variable for something) or a "write" (an assignment) or, * sometimes, both at once. * …
File
-
vendor/
sirbrillig/ phpcs-variable-analysis/ VariableAnalysis/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php, line 865
Class
Namespace
VariableAnalysis\Sniffs\CodeAnalysisCode
protected function processVariableAsClassProperty(File $phpcsFile, $stackPtr) {
// Make sure we are not in a class method before assuming it's a property.
$tokens = $phpcsFile->getTokens();
/** @var array{conditions?: (int|string)[], content?: string}|null */
$token = $tokens[$stackPtr];
if ($token && !empty($token['conditions']) && !empty($token['content']) && !Helpers::areConditionsWithinFunctionBeforeClass($token)) {
return Helpers::areAnyConditionsAClass($token);
}
return false;
}