Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanvelzen committed Apr 2, 2022
1 parent 4eff9fa commit 5b11ca8
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/PhpDoc/TypeNodeResolver.php
Expand Up @@ -381,10 +381,8 @@ private function mightBeConstant(string $name): bool

private function tryResolveConstant(string $name, NameScope $nameScope): ?Type
{
$names = $this->getPossibleConstantNames($name, $nameScope);

foreach ($names as $name) {
$nameNode = new Name\FullyQualified(explode('\\', $name));
foreach ($this->getPossibleFullyQualifiedConstantNames($name, $nameScope) as $fqn) {
$nameNode = new Name\FullyQualified(explode('\\', $fqn));

if ($this->getReflectionProvider()->hasConstant($nameNode, null)) {
return $this->getReflectionProvider()->getConstant($nameNode, null)->getValueType();
Expand All @@ -397,7 +395,7 @@ private function tryResolveConstant(string $name, NameScope $nameScope): ?Type
/**
* @return non-empty-list<string>
*/
private function getPossibleConstantNames(string $name, NameScope $nameScope): array
private function getPossibleFullyQualifiedConstantNames(string $name, NameScope $nameScope): array
{
if (strpos($name, '\\') === 0) {
return [ltrim($name, '\\')];
Expand Down

0 comments on commit 5b11ca8

Please sign in to comment.