Skip to content

Commit

Permalink
Faster ConstantFloatType->isSuperTypeOf(ConstantFloatType)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored and ondrejmirtes committed Dec 11, 2022
1 parent 17896e3 commit 94c841a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Type/Constant/ConstantFloatType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 94c841a

Please sign in to comment.