Commit e8a33a8
committed
Fix static method call on non-generic class-string returning ErrorType
- When calling a static method on a non-generic class-string (e.g. $class::foo()
where $class is class-string), the result was ErrorType instead of MixedType
- Root cause: class-string converts to ObjectWithoutClassType via
getObjectTypeOrClassStringObjectType(), which returns maybe for hasMethod(),
causing filterTypeWithMethod() to reject it and methodCallReturnType() to
return null, falling back to ErrorType
- Fix checks if the static call is on an expression (not a class name), the
resolved type has no known class names, and hasMethod is not definitively no,
returning MixedType in that case
- New regression test in tests/PHPStan/Analyser/nsrt/bug-9844.php
Closes phpstan/phpstan#98441 parent 106fc93 commit e8a33a8
2 files changed
Lines changed: 26 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6390 | 6390 | | |
6391 | 6391 | | |
6392 | 6392 | | |
6393 | | - | |
| 6393 | + | |
| 6394 | + | |
| 6395 | + | |
| 6396 | + | |
| 6397 | + | |
| 6398 | + | |
| 6399 | + | |
| 6400 | + | |
| 6401 | + | |
6394 | 6402 | | |
6395 | 6403 | | |
6396 | 6404 | | |
| |||
| 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 | + | |
0 commit comments