1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Fix #2132 - get value of literal int division

This commit is contained in:
Matt Brown 2020-11-04 22:32:33 -05:00
parent 3e9c5d3600
commit eacc05e73f

View File

@ -315,6 +315,14 @@ class NonDivArithmeticOpAnalyzer
$calculated_type = Type::getInt(false, $left_type_part->value | $right_type_part->value);
} elseif ($parent instanceof PhpParser\Node\Expr\BinaryOp\BitwiseAnd) {
$calculated_type = Type::getInt(false, $left_type_part->value & $right_type_part->value);
} elseif ($parent instanceof PhpParser\Node\Expr\BinaryOp\Div) {
$value = $left_type_part->value / $right_type_part->value;
if (is_int($value)) {
$calculated_type = Type::getInt(false, $value);
} else {
$calculated_type = Type::getFloat($value);
}
}
if ($calculated_type) {