Repository navigation
Commit 9e7b557
Drop the
`resource` is a pseudo-type, PHP has no such native type - a `resource` typehint
in source is read as a class name. So `ParserNodeTypeToPHPStanType` is the wrong
place to special-case it: it resolves native types for all code, including a
userland class named `Resource`.
The pseudo-type only enters through the PhpStorm stubs, which describe pre-PHP 8
signatures with `#[LanguageLevelTypeAware(['8.1' => 'finfo'], default: 'resource')]`.
`PhpStormStubsSourceStubber` turned that string into a native type, so every such
signature ended up with `ObjectType('resource')` - a class type unrelated to
`ResourceType`, hence "expects resource, resource given".
Drop the native type there instead (the stubber already does this for other
unrepresentable types such as `string[]|string|null`), which leaves the
`@param resource`/`@return resource` PHPDoc in the same stub to describe the type.
Unions containing `resource` (`resource|false`, `resource|array|string`) are
handled too - those additionally made `is_resource()` narrow to `*NEVER*`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>resource native type in PhpStormStubsSourceStubber instead of resolving it in ParserNodeTypeToPHPStanType1 parent fc4f414 commit 9e7b557
4 files changed
Lines changed: 21 additions & 9 deletions
File tree
- patches
- src/Type
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
147 | 150 | | |
148 | 151 | | |
149 | 152 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 29 | | |
38 | 30 | | |
39 | 31 | | |
| |||
0 commit comments