function CallToDeprecatedFunctionRule::processNode
File
-
vendor/
phpstan/ phpstan-deprecation-rules/ src/ Rules/ Deprecations/ CallToDeprecatedFunctionRule.php, line 38
Class
- CallToDeprecatedFunctionRule
- @implements Rule<FuncCall>
Namespace
PHPStan\Rules\DeprecationsCode
public function processNode(Node $node, Scope $scope) : array {
if ($this->deprecatedScopeHelper
->isScopeDeprecated($scope)) {
return [];
}
if (!$node->name instanceof Name) {
return [];
}
try {
$function = $this->reflectionProvider
->getFunction($node->name, $scope);
} catch (FunctionNotFoundException $e) {
// Other rules will notify if the function is not found
return [];
}
if ($function->isDeprecated()
->yes()) {
$description = $function->getDeprecatedDescription();
if ($description === null) {
return [
RuleErrorBuilder::message(sprintf('Call to deprecated function %s().', $function->getName()))
->identifier('function.deprecated')
->build(),
];
}
return [
RuleErrorBuilder::message(sprintf("Call to deprecated function %s():\n%s", $function->getName(), $description))
->identifier('function.deprecated')
->build(),
];
}
return [];
}