support unary-minus on IntegerRangeType#669
Conversation
9e3851f to
159fd4f
Compare
|
failling test is unrelated. just rebased. |
| if ($type instanceof IntegerRangeType) { | ||
| $negativeRange = $this->resolveType(new Node\Expr\BinaryOp\Mul($node->expr, new LNumber(-1))); | ||
|
|
||
| if ( $negativeRange instanceof IntegerRangeType && ($negativeRange->getMin() === null || $negativeRange->getMax() === null)) { |
There was a problem hiding this comment.
Actually I was not sure whether multiplication by -1 should have already returned the range as we need it and this if-case actually compensates a bug in the Mul logic?
There was a problem hiding this comment.
I don't know, you tell me :) Feel free to fix more bugs here.
There was a problem hiding this comment.
Do we expect -$b === $b * -1 Given $b = int<min, 5> ?
There was a problem hiding this comment.
Seems like it. Here's a small script I made to generate equations for Wolfram: https://3v4l.org/AUHH7
There was a problem hiding this comment.
btw: the same is true for division: Wolfram
|
@ondrejmirtes we can merge here as is. The multiplication bug will be fixed separately |
|
Thank you! |
refs phpstan/phpstan#5614