Skip to content

Commit

Permalink
Process ClassConstFetch where $class is Name only for enums (#266)
Browse files Browse the repository at this point in the history
PHPStan 1.12.6 started "Process[ing] ClassConstFetch::$class when it's a Name node" (phpstan/phpstan-src@712c33e) and that now duplicates findings by the `FullyQualified` check above on class constants.

https://github.com/phpstan/phpstan/releases/tag/1.12.6
  • Loading branch information
spaze authored Oct 11, 2024
2 parents 86ef121 + 133690e commit ad538e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"require": {
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.10.52"
"phpstan/phpstan": "^1.12.6"
},
"require-dev": {
"nette/neon": "^3.2",
Expand Down
6 changes: 2 additions & 4 deletions src/Usages/NamespaceUsages.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,13 @@ public function processNode(Node $node, Scope $scope): array
} elseif ($node instanceof StaticCall && $node->class instanceof Name) {
$namespaces = [$node->class->toString()];
} elseif ($node instanceof ClassConstFetch && $node->class instanceof Name) {
$namespaces = [];
$classReflection = $scope->resolveTypeByName($node->class)->getClassReflection();
if ($classReflection && $classReflection->isEnum()) {
$description = 'Enum';
$identifier = ErrorIdentifiers::DISALLOWED_ENUM;
} else {
$description = 'Class';
$identifier = ErrorIdentifiers::DISALLOWED_CLASS;
$namespaces = [$node->class->toString()];
}
$namespaces = [$node->class->toString()];
} elseif ($node instanceof Class_ && ($node->extends !== null || count($node->implements) > 0)) {
$namespaces = [];

Expand Down

0 comments on commit ad538e6

Please sign in to comment.