Commit e450d3c
Fix ClassConstantAccessType to return mixed for untyped constants on non-final classes
When static::CONST is used and the constant has no native type or PHPDoc type,
and neither the class nor the constant is final, return mixed instead of the
literal value — since a subclass could override the constant with any value.
Also unified the logic to use getObjectClassReflections() instead of
instanceof StaticType, so it works for both unresolved StaticType and
resolved ObjectType (e.g., FooBar $foo where $foo could be a subclass).
Co-authored-by: Ondřej Mirtes <ondrejmirtes@users.noreply.github.com>1 parent cccf92c commit e450d3c
File tree
2 files changed
+11
-12
lines changed- src/Type
- tests/PHPStan/Analyser/nsrt
2 files changed
+11
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
67 | 68 | | |
68 | | - | |
69 | | - | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
0 commit comments