-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
More precise type inference with unary plus and minus #580
Conversation
$type = TypeUtils::generalizeType($type, GeneralizePrecision::lessSpecific()); | ||
|
||
if ($type instanceof ConstantIntegerType && $factor->sign === false) { | ||
$type = new ConstantIntegerType($type->getValue() * -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- What about sign=true?
- Looks like this doesn't have tests, at least from the diff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Sign
true
is+1
, signnull
is1
, those dont change value of constant type - Tests are present in origin: #506 commit. Mostly I didnt add testcases to the old test as that one is MUCH worse. But I can add simple one to this separated PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test I'm trying to write produces wrong results as those two are not merged yet:
- Proper aggregate function detection (even deeper in AST) #581
- Introduce DoctrineTypeDriverAwareDescriptor & DriverDetector #578
DQL from the test:
SELECT -o.intColumn as minusInt,
-o.floatColumn as minusFloat,
-COUNT(o.intColumn) as minusIntRange
FROM QueryResult\Entities\One o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test added, it will fail once rebased on those PRs.
); | ||
|
||
} elseif ($type instanceof ConstantFloatType && $factor->sign === false) { | ||
$type = new ConstantFloatType($type->getValue() * -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same questions as above
Thank you. |
Separated from #506