function FetchingDeprecatedConstRule::processNode
File
-
vendor/
phpstan/ phpstan-deprecation-rules/ src/ Rules/ Deprecations/ FetchingDeprecatedConstRule.php, line 36
Class
- FetchingDeprecatedConstRule
- @implements Rule<ConstFetch>
Namespace
PHPStan\Rules\DeprecationsCode
public function processNode(Node $node, Scope $scope) : array {
if ($this->deprecatedScopeHelper
->isScopeDeprecated($scope)) {
return [];
}
if (!$this->reflectionProvider
->hasConstant($node->name, $scope)) {
return [];
}
$constantReflection = $this->reflectionProvider
->getConstant($node->name, $scope);
if ($constantReflection->isDeprecated()
->yes()) {
return [
RuleErrorBuilder::message(sprintf($constantReflection->getDeprecatedDescription() ?? 'Use of constant %s is deprecated.', $constantReflection->getName()))
->identifier('constant.deprecated')
->build(),
];
}
return [];
}