Skip to content

Commit 37cc327

Browse files
Fix support for PHP8 union types
1 parent ddacd6a commit 37cc327

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ServiceLocatorTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function getProvidedServices(): array
8787
} else {
8888
$type = (new \ReflectionFunction($factory))->getReturnType();
8989

90-
$this->providedTypes[$name] = $type ? ($type->allowsNull() ? '?' : '').$type->getName() : '?';
90+
$this->providedTypes[$name] = $type ? ($type->allowsNull() ? '?' : '').($type instanceof \ReflectionNamedType ? $type->getName() : $type) : '?';
9191
}
9292
}
9393
}

ServiceSubscriberTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function getSubscribedServices(): array
4040
}
4141

4242
if (self::class === $method->getDeclaringClass()->name && ($returnType = $method->getReturnType()) && !$returnType->isBuiltin()) {
43-
$services[self::class.'::'.$method->name] = '?'.$returnType->getName();
43+
$services[self::class.'::'.$method->name] = '?'.($returnType instanceof \ReflectionNamedType ? $returnType->getName() : $type);
4444
}
4545
}
4646

0 commit comments

Comments
 (0)