Skip to content

Commit fc4f414

Browse files
phpstan-botclaude
andcommitted
Patch nikic/php-parser with the resource builtin type from PHP-Parser#1166
`BuilderHelpers::normalizeType()` turns every type name it does not know as a builtin into a `Name` node, i.e. a class name - including `resource`. Apply the upstream fix from nikic/PHP-Parser#1166 as a patch file so the builder API produces an `Identifier` for it. Note this has no effect on PHPStan's analysis on its own: `PhpStormStubsSourceStubber` pretty-prints the stub node back to source and the source is re-parsed, and a `resource` typehint in PHP source is a class name again. The patch is here because the builder API should not claim `resource` is a class; the actual fix is in the following commit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent c058b09 commit fc4f414

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎composer.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@
141141
"nette/di": [
142142
"patches/Resolver.patch"
143143
],
144+
"nikic/php-parser": [
145+
"patches/BuilderHelpers.patch"
146+
],
144147
"symfony/console": [
145148
"patches/OutputFormatter.patch",
146149
"patches/Application.patch"

‎composer.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎patches/BuilderHelpers.patch‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/lib/PhpParser/BuilderHelpers.php b/lib/PhpParser/BuilderHelpers.php
2+
index f29a69153d..deac776e9c 100644
3+
--- a/lib/PhpParser/BuilderHelpers.php
4+
+++ b/lib/PhpParser/BuilderHelpers.php
5+
@@ -184,6 +184,7 @@ public static function normalizeType($type) {
6+
'int',
7+
'float',
8+
'string',
9+
+ 'resource',
10+
'iterable',
11+
'void',
12+
'object',

0 commit comments

Comments
 (0)