36 ReflectionProvider $reflectionProvider,
37 \PHPStan\Rules\Generics\GenericAncestorsCheck $genericAncestorsCheck
43 $forbidden_classes = [];
48 $forbidden_classes = array_merge(
54 $this->forbidden_classes = array_unique($forbidden_classes);
59 if (isset($this->ancestor_cache[$class_name])) {
60 return $this->ancestor_cache[$class_name];
63 $ancestors[] = $class_name;
66 $reflection = $this->reflectionProvider->getClass($class_name);
67 $ancestors = array_merge($ancestors, $reflection->getParentClassesNames());
68 }
catch (\PHPStan\Broker\ClassNotFoundException
$e) {
73 return array_unique($ancestors);
78 $this->ancestor_cache[$class_name] = $ancestor_classes;
83 return CallLike::class;
92 final public function processNode(Node $node, Scope $scope): array
95 case $node instanceof Node\Expr\StaticCall:
96 case $node instanceof Node\Expr\New_:
97 if ($node->class instanceof Node\Name) {
98 $class_name = $node->class->toString();
109 $array_intersect = array_intersect($class_names_to_test, $this->forbidden_classes);
110 if ($array_intersect !== []) {
113 RuleErrorBuilder::message(
"Usage of $class_name is forbidden.")
cacheAncestors($class_name, array $ancestor_classes)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getRelevantILIASVersion()
PHPStan Rules Generics GenericAncestorsCheck $genericAncestorsCheck
getClassAncestors(string $class_name)
processNode(Node $node, Scope $scope)
getHumanReadableRuleName()
__construct(ReflectionProvider $reflectionProvider, \PHPStan\Rules\Generics\GenericAncestorsCheck $genericAncestorsCheck)
ReflectionProvider $reflectionProvider