Skip to content

Commit

Permalink
Update to avoid cast when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
frankeld committed Aug 28, 2024
1 parent da4bd2f commit b48629c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Expressions/UnaryExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,18 @@ public function evaluateImpl(row $row, AsyncMysqlConnection $conn): mixed {
invariant($op is nonnull, 'This case was not considered. The operator is null.');
switch ($op) {
case Operator::UNARY_MINUS:
return -1 * (float)$val;
// Keeping this cast around for backwards compat
if (!($val is num)) {
$val = (float)$val;
}
return -1 * $val;
case Operator::UNARY_PLUS:
return (float)$val;
// Keeping this cast around for backwards compat
if (!($val is num)) {
$val = (float)$val;
}
return $val;
case Operator::TILDE:
case Operator::TILDE:
return ~(int)$val;
default:
Expand Down

0 comments on commit b48629c

Please sign in to comment.