Fix support for PHP8 union types

This commit is contained in:
Nicolas Grekas 2020-06-15 16:43:28 +02:00
parent 2121c55b02
commit dd1b61703f
2 changed files with 3 additions and 3 deletions

View File

@ -112,7 +112,7 @@ trait MicroKernelTrait
throw new \LogicException(sprintf('"%s" uses "%s", but does not implement the required method "protected function configureContainer(ContainerConfigurator $c): void".', get_debug_type($this), MicroKernelTrait::class), 0, $e);
}
$configuratorClass = $configureContainer->getNumberOfParameters() > 0 && ($type = $configureContainer->getParameters()[0]->getType()) && !$type->isBuiltin() ? $type->getName() : null;
$configuratorClass = $configureContainer->getNumberOfParameters() > 0 && ($type = $configureContainer->getParameters()[0]->getType()) instanceof \ReflectionNamedType && !$type->isBuiltin() ? $type->getName() : null;
if ($configuratorClass && !is_a(ContainerConfigurator::class, $configuratorClass, true)) {
$this->configureContainer($container, $loader);

View File

@ -42,7 +42,7 @@ class AutowireRequiredPropertiesPass extends AbstractRecursivePass
$properties = $value->getProperties();
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
if (!$reflectionProperty->hasType()) {
if (!($type = $reflectionProperty->getType()) instanceof \ReflectionNamedType) {
continue;
}
if (false === $doc = $reflectionProperty->getDocComment()) {
@ -55,7 +55,7 @@ class AutowireRequiredPropertiesPass extends AbstractRecursivePass
continue;
}
$type = $reflectionProperty->getType()->getName();
$type = $type->getName();
$value->setProperty($name, new TypedReference($type, $type, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $name));
}