Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CallToDeprecatedFunctionRule.php

function CallToDeprecatedFunctionRule::processNode

File

vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/CallToDeprecatedFunctionRule.php, line 38

Class

CallToDeprecatedFunctionRule
@implements Rule<FuncCall>

Namespace

PHPStan\Rules\Deprecations

Code

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 [];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal