function Helpers::areConditionsWithinFunctionBeforeClass
* Return true if the token conditions are within a function before they are * within a class. * *
Parameters
array{conditions: (int|string)[], content: string} $token: * * @return bool
1 call to Helpers::areConditionsWithinFunctionBeforeClass()
- VariableAnalysisSniff::processVariableAsClassProperty in vendor/
sirbrillig/ phpcs-variable-analysis/ VariableAnalysis/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php - * 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…
File
-
vendor/
sirbrillig/ phpcs-variable-analysis/ VariableAnalysis/ Lib/ Helpers.php, line 133
Class
Namespace
VariableAnalysis\LibCode
public static function areConditionsWithinFunctionBeforeClass(array $token) {
$conditions = $token['conditions'];
$classlikeCodes = [
T_CLASS,
T_ANON_CLASS,
T_TRAIT,
];
if (defined('T_ENUM')) {
$classlikeCodes[] = T_ENUM;
}
$classlikeCodes[] = 'PHPCS_T_ENUM';
foreach (array_reverse($conditions, true) as $scopeCode) {
if (in_array($scopeCode, $classlikeCodes)) {
return false;
}
if ($scopeCode === T_FUNCTION) {
return true;
}
}
return false;
}