Commit c4b0b52
Fix dynamic variable access producing inconsistent errors on PHP 8.1+
Use getScopeType() instead of getType() in filterBySpecifiedTypes() to
bypass the fiber mechanism when reading the narrowed type after
addTypeToExpression/assignExpression. On FiberScope, getType() suspends
the fiber and returns the pre-modification type from the coordinator,
causing conditional expression guard matching to fail. This made $$name
dynamic access report false "might not be defined" errors for variables
that are conditionally defined based on the name value.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent d6d4f4b commit c4b0b52
File tree
2 files changed
+1
-9
lines changed- src/Analyser
- tests/PHPStan/Rules/Variables
2 files changed
+1
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3230 | 3230 | | |
3231 | 3231 | | |
3232 | 3232 | | |
3233 | | - | |
| 3233 | + | |
3234 | 3234 | | |
3235 | 3235 | | |
3236 | 3236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1137 | 1137 | | |
1138 | 1138 | | |
1139 | 1139 | | |
1140 | | - | |
1141 | | - | |
1142 | | - | |
1143 | | - | |
1144 | | - | |
1145 | | - | |
1146 | | - | |
1147 | | - | |
1148 | 1140 | | |
1149 | 1141 | | |
1150 | 1142 | | |
| |||
0 commit comments