Skip to content

Commit 95c0a75

Browse files
committed
- Fixed not checking class ancestors for the comparable trait
1 parent 7140eda commit 95c0a75

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Trait/ComparableTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ final public static function hasComparableTrait(object $object): bool
9292
$reflectionClass = $object instanceof \ReflectionClass ?
9393
$object :
9494
(new \ReflectionClass($object));
95+
$traits = $reflectionClass->getTraits();
96+
97+
while ($ancestor = $reflectionClass->getParentClass()) {
98+
$traits = array_merge($traits, $ancestor->getTraits());
99+
}
100+
101+
$traits = array_unique($traits);
95102

96103
return isset($reflectionClass->getTraits()[ComparableTrait::class]);
97104
}

0 commit comments

Comments
 (0)