diff --git a/src/Type/Constant/ConstantFloatType.php b/src/Type/Constant/ConstantFloatType.php index e6a639fe2b..867898510a 100644 --- a/src/Type/Constant/ConstantFloatType.php +++ b/src/Type/Constant/ConstantFloatType.php @@ -11,8 +11,10 @@ use PHPStan\Type\Traits\ConstantScalarTypeTrait; use PHPStan\Type\Type; use PHPStan\Type\VerbosityLevel; +use function abs; use function is_finite; use function strpos; +use const PHP_FLOAT_EPSILON; /** @api */ class ConstantFloatType extends FloatType implements ConstantScalarType @@ -52,7 +54,7 @@ public function isSuperTypeOf(Type $type): TrinaryLogic { if ($type instanceof self) { if (!$this->equals($type)) { - if ($this->describe(VerbosityLevel::value()) === $type->describe(VerbosityLevel::value())) { + if (abs($this->value - $type->value) < PHP_FLOAT_EPSILON) { return TrinaryLogic::createMaybe(); }