Skip to content

Commit f7b6fe3

Browse files
staabmondrejmirtes
authored andcommitted
Simplify isFloat checks
1 parent ead586b commit f7b6fe3

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/Reflection/InitializerExprTypeResolver.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,17 +1192,16 @@ public function getMulType(Expr $left, Expr $right, callable $getTypeCallback):
11921192
return TypeCombinator::union(...$resultTypes);
11931193
}
11941194

1195-
$floatType = new FloatType();
11961195
$leftNumberType = $leftType->toNumber();
11971196
if ($leftNumberType instanceof ConstantIntegerType && $leftNumberType->getValue() === 0) {
1198-
if ($floatType->isSuperTypeOf($rightType)->yes()) {
1197+
if ($rightType->isFloat()->yes()) {
11991198
return new ConstantFloatType(0.0);
12001199
}
12011200
return new ConstantIntegerType(0);
12021201
}
12031202
$rightNumberType = $rightType->toNumber();
12041203
if ($rightNumberType instanceof ConstantIntegerType && $rightNumberType->getValue() === 0) {
1205-
if ($floatType->isSuperTypeOf($leftType)->yes()) {
1204+
if ($leftType->isFloat()->yes()) {
12061205
return new ConstantFloatType(0.0);
12071206
}
12081207
return new ConstantIntegerType(0);

src/Type/ExponentiateHelper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ public static function exponentiate(Type $base, Type $exponent): Type
4646
}
4747

4848
// exponentiation of a float, stays a float
49-
$float = new FloatType();
50-
$isFloatBase = $float->isSuperTypeOf($base)->yes();
49+
$isFloatBase = $base->isFloat()->yes();
5150

5251
$isLooseZero = (new ConstantIntegerType(0))->isSuperTypeOf($exponent->toNumber());
5352
if ($isLooseZero->yes()) {

0 commit comments

Comments
 (0)