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

Breadcrumb

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

function DeprecatedAnnotationsRuleBase::processNode

File

vendor/mglaman/phpstan-drupal/src/Rules/Deprecations/DeprecatedAnnotationsRuleBase.php, line 40

Class

DeprecatedAnnotationsRuleBase
@implements Rule<Node\Stmt\Class_>

Namespace

mglaman\PHPStanDrupal\Rules\Deprecations

Code

public function processNode(Node $node, Scope $scope) : array {
    if ($node->extends === null) {
        return [];
    }
    if ($node->name === null) {
        return [];
    }
    if ($node->isAbstract()) {
        return [];
    }
    // PHPStan gives anonymous classes a name, so we cannot determine if
    // a class is truly anonymous using the normal methods from php-parser.
    // @see \PHPStan\Reflection\BetterReflection\BetterReflectionProvider::getAnonymousClassReflection
    if ($node->hasAttribute('anonymousClass') && $node->getAttribute('anonymousClass') === true) {
        return [];
    }
    $className = $node->name->name;
    $namespace = $scope->getNamespace();
    $reflection = $this->reflectionProvider
        ->getClass($namespace . '\\' . $className);
    $implementsExpectedInterface = $reflection->implementsInterface($this->getExpectedInterface());
    if (!$implementsExpectedInterface) {
        return [];
    }
    return $this->doProcessNode($reflection, $node, $scope);
}

API Navigation

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