From 2ca85496cde37f825bd14f7e3548e2793ca90712 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 27 Apr 2025 15:37:55 +0200 Subject: [PATCH 1/3] Remove unneeded use statements --- Tests/Compiler/ResolveAutowireInlineAttributesPassTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Tests/Compiler/ResolveAutowireInlineAttributesPassTest.php b/Tests/Compiler/ResolveAutowireInlineAttributesPassTest.php index 58cb1cd38..a0d1ec50f 100644 --- a/Tests/Compiler/ResolveAutowireInlineAttributesPassTest.php +++ b/Tests/Compiler/ResolveAutowireInlineAttributesPassTest.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass; use Symfony\Component\DependencyInjection\Compiler\ResolveNamedArgumentsPass; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; require_once __DIR__.'/../Fixtures/includes/autowiring_classes.php'; From 42cb5ab4d4453bc4e04b123c57ec64c228d4e689 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 15 May 2025 15:18:10 +0200 Subject: [PATCH 2/3] [DependencyInjection] Fix missing binding for ServiceCollectionInterface when declaring a service subscriber --- Compiler/RegisterServiceSubscribersPass.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Compiler/RegisterServiceSubscribersPass.php b/Compiler/RegisterServiceSubscribersPass.php index 87470c398..89b822bc5 100644 --- a/Compiler/RegisterServiceSubscribersPass.php +++ b/Compiler/RegisterServiceSubscribersPass.php @@ -20,6 +20,7 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\TypedReference; use Symfony\Contracts\Service\Attribute\SubscribedService; +use Symfony\Contracts\Service\ServiceCollectionInterface; use Symfony\Contracts\Service\ServiceProviderInterface; use Symfony\Contracts\Service\ServiceSubscriberInterface; @@ -134,6 +135,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed $value->setBindings([ PsrContainerInterface::class => new BoundArgument($locatorRef, false), ServiceProviderInterface::class => new BoundArgument($locatorRef, false), + ServiceCollectionInterface::class => new BoundArgument($locatorRef, false), ] + $value->getBindings()); return parent::processValue($value); From 8cb11f833d1f5bfbb2df97dfc23c92b4d42c18d9 Mon Sep 17 00:00:00 2001 From: matlec Date: Wed, 14 May 2025 19:55:19 +0200 Subject: [PATCH 3/3] [DependencyInjection] Make `DefinitionErrorExceptionPass` consider `IGNORE_ON_UNINITIALIZED_REFERENCE` and `RUNTIME_EXCEPTION_ON_INVALID_REFERENCE` the same --- Compiler/DefinitionErrorExceptionPass.php | 5 ++++- Tests/Compiler/DefinitionErrorExceptionPassTest.php | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Compiler/DefinitionErrorExceptionPass.php b/Compiler/DefinitionErrorExceptionPass.php index b6a2cf907..204401cd2 100644 --- a/Compiler/DefinitionErrorExceptionPass.php +++ b/Compiler/DefinitionErrorExceptionPass.php @@ -65,7 +65,10 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed } if ($value instanceof Reference && $this->currentId !== $targetId = (string) $value) { - if (ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) { + if ( + ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior() + || ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior() + ) { $this->sourceReferences[$targetId][$this->currentId] ??= true; } else { $this->sourceReferences[$targetId][$this->currentId] = false; diff --git a/Tests/Compiler/DefinitionErrorExceptionPassTest.php b/Tests/Compiler/DefinitionErrorExceptionPassTest.php index 9ab5c27fc..5ed7be315 100644 --- a/Tests/Compiler/DefinitionErrorExceptionPassTest.php +++ b/Tests/Compiler/DefinitionErrorExceptionPassTest.php @@ -64,6 +64,9 @@ public function testSkipNestedErrors() $container->register('foo', 'stdClass') ->addArgument(new Reference('bar', ContainerBuilder::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE)); + $container->register('baz', 'stdClass') + ->addArgument(new Reference('bar', ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE)); + $pass = new DefinitionErrorExceptionPass(); $pass->process($container);