Repository navigation
Commit 54ac5fd
committed
Adjust self-analysis for the more precise foreach-body narrowing
The self-analysis config runs with bleedingEdge on, so the foreach body now
narrows the iterated expression even under phpstan-strict-rules. That lets
PHPStan prove two facts in its own source that it previously left uncertain:
- UnionType::accepts() reuses $i as the value variable of a second foreach
after it was the key variable of an earlier one. The reused name now reads
as a foreach.valueOverwrite, so rename the second loop's variable.
- ConstantArrayType::isSuperTypeOf() destructures $this->unsealed and
$type->unsealed (typed array{Type, Type}|null) in branches guarded by a
separate unsealedness check that PHPStan cannot connect to the property.
Read the property into a local and throw ShouldNotHappenException on null,
matching the file's existing impossible-state style.
Both changes preserve behaviour.1 parent a4609bb commit 54ac5fd
2 files changed
Lines changed: 14 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
811 | 811 | | |
812 | 812 | | |
813 | 813 | | |
814 | | - | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
815 | 819 | | |
816 | 820 | | |
817 | 821 | | |
| |||
835 | 839 | | |
836 | 840 | | |
837 | 841 | | |
838 | | - | |
839 | | - | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
840 | 849 | | |
841 | 850 | | |
842 | 851 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
| 242 | + | |
243 | 243 | | |
244 | | - | |
| 244 | + | |
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| |||
0 commit comments