Commit d6e4e48
Keep rootExpr for equality assertions, move specifyOnly after rootExpr check
- Revert equality assertions (`@phpstan-assert =`) back to using
`rootExpr = $call` instead of `specifyOnly`. The rootExpr mechanism
in ImpossibleCheckTypeHelper provides more nuanced detection (constant
boolean evaluation via scope) and is the established path for these.
`specifyOnly` is reserved for the FAUX replacement cases (str_contains,
array_key_exists) where sureTypes are pure side effects.
- Move the `specifyOnly` check after the `rootExpr` check in
ImpossibleCheckTypeHelper so that rootExpr takes precedence when both
flags are set (e.g. via unionWith/intersectWith propagation).
- Add duplicate call test cases (str_ends_with, str_contains) to
document that nested identical calls are not reported as always-true.
This was never detected before — the old FAUX mechanism also returned
null for these — and would require a separate mechanism (tracking
function call results in scope).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent bde2066 commit d6e4e48
3 files changed
Lines changed: 29 additions & 8 deletions
File tree
- src
- Analyser
- Rules/Comparison
- tests/PHPStan/Rules/Comparison/data
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1856 | 1856 | | |
1857 | 1857 | | |
1858 | 1858 | | |
1859 | | - | |
1860 | | - | |
1861 | | - | |
1862 | | - | |
| 1859 | + | |
1863 | 1860 | | |
1864 | 1861 | | |
1865 | 1862 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | 276 | | |
281 | 277 | | |
282 | 278 | | |
| |||
294 | 290 | | |
295 | 291 | | |
296 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
69 | 93 | | |
0 commit comments