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\DeprecationsCode
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);
}