Commit 911404a
Fix redundant type cast dropping type narrowing in comparisons
- Unwrap redundant cast expressions in Smaller/SmallerOrEqual type specifying
so that narrowing propagates to the inner variable instead of the cast expr
- When a cast produces the same type as its inner expression (e.g. (int) on
an int variable), the narrowing is now applied to the original variable
- New regression test in tests/PHPStan/Analyser/nsrt/bug-7858.php
Closes phpstan/phpstan#78581 parent 2681e50 commit 911404a
2 files changed
Lines changed: 46 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
431 | 448 | | |
432 | | - | |
| 449 | + | |
433 | 450 | | |
434 | 451 | | |
435 | | - | |
| 452 | + | |
436 | 453 | | |
437 | 454 | | |
438 | 455 | | |
439 | 456 | | |
440 | 457 | | |
441 | 458 | | |
442 | | - | |
| 459 | + | |
443 | 460 | | |
444 | 461 | | |
445 | | - | |
| 462 | + | |
446 | 463 | | |
447 | 464 | | |
448 | 465 | | |
449 | 466 | | |
450 | 467 | | |
451 | 468 | | |
452 | 469 | | |
453 | | - | |
| 470 | + | |
454 | 471 | | |
455 | 472 | | |
456 | | - | |
| 473 | + | |
457 | 474 | | |
458 | 475 | | |
459 | 476 | | |
460 | 477 | | |
461 | 478 | | |
462 | 479 | | |
463 | | - | |
| 480 | + | |
464 | 481 | | |
465 | 482 | | |
466 | | - | |
| 483 | + | |
467 | 484 | | |
468 | 485 | | |
469 | 486 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments