-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#1904Labels
Description
Feature improvement
While working on Integer Range implementation in Psalm, I came across some interesting test cases that are not yet handled on PHPStan. I thought it would be useful to post them here to have a coherent implementation between our tools (cc @staabm)
- Literal power arithmetic is not inferred: https://phpstan.org/r/63664a6c-b18e-4d0f-8666-59feef8d51ed
- Loop start at 0 but range starts at min: https://phpstan.org/r/448d575f-49a9-4549-8c59-f0f0bb779c5a
- Wrong inference with Minus: https://phpstan.org/r/0f2bf43b-e5a6-436b-ac44-e62a2c60ae94
Shift result can only be positive: https://phpstan.org/r/dfd46a1d-6fc6-44ef-b2f8-6cd7b74c67e8EDIT: that's wrong. PHP forbid using negatives in the second operand but not in the first- UnaryMinus should inverse range: https://phpstan.org/r/1c4411c3-67c5-4dfa-bc8f-1e0b8188f62c
- when two Integer Range are ===, the result should be the intersection(and both operands should update): https://phpstan.org/r/a8429682-c200-43a6-b6d5-93ae431e5bdd