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:
parent
3e9c5d3600
commit
eacc05e73f
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user