Commit ce34267
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 b72f6ee commit ce34267
2 files changed
Lines changed: 46 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
495 | 512 | | |
496 | | - | |
| 513 | + | |
497 | 514 | | |
498 | 515 | | |
499 | | - | |
| 516 | + | |
500 | 517 | | |
501 | 518 | | |
502 | 519 | | |
503 | 520 | | |
504 | 521 | | |
505 | 522 | | |
506 | | - | |
| 523 | + | |
507 | 524 | | |
508 | 525 | | |
509 | | - | |
| 526 | + | |
510 | 527 | | |
511 | 528 | | |
512 | 529 | | |
513 | 530 | | |
514 | 531 | | |
515 | 532 | | |
516 | 533 | | |
517 | | - | |
| 534 | + | |
518 | 535 | | |
519 | 536 | | |
520 | | - | |
| 537 | + | |
521 | 538 | | |
522 | 539 | | |
523 | 540 | | |
524 | 541 | | |
525 | 542 | | |
526 | 543 | | |
527 | | - | |
| 544 | + | |
528 | 545 | | |
529 | 546 | | |
530 | | - | |
| 547 | + | |
531 | 548 | | |
532 | 549 | | |
533 | 550 | | |
| |||
| 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