Commit d0c5099
Align ClassConstantAccessType::getResult() with InitializerExprTypeResolver logic
Restructured getResult() to match the $isObject path in
InitializerExprTypeResolver::getClassConstFetchTypeByReflection():
- Extract ClassReflection first via getObjectClassReflections()
- Add enum case handling (EnumCaseObjectType)
- Match exact condition structure: class not final AND constant not final
AND no phpDocType AND no nativeType → mixed
- Otherwise use getValueType() (declared type for typed constants,
literal for untyped constants)
Added test cases for final child class inheriting @return static::CONST
and for final typed constant on non-final class.
Co-authored-by: Ondřej Mirtes <ondrejmirtes@users.noreply.github.com>1 parent e450d3c commit d0c5099
File tree
2 files changed
+49
-10
lines changed- src/Type
- tests/PHPStan/Analyser/nsrt
2 files changed
+49
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
55 | 65 | | |
56 | 66 | | |
57 | 67 | | |
58 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
59 | 71 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 72 | + | |
66 | 73 | | |
67 | | - | |
68 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
69 | 81 | | |
70 | 82 | | |
71 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
0 commit comments