Skip to content

Commit

Permalink
Fix NameResolver for class constant native type
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes authored and nikic committed Nov 28, 2023
1 parent d0b3512 commit f666500
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/PhpParser/NodeVisitor/NameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ public function enterNode(Node $node) {
$this->addNamespacedName($const);
}
} elseif ($node instanceof Stmt\ClassConst) {
if (null !== $node->type) {
$node->type = $this->resolveType($node->type);
}
$this->resolveAttrGroups($node);
} elseif ($node instanceof Stmt\EnumCase) {
$this->resolveAttrGroups($node);
Expand Down
9 changes: 8 additions & 1 deletion test/PhpParser/NodeVisitor/NameResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class A extends B implements C, D {
E::h as i;
E::j insteadof F, G;
}
#[X]
public float $php = 7.4;
public ?Foo $person;
Expand All @@ -197,6 +197,10 @@ class A extends B implements C, D {
#[X]
const C = 1;
public const X A = X::Bar;
public const X\Foo B = X\Foo::Bar;
public const \X\Foo C = \X\Foo::Bar;
}
#[X]
Expand Down Expand Up @@ -262,6 +266,9 @@ class A extends \NS\B implements \NS\C, \NS\D
public \NS\A|\NS\B|int $prop;
#[\NS\X]
const C = 1;
public const \NS\X A = \NS\X::Bar;
public const \NS\X\Foo B = \NS\X\Foo::Bar;
public const \X\Foo C = \X\Foo::Bar;
}
#[\NS\X]
interface A extends \NS\C, \NS\D
Expand Down

0 comments on commit f666500

Please sign in to comment.