From 29c35b584a948e9a3c90e2d56312069ce073e6e6 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 4 Apr 2024 09:29:39 +0200 Subject: [PATCH] Fix `ClosureType::equals()` --- src/Type/CallableType.php | 6 +++++- src/Type/ClosureType.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Type/CallableType.php b/src/Type/CallableType.php index d11fcf429..112309961 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 fbab59619..4b881eb20 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