Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

declare(strict_types=1);
Expand Down Expand Up @@ -960,25 +960,25 @@
} elseif ($operation instanceof PhpParser\Node\Expr\BinaryOp\Minus) {
$result = $operand1 - $operand2;
} elseif ($operation instanceof PhpParser\Node\Expr\BinaryOp\Mod) {
if ($operand2 === 0) {
if ($operand2 === 0 || $operand2 === 0.0) {
return Type::getNever();
}

$result = $operand1 % $operand2;
$result = (int) $operand1 % (int) $operand2;
} elseif ($operation instanceof PhpParser\Node\Expr\BinaryOp\Mul) {
$result = $operand1 * $operand2;
} elseif ($operation instanceof PhpParser\Node\Expr\BinaryOp\Pow) {
$result = $operand1 ** $operand2;
} elseif ($operation instanceof PhpParser\Node\Expr\BinaryOp\BitwiseOr) {
$result = $operand1 | $operand2;
$result = (int) $operand1 | (int) $operand2;
} elseif ($operation instanceof PhpParser\Node\Expr\BinaryOp\BitwiseAnd) {
$result = $operand1 & $operand2;
$result = (int) $operand1 & (int) $operand2;
} elseif ($operation instanceof PhpParser\Node\Expr\BinaryOp\BitwiseXor) {
$result = $operand1 ^ $operand2;
$result = (int) $operand1 ^ (int) $operand2;
} elseif ($operation instanceof PhpParser\Node\Expr\BinaryOp\ShiftLeft) {
$result = $operand1 << $operand2;
$result = (int) $operand1 << (int) $operand2;
} elseif ($operation instanceof PhpParser\Node\Expr\BinaryOp\ShiftRight) {
$result = $operand1 >> $operand2;
$result = (int) $operand1 >> (int) $operand2;
} elseif ($operation instanceof PhpParser\Node\Expr\BinaryOp\Div) {
if ($operand2 === 0 || $operand2 === 0.0) {
return Type::getNever();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function analyze(
$has_valid_operand = true;
} elseif ($type_part instanceof TFloat) {
$type_part = ($type_part instanceof TLiteralFloat) ?
new TLiteralInt(~$type_part->value) :
new TLiteralInt(~(int) $type_part->value) :
new TInt;

$stmt_expr_type->removeType($type_string);
Expand Down
Loading