Commit 676b6f5
Infer return type from class-string<T> in ClassResolver extensions (#965)
Infer return type from class-string<T> argument in ClassResolver extensions
When a variable typed as class-string<T> is passed to
ClassResolverInterface::getInstanceFromDefinition() or Drupal::classResolver(),
PHPStan now infers the return type as T instead of falling back to object.
The existing service-ID and constant-string class-name resolution via ServiceMap
is unchanged. This only fills the gap for non-constant class-string<T> variables.
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 2552230 commit 676b6f5
2 files changed
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
11 | 27 | | |
12 | 28 | | |
13 | 29 | | |
| |||
0 commit comments