-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix namespace of named type in class constant native type by patching…
… PHP-Parser
- Loading branch information
1 parent
6b5c6e4
commit 8234dc0
Showing
7 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- lib/PhpParser/NodeVisitor/NameResolver.php 2023-11-28 14:02:15 | ||
+++ lib/PhpParser/NodeVisitor/NameResolver.php 2023-11-28 14:03:53 | ||
@@ -119,6 +119,9 @@ | ||
} | ||
} else if ($node instanceof Stmt\ClassConst) { | ||
$this->resolveAttrGroups($node); | ||
+ if (null !== $node->type) { | ||
+ $node->type = $this->resolveType($node->type); | ||
+ } | ||
} else if ($node instanceof Stmt\EnumCase) { | ||
$this->resolveAttrGroups($node); | ||
} elseif ($node instanceof Expr\StaticCall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php // lint >= 8.3 | ||
|
||
namespace Bug10212; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
enum Foo | ||
{ | ||
case Bar; | ||
} | ||
|
||
class HelloWorld | ||
{ | ||
public const string A = 'foo'; | ||
public const X\Foo B = Foo::Bar; | ||
public const Foo C = Foo::Bar; | ||
} | ||
|
||
function(HelloWorld $hw): void { | ||
assertType(X\Foo::class, $hw::B); | ||
assertType(Foo::class, $hw::C); | ||
}; |