diff --git a/src/ReflectionMapper.php b/src/ReflectionMapper.php index b8c5d46..b1ba783 100644 --- a/src/ReflectionMapper.php +++ b/src/ReflectionMapper.php @@ -67,9 +67,13 @@ public function fromMethodReturnType(ReflectionMethod $method): Type ); } + assert($returnType instanceof ReflectionUnionType); + $types = []; foreach ($returnType->getTypes() as $type) { + assert($type instanceof ReflectionNamedType); + if ($type->getName() === 'self') { $types[] = ObjectType::fromName( $method->getDeclaringClass()->getName(),