Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd1b617

Browse files
Fix support for PHP8 union types
1 parent 2121c55 commit dd1b617

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function registerContainerConfiguration(LoaderInterface $loader)
112112
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);
113113
}
114114

115-
$configuratorClass = $configureContainer->getNumberOfParameters() > 0 && ($type = $configureContainer->getParameters()[0]->getType()) && !$type->isBuiltin() ? $type->getName() : null;
115+
$configuratorClass = $configureContainer->getNumberOfParameters() > 0 && ($type = $configureContainer->getParameters()[0]->getType()) instanceof \ReflectionNamedType && !$type->isBuiltin() ? $type->getName() : null;
116116

117117
if ($configuratorClass && !is_a(ContainerConfigurator::class, $configuratorClass, true)) {
118118
$this->configureContainer($container, $loader);

src/Symfony/Component/DependencyInjection/Compiler/AutowireRequiredPropertiesPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function processValue($value, bool $isRoot = false)
4242

4343
$properties = $value->getProperties();
4444
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
45-
if (!$reflectionProperty->hasType()) {
45+
if (!($type = $reflectionProperty->getType()) instanceof \ReflectionNamedType) {
4646
continue;
4747
}
4848
if (false === $doc = $reflectionProperty->getDocComment()) {
@@ -55,7 +55,7 @@ protected function processValue($value, bool $isRoot = false)
5555
continue;
5656
}
5757

58-
$type = $reflectionProperty->getType()->getName();
58+
$type = $type->getName();
5959
$value->setProperty($name, new TypedReference($type, $type, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $name));
6060
}
6161

0 commit comments

Comments
 (0)