diff --git a/src/Type/CallableType.php b/src/Type/CallableType.php index d11fcf4290..112309961c 100644 --- a/src/Type/CallableType.php +++ b/src/Type/CallableType.php @@ -193,7 +193,11 @@ public function isAcceptedWithReasonBy(Type $acceptingType, bool $strictTypes): public function equals(Type $type): bool { - return $type instanceof self; + if (!$type instanceof self) { + return false; + } + + return $this->describe(VerbosityLevel::precise()) === $type->describe(VerbosityLevel::precise()); } public function describe(VerbosityLevel $level): string diff --git a/src/Type/ClosureType.php b/src/Type/ClosureType.php index fbab596190..4b881eb201 100644 --- a/src/Type/ClosureType.php +++ b/src/Type/ClosureType.php @@ -190,7 +190,7 @@ public function equals(Type $type): bool return false; } - return $this->returnType->equals($type->returnType); + return $this->describe(VerbosityLevel::precise()) === $type->describe(VerbosityLevel::precise()); } public function describe(VerbosityLevel $level): string