From d6ea474bb4b9f4647d887af327298b3a22e3ffef Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 26 May 2023 08:58:25 +0200 Subject: [PATCH] [DependencyInjection] Revert "Use weak references in the container" --- .../LazyProxy/PhpDumper/ProxyDumper.php | 9 ++-- .../Fixtures/php/lazy_service_structure.txt | 13 ++--- .../PhpDumper/Fixtures/proxy-factory.php | 10 ++-- .../LazyProxy/PhpDumper/ProxyDumperTest.php | 1 - .../DependencyInjection/ContainerBuilder.php | 32 +++++------- .../DependencyInjection/Dumper/PhpDumper.php | 51 ++++--------------- .../Tests/Fixtures/php/autowire_closure.php | 10 +--- .../php/callable_adapter_consumer.php | 2 - .../Tests/Fixtures/php/closure.php | 10 +--- .../Tests/Fixtures/php/closure_proxy.php | 2 - ...er_class_constructor_without_arguments.php | 2 - ...s_with_mandatory_constructor_arguments.php | 2 - ...ss_with_optional_constructor_arguments.php | 2 - ...om_container_class_without_constructor.php | 2 - .../Fixtures/php/lazy_autowire_attribute.php | 6 +-- ...y_autowire_attribute_with_intersection.php | 6 +-- .../Tests/Fixtures/php/lazy_closure.php | 2 - .../Tests/Fixtures/php/services1-1.php | 2 - .../Tests/Fixtures/php/services1.php | 2 - .../Tests/Fixtures/php/services10.php | 2 - .../Fixtures/php/services10_as_files.txt | 10 +--- .../Tests/Fixtures/php/services12.php | 2 - .../Tests/Fixtures/php/services13.php | 2 - .../Tests/Fixtures/php/services19.php | 2 - .../Tests/Fixtures/php/services24.php | 2 - .../Tests/Fixtures/php/services26.php | 2 - .../Tests/Fixtures/php/services33.php | 2 - .../Tests/Fixtures/php/services8.php | 2 - .../Tests/Fixtures/php/services9_as_files.txt | 20 ++------ .../Tests/Fixtures/php/services9_compiled.php | 20 ++------ .../php/services9_inlined_factories.txt | 20 ++------ ...nlined_factories_with_tagged_iterrator.txt | 14 ++--- .../php/services9_lazy_inlined_factories.txt | 6 +-- .../Tests/Fixtures/php/services_adawson.php | 2 - .../php/services_almost_circular_private.php | 14 +---- .../php/services_almost_circular_public.php | 14 +---- .../Fixtures/php/services_array_params.php | 2 - .../Fixtures/php/services_base64_env.php | 2 - .../services_closure_argument_compiled.php | 10 +--- .../Tests/Fixtures/php/services_csv_env.php | 2 - .../php/services_current_factory_inlining.php | 2 - .../Fixtures/php/services_dedup_lazy.php | 18 ++----- .../Fixtures/php/services_deep_graph.php | 2 - .../Fixtures/php/services_default_env.php | 2 - .../php/services_deprecated_parameters.php | 2 - ...ervices_deprecated_parameters_as_files.txt | 2 - .../Tests/Fixtures/php/services_env_in_id.php | 2 - .../php/services_errored_definition.php | 20 ++------ .../Fixtures/php/services_inline_requires.php | 2 - .../Fixtures/php/services_inline_self_ref.php | 2 - .../Tests/Fixtures/php/services_json_env.php | 2 - .../Tests/Fixtures/php/services_locator.php | 38 ++------------ .../php/services_new_in_initializer.php | 2 - .../php/services_non_shared_duplicates.php | 5 +- .../Fixtures/php/services_non_shared_lazy.php | 4 -- .../php/services_non_shared_lazy_as_files.txt | 6 +-- .../php/services_non_shared_lazy_ghost.php | 6 +-- .../Fixtures/php/services_private_frozen.php | 2 - .../php/services_private_in_expression.php | 2 - .../php/services_query_string_env.php | 2 - .../Tests/Fixtures/php/services_rot13_env.php | 5 +- .../php/services_service_locator_argument.php | 5 +- .../Fixtures/php/services_subscriber.php | 5 +- .../Tests/Fixtures/php/services_tsantos.php | 2 - .../php/services_uninitialized_ref.php | 24 ++------- .../php/services_unsupported_characters.php | 2 - .../Tests/Fixtures/php/services_url_env.php | 2 - .../Tests/Fixtures/php/services_wither.php | 2 - .../php/services_wither_annotation.php | 2 - .../Fixtures/php/services_wither_lazy.php | 6 +-- .../php/services_wither_staticreturntype.php | 2 - .../Tests/Fixtures/php/static_constructor.php | 2 - 72 files changed, 80 insertions(+), 420 deletions(-) diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php index fd610860f534f..3747d896bccd9 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php @@ -61,16 +61,15 @@ public function getProxyFactoryCode(Definition $definition, string $id, string $ return <<createProxy('$proxyClass', static function () use (\$containerRef) { - return \\$proxyClass::staticProxyConstructor(static function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) use (\$containerRef) { - \$container = \$containerRef->get(); + $instantiation \$container->createProxy('$proxyClass', static fn () => \\$proxyClass::staticProxyConstructor( + static function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) use (\$container) { \$wrappedInstance = $factoryCode; \$proxy->setProxyInitializer(null); return true; - }); - }); + } + )); } diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt index 84995384157b6..ad7a803cb6e8a 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt @@ -5,19 +5,16 @@ class LazyServiceProjectServiceContainer extends Container {%a protected static function getFooService($container, $lazyLoad = true) { - $containerRef = $container->ref; - if (true === $lazyLoad) { - return $container->services['foo'] = $container->createProxy('stdClass_%s', static function () use ($containerRef) { - return %S\stdClass_%s(static function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($containerRef) { - $container = $containerRef->get(); - $wrappedInstance = self::getFooService($containerRef->get(), false); + return $container->services['foo'] = $container->createProxy('stdClass_%s', static fn () => %S\stdClass_%s( + static function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) { + $wrappedInstance = self::getFooService($container, false); $proxy->setProxyInitializer(null); return true; - }); - }); + } + )); } return new \stdClass(); diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/Fixtures/proxy-factory.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/Fixtures/proxy-factory.php index 12a7de3483761..c0399ae3340f3 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/Fixtures/proxy-factory.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/Fixtures/proxy-factory.php @@ -8,19 +8,17 @@ public function getFooService($lazyLoad = true) { $container = $this; - $containerRef = \WeakReference::create($this); if (true === $lazyLoad) { - return $container->privates['foo'] = $container->createProxy('SunnyInterface_1eff735', static function () use ($containerRef) { - return \SunnyInterface_1eff735::staticProxyConstructor(static function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($containerRef) { - $container = $containerRef->get(); + return $container->privates['foo'] = $container->createProxy('SunnyInterface_1eff735', static fn () => \SunnyInterface_1eff735::staticProxyConstructor( + static function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) { $wrappedInstance = $container->getFooService(false); $proxy->setProxyInitializer(null); return true; - }); - }); + } + )); } return new Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\DummyClass(); diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php index ea376464fc925..3652275c2bb65 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php @@ -130,7 +130,6 @@ public function testGetProxyFactoryCodeForInterface() public function getFooService(\$lazyLoad = true) { \$container = \$this; - \$containerRef = \\WeakReference::create(\$this); {$factory} return new {$class}(); } diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 44df682ebcb6f..a7a9c145aabac 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -141,8 +141,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ private array $removedBindingIds = []; - private \WeakReference $containerRef; - private const INTERNAL_TYPES = [ 'int' => true, 'float' => true, @@ -1064,9 +1062,8 @@ private function createService(Definition $definition, array &$inlineServices, b $callable[0] instanceof Reference || $callable[0] instanceof Definition && !isset($inlineServices[spl_object_hash($callable[0])]) )) { - $containerRef = $this->containerRef ??= \WeakReference::create($this); - $initializer = static function () use ($containerRef, $callable, &$inlineServices) { - return $containerRef->get()->doResolveServices($callable[0], $inlineServices); + $initializer = function () use ($callable, &$inlineServices) { + return $this->doResolveServices($callable[0], $inlineServices); }; $proxy = eval('return '.LazyClosure::getCode('$initializer', $callable, $definition, $this, $id).';'); @@ -1079,14 +1076,13 @@ private function createService(Definition $definition, array &$inlineServices, b if (true === $tryProxy && $definition->isLazy() && ['Closure', 'fromCallable'] !== $definition->getFactory() && !$tryProxy = !($proxy = $this->proxyInstantiator ??= new LazyServiceInstantiator()) || $proxy instanceof RealServiceInstantiator ) { - $containerRef = $this->containerRef ??= \WeakReference::create($this); $proxy = $proxy->instantiateProxy( $this, (clone $definition) ->setClass($class) ->setTags(($definition->hasTag('proxy') ? ['proxy' => $parameterBag->resolveValue($definition->getTag('proxy'))] : []) + $definition->getTags()), - $id, static function ($proxy = false) use ($containerRef, $definition, &$inlineServices, $id) { - return $containerRef->get()->createService($definition, $inlineServices, true, $id, $proxy); + $id, function ($proxy = false) use ($definition, &$inlineServices, $id) { + return $this->createService($definition, $inlineServices, true, $id, $proxy); } ); $this->shareService($definition, $proxy, $id, $inlineServices); @@ -1214,38 +1210,34 @@ private function doResolveServices(mixed $value, array &$inlineServices = [], bo $value[$k] = $this->doResolveServices($v, $inlineServices, $isConstructorArgument); } } elseif ($value instanceof ServiceClosureArgument) { - $containerRef = $this->containerRef ??= \WeakReference::create($this); $reference = $value->getValues()[0]; - $value = static fn () => $containerRef->get()->resolveServices($reference); + $value = fn () => $this->resolveServices($reference); } elseif ($value instanceof IteratorArgument) { - $containerRef = $this->containerRef ??= \WeakReference::create($this); - $value = new RewindableGenerator(static function () use ($containerRef, $value, &$inlineServices) { - $container = $containerRef->get(); + $value = new RewindableGenerator(function () use ($value, &$inlineServices) { foreach ($value->getValues() as $k => $v) { foreach (self::getServiceConditionals($v) as $s) { - if (!$container->has($s)) { + if (!$this->has($s)) { continue 2; } } foreach (self::getInitializedConditionals($v) as $s) { - if (!$container->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE, $inlineServices)) { + if (!$this->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE, $inlineServices)) { continue 2; } } - yield $k => $container->doResolveServices($v, $inlineServices); + yield $k => $this->doResolveServices($v, $inlineServices); } - }, static function () use ($containerRef, $value): int { - $container = $containerRef->get(); + }, function () use ($value): int { $count = 0; foreach ($value->getValues() as $v) { foreach (self::getServiceConditionals($v) as $s) { - if (!$container->has($s)) { + if (!$this->has($s)) { continue 2; } } foreach (self::getInitializedConditionals($v) as $s) { - if (!$container->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) { + if (!$this->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) { continue 2; } } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index a2964dd618d3f..ac477728badad 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -69,7 +69,7 @@ class PhpDumper extends Dumper private int $variableCount; private ?\SplObjectStorage $inlinedDefinitions = null; private ?array $serviceCalls = null; - private array $reservedVariables = ['instance', 'class', 'this', 'container', 'containerRef']; + private array $reservedVariables = ['instance', 'class', 'this', 'container']; private ExpressionLanguage $expressionLanguage; private ?string $targetDirRegex = null; private int $targetDirMaxMatches; @@ -87,7 +87,6 @@ class PhpDumper extends Dumper private array $singleUsePrivateIds = []; private array $preload = []; private bool $addGetService = false; - private bool $addContainerRef = false; private array $locatedIds = []; private string $serviceLocatorTag; private array $exportedVariables = []; @@ -247,8 +246,8 @@ public function dump(array $options = []): string|array if ($this->addGetService) { $code = preg_replace( - "/(\r?\n\r?\n public function __construct.+?\\{\r?\n) ++([^\r\n]++)/s", - "\n protected \Closure \$getService;$1 \$containerRef = $2\n \$this->getService = static function () use (\$containerRef) { return \$containerRef->get()->getService(...\\func_get_args()); };", + "/\r?\n\r?\n public function __construct.+?\\{\r?\n/s", + "\n protected \Closure \$getService;$0", $code, 1 ); @@ -862,7 +861,6 @@ private function addService(string $id, Definition $definition): array } else { $lazyInitialization = ''; } - $this->addContainerRef = false; $code = <<addContainerRef = true; - $factoryCode = $asFile ? sprintf('self::do($containerRef->get(), %s)', $lazyLoad) : sprintf('self::%s($containerRef->get(), %s)', $methodName, $lazyLoad); + $factoryCode = $asFile ? sprintf('self::do($container, %s)', $lazyLoad) : sprintf('self::%s($container, %s)', $methodName, $lazyLoad); $code .= $this->getProxyDumper()->getProxyFactoryCode($definition, $id, $factoryCode); } @@ -945,9 +942,8 @@ protected static function {$methodName}(\$container$lazyInitialization) if (!$isProxyCandidate && !$definition->isShared()) { $c = implode("\n", array_map(fn ($line) => $line ? ' '.$line : $line, explode("\n", $c))); $lazyloadInitialization = $definition->isLazy() ? ', $lazyLoad = true' : ''; - $useContainerRef = $this->addContainerRef ? ' use ($containerRef)' : ''; - $c = sprintf(" %s = function (\$container%s)%s {\n%s };\n\n return %1\$s(\$container);\n", $factory, $lazyloadInitialization, $useContainerRef, $c); + $c = sprintf(" %s = function (\$container%s) {\n%s };\n\n return %1\$s(\$container);\n", $factory, $lazyloadInitialization, $c); } $code .= $c; @@ -958,8 +954,6 @@ protected static function {$methodName}(\$container$lazyInitialization) $this->definitionVariables = $this->inlinedDefinitions = null; $this->referenceVariables = $this->serviceCalls = null; - $code = preg_replace('/%container_ref%/', $this->addContainerRef ? "\n \$containerRef = \$container->ref;\n" : '', $code, 1); - return [$file, $code]; } @@ -1196,12 +1190,7 @@ private function addNewInstance(Definition $definition, string $return = '', str $callable[0] instanceof Reference || ($callable[0] instanceof Definition && !$this->definitionVariables->contains($callable[0])) )) { - if (str_contains($initializer = $this->dumpValue($callable[0]), '$container')) { - $this->addContainerRef = true; - $initializer = sprintf('function () use ($containerRef) { $container = $containerRef->get(); return %s; }', $initializer); - } else { - $initializer = 'fn () => '.$initializer; - } + $initializer = 'fn () => '.$this->dumpValue($callable[0]); return $return.LazyClosure::getCode($initializer, $callable, $definition, $this->container, $id).$tail; } @@ -1268,11 +1257,9 @@ class $class extends $baseClass private const DEPRECATED_PARAMETERS = []; protected \$parameters = []; - protected readonly \WeakReference \$ref; public function __construct() { - \$this->ref = \WeakReference::create(\$this); EOF; $code = str_replace(" private const DEPRECATED_PARAMETERS = [];\n\n", $this->addDeprecatedParameters(), $code); @@ -1853,12 +1840,6 @@ private function dumpValue(mixed $value, bool $interpolate = true): string $attribute = sprintf('#[\Closure(%s)] ', $attribute); } - if (str_contains($code, '$container')) { - $this->addContainerRef = true; - - return sprintf("%sfunction () use (\$containerRef)%s {\n \$container = \$containerRef->get();\n\n return %s;\n }", $attribute, $returnedType, $code); - } - return sprintf('%sfn ()%s => %s', $attribute, $returnedType, $code); } @@ -1867,15 +1848,8 @@ private function dumpValue(mixed $value, bool $interpolate = true): string return 'new RewindableGenerator(fn () => new \EmptyIterator(), 0)'; } - $this->addContainerRef = true; - $code = []; - $code[] = 'new RewindableGenerator(function () use ($containerRef) {'; - $code[] = ' $container = $containerRef->get();'; - $code[] = ''; - - $countCode = []; - $countCode[] = 'function () use ($containerRef) {'; + $code[] = 'new RewindableGenerator(function () use ($container) {'; $operands = [0]; foreach ($values as $k => $v) { @@ -1888,12 +1862,7 @@ private function dumpValue(mixed $value, bool $interpolate = true): string } } - $countCode[] = ' $container = $containerRef->get();'; - $countCode[] = ''; - $countCode[] = sprintf(' return %s;', implode(' + ', $operands)); - $countCode[] = ' }'; - - $code[] = sprintf(' }, %s)', \count($operands) > 1 ? implode("\n", $countCode) : $operands[0]); + $code[] = sprintf(' }, %s)', \count($operands) > 1 ? 'fn () => '.implode(' + ', $operands) : $operands[0]); return implode("\n", $code); } @@ -1925,7 +1894,7 @@ private function dumpValue(mixed $value, bool $interpolate = true): string } $this->addGetService = true; - return sprintf('new \%s($container->getService, [%s%s], [%s%s])', ServiceLocator::class, $serviceMap, $serviceMap ? "\n " : '', $serviceTypes, $serviceTypes ? "\n " : ''); + return sprintf('new \%s($container->getService ??= $container->getService(...), [%s%s], [%s%s])', ServiceLocator::class, $serviceMap, $serviceMap ? "\n " : '', $serviceTypes, $serviceTypes ? "\n " : ''); } } finally { [$this->definitionVariables, $this->referenceVariables] = $scope; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/autowire_closure.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/autowire_closure.php index d5c461e64f80d..cd0c1e8be7b9f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/autowire_closure.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/autowire_closure.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_Autowire_Closure extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'bar' => 'getBarService', @@ -48,13 +46,7 @@ public function isCompiled(): bool */ protected static function getBarService($container) { - $containerRef = $container->ref; - - return $container->services['bar'] = new \Symfony\Component\DependencyInjection\Tests\Dumper\LazyClosureConsumer(#[\Closure(name: 'foo', class: 'Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo')] function () use ($containerRef) { - $container = $containerRef->get(); - - return ($container->services['foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()); - }, ($container->services['baz'] ?? self::getBazService($container)), ($container->services['foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo())->cloneFoo(...), ($container->services['my_callable'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\MyCallable())->__invoke(...)); + return $container->services['bar'] = new \Symfony\Component\DependencyInjection\Tests\Dumper\LazyClosureConsumer(#[\Closure(name: 'foo', class: 'Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo')] fn () => ($container->services['foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()), ($container->services['baz'] ?? self::getBazService($container)), ($container->services['foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo())->cloneFoo(...), ($container->services['my_callable'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\MyCallable())->__invoke(...)); } /** diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/callable_adapter_consumer.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/callable_adapter_consumer.php index 0a32e23ae9c32..ccd8d2e0bf63b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/callable_adapter_consumer.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/callable_adapter_consumer.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_Callable_Adapter_Consumer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'bar' => 'getBarService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure.php index 1444190c5b645..287eb9e3e94e9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'closure' => 'getClosureService', @@ -64,12 +62,6 @@ protected static function getClosureService($container) */ protected static function getClosureOfServiceClosureService($container) { - $containerRef = $container->ref; - - return $container->services['closure_of_service_closure'] = #[\Closure(name: 'bar2', class: 'stdClass')] function () use ($containerRef) { - $container = $containerRef->get(); - - return ($container->privates['bar2'] ??= new \stdClass()); - }; + return $container->services['closure_of_service_closure'] = #[\Closure(name: 'bar2', class: 'stdClass')] fn () => ($container->privates['bar2'] ??= new \stdClass()); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure_proxy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure_proxy.php index 94ca615c4ddd4..2bef92604d3a9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure_proxy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure_proxy.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_Closure_Proxy extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'closure_proxy' => 'getClosureProxyService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php index 3745b291db52f..8bdda6b602b9b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php @@ -17,11 +17,9 @@ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithoutArgumentsContainer { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); parent::__construct(); $this->parameterBag = null; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php index 482316c0ff1a0..85b8bc6dae27d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php @@ -17,11 +17,9 @@ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithMandatoryArgumentsContainer { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->aliases = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php index adb80f267dd0b..6aeea149719b9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php @@ -17,11 +17,9 @@ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithOptionalArgumentsContainer { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); parent::__construct(); $this->parameterBag = null; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php index ff3750b0847cb..ee47766101427 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php @@ -17,11 +17,9 @@ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\NoConstructorContainer { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->aliases = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute.php index a82d5bc1e9b67..8134075865d25 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_Lazy_Autowire_Attribute extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'bar' => 'getBarService', @@ -79,10 +77,8 @@ protected static function getFooService($container) */ protected static function getFoo2Service($container, $lazyLoad = true) { - $containerRef = $container->ref; - if (true === $lazyLoad) { - return $container->privates['.lazy.Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo'] = $container->createProxy('FooProxy4048957', static fn () => \FooProxy4048957::createLazyProxy(static fn () => self::getFoo2Service($containerRef->get(), false))); + return $container->privates['.lazy.Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo'] = $container->createProxy('FooProxy4048957', static fn () => \FooProxy4048957::createLazyProxy(static fn () => self::getFoo2Service($container, false))); } return ($container->services['foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute_with_intersection.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute_with_intersection.php index 4bf955ac2447a..8dc0eb50e62fb 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute_with_intersection.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute_with_intersection.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'foo' => 'getFooService', @@ -73,10 +71,8 @@ protected static function getFooService($container) */ protected static function get_Lazy_Foo_GDmfketService($container, $lazyLoad = true) { - $containerRef = $container->ref; - if (true === $lazyLoad) { - return $container->privates['.lazy.foo.gDmfket'] = $container->createProxy('objectProxy8ac8e9a', static fn () => \objectProxy8ac8e9a::createLazyProxy(static fn () => self::get_Lazy_Foo_GDmfketService($containerRef->get(), false))); + return $container->privates['.lazy.foo.gDmfket'] = $container->createProxy('objectProxy8ac8e9a', static fn () => \objectProxy8ac8e9a::createLazyProxy(static fn () => self::get_Lazy_Foo_GDmfketService($container, false))); } return ($container->services['foo'] ?? self::getFooService($container)); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_closure.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_closure.php index e7783b6f90a1a..3623366544fa0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_closure.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_closure.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_Lazy_Closure extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'closure' => 'getClosureService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php index 98ea8c666ba36..da000bf8e41e3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php @@ -17,11 +17,9 @@ class Container extends \Symfony\Component\DependencyInjection\Dump\AbstractContainer { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->aliases = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php index a1398a57c976d..4cec1eb29b06e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->aliases = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index a98229eb58979..95bf7aa4df39f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10_as_files.txt index cd63684ca9f3a..25d0b3257f0d9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10_as_files.txt @@ -27,15 +27,9 @@ class getClosureService extends ProjectServiceContainer */ public static function do($container, $lazyLoad = true) { - $containerRef = $container->ref; - $container->services['closure'] = $instance = new \stdClass(); - $instance->closures = [#[\Closure(name: 'foo', class: 'FooClass')] function () use ($containerRef): ?\stdClass { - $container = $containerRef->get(); - - return ($container->services['foo'] ?? null); - }]; + $instance->closures = [#[\Closure(name: 'foo', class: 'FooClass')] fn (): ?\stdClass => ($container->services['foo'] ?? null)]; return $instance; } @@ -61,11 +55,9 @@ class ProjectServiceContainer extends Container { protected $targetDir; protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct(private array $buildParameters = [], protected string $containerDir = __DIR__) { - $this->ref = \WeakReference::create($this); $this->targetDir = \dirname($containerDir); $this->services = $this->privates = []; $this->methodMap = [ diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index d2a31115d1187..be77a31954e4b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php index de0550de9b79c..9657c007ab03b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'bar' => 'getBarService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php index 328a9180ac5ab..03cb9b5ba5ee5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php index b2bfd9e0865af..693c1c5a1619f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'foo' => 'getFooService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php index ad424a8e467a6..c434b19d9d2fe 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php index eed5f3f6270dd..7d5f9e78999a0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'Bar\\Foo' => 'getFooService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php index 1625966d2d528..65aded752be4e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt index 9528de3651608..c3fddf9e67175 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt @@ -361,11 +361,7 @@ class getLazyContextService extends ProjectServiceContainer */ public static function do($container, $lazyLoad = true) { - $containerRef = $container->ref; - - return $container->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () use ($container) { yield 'k1' => ($container->services['foo.baz'] ?? $container->load('getFoo_BazService')); yield 'k2' => $container; }, 2), new RewindableGenerator(fn () => new \EmptyIterator(), 0)); @@ -383,11 +379,7 @@ class getLazyContextIgnoreInvalidRefService extends ProjectServiceContainer */ public static function do($container, $lazyLoad = true) { - $containerRef = $container->ref; - - return $container->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () use ($container) { yield 0 => ($container->services['foo.baz'] ?? $container->load('getFoo_BazService')); }, 1), new RewindableGenerator(fn () => new \EmptyIterator(), 0)); } @@ -515,11 +507,7 @@ class getTaggedIteratorService extends ProjectServiceContainer */ public static function do($container, $lazyLoad = true) { - $containerRef = $container->ref; - - return $container->services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () use ($container) { yield 0 => ($container->services['foo'] ?? $container->load('getFooService')); yield 1 => ($container->privates['tagged_iterator_foo'] ??= new \Bar()); }, 2)); @@ -561,11 +549,9 @@ class ProjectServiceContainer extends Container { protected $targetDir; protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct(private array $buildParameters = [], protected string $containerDir = __DIR__) { - $this->ref = \WeakReference::create($this); $this->targetDir = \dirname($containerDir); $this->parameters = $this->getDefaultParameters(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 765cc4a54b587..8161543a7d715 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; @@ -330,11 +328,7 @@ protected static function getFooWithInlineService($container) */ protected static function getLazyContextService($container) { - $containerRef = $container->ref; - - return $container->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () use ($container) { yield 'k1' => ($container->services['foo.baz'] ?? self::getFoo_BazService($container)); yield 'k2' => $container; }, 2), new RewindableGenerator(fn () => new \EmptyIterator(), 0)); @@ -347,11 +341,7 @@ protected static function getLazyContextService($container) */ protected static function getLazyContextIgnoreInvalidRefService($container) { - $containerRef = $container->ref; - - return $container->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () use ($container) { yield 0 => ($container->services['foo.baz'] ?? self::getFoo_BazService($container)); }, 1), new RewindableGenerator(fn () => new \EmptyIterator(), 0)); } @@ -428,11 +418,7 @@ protected static function getServiceFromStaticMethodService($container) */ protected static function getTaggedIteratorService($container) { - $containerRef = $container->ref; - - return $container->services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () use ($container) { yield 0 => ($container->services['foo'] ?? self::getFooService($container)); yield 1 => ($container->privates['tagged_iterator_foo'] ??= new \Bar()); }, 2)); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories.txt index c83530a598fe4..4fcb352ade2cc 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories.txt @@ -38,11 +38,9 @@ class ProjectServiceContainer extends Container { protected $targetDir; protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct(private array $buildParameters = [], protected string $containerDir = __DIR__) { - $this->ref = \WeakReference::create($this); $this->targetDir = \dirname($containerDir); $this->parameters = $this->getDefaultParameters(); @@ -351,13 +349,9 @@ class ProjectServiceContainer extends Container */ protected static function getLazyContextService($container) { - $containerRef = $container->ref; - include_once $container->targetDir.''.'/Fixtures/includes/classes.php'; - return $container->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () use ($container) { yield 'k1' => ($container->services['foo.baz'] ?? self::getFoo_BazService($container)); yield 'k2' => $container; }, 2), new RewindableGenerator(fn () => new \EmptyIterator(), 0)); @@ -370,13 +364,9 @@ class ProjectServiceContainer extends Container */ protected static function getLazyContextIgnoreInvalidRefService($container) { - $containerRef = $container->ref; - include_once $container->targetDir.''.'/Fixtures/includes/classes.php'; - return $container->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () use ($container) { yield 0 => ($container->services['foo.baz'] ?? self::getFoo_BazService($container)); }, 1), new RewindableGenerator(fn () => new \EmptyIterator(), 0)); } @@ -469,11 +459,7 @@ class ProjectServiceContainer extends Container */ protected static function getTaggedIteratorService($container) { - $containerRef = $container->ref; - - return $container->services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () use ($container) { yield 0 => ($container->services['foo'] ?? self::getFooService($container)); yield 1 => ($container->privates['tagged_iterator_foo'] ??= new \Bar()); }, 2)); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories_with_tagged_iterrator.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories_with_tagged_iterrator.txt index cd0358301c712..61ea67f6b9521 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories_with_tagged_iterrator.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories_with_tagged_iterrator.txt @@ -29,11 +29,9 @@ class ProjectServiceContainer extends Container { protected $targetDir; protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct(private array $buildParameters = [], protected string $containerDir = __DIR__) { - $this->ref = \WeakReference::create($this); $this->targetDir = \dirname($containerDir); $this->services = $this->privates = []; $this->methodMap = [ @@ -65,14 +63,10 @@ class ProjectServiceContainer extends Container */ protected static function getFooService($container) { - $containerRef = $container->ref; - - $container->factories['foo'] = function ($container) use ($containerRef) { + $container->factories['foo'] = function ($container) { $instance = new \Symfony\Component\DependencyInjection\Tests\Dumper\FooClass(); - $instance->setOtherInstances(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + $instance->setOtherInstances(new RewindableGenerator(function () use ($container) { yield 0 => ($container->privates['Bar'] ??= new \Bar()); yield 1 => ($container->privates['stdClass'] ??= new \stdClass()); }, 2)); @@ -123,8 +117,8 @@ if (!\class_exists(ProjectServiceContainer::class, false)) { return new \Container%s\ProjectServiceContainer([ 'container.build_hash' => '%s', - 'container.build_id' => '3f6e2bc2', - 'container.build_time' => 1563381341, + 'container.build_id' => '%s', + 'container.build_time' => %d, ], __DIR__.\DIRECTORY_SEPARATOR.'Container%s'); ) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt index 59aa77a6e150e..cc147d95abe10 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt @@ -33,11 +33,9 @@ class ProjectServiceContainer extends Container { protected $targetDir; protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct(private array $buildParameters = [], protected string $containerDir = __DIR__) { - $this->ref = \WeakReference::create($this); $this->targetDir = \dirname($containerDir); $this->parameters = $this->getDefaultParameters(); @@ -75,10 +73,8 @@ class ProjectServiceContainer extends Container */ protected static function getLazyFooService($container, $lazyLoad = true) { - $containerRef = $container->ref; - if (true === $lazyLoad) { - return $container->services['lazy_foo'] = $container->createProxy('FooClassGhostEe53b95', static fn () => \FooClassGhostEe53b95::createLazyGhost(static fn ($proxy) => self::getLazyFooService($containerRef->get(), $proxy))); + return $container->services['lazy_foo'] = $container->createProxy('FooClassGhostEe53b95', static fn () => \FooClassGhostEe53b95::createLazyGhost(static fn ($proxy) => self::getLazyFooService($container, $proxy))); } include_once $container->targetDir.''.'/Fixtures/includes/foo_lazy.php'; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_adawson.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_adawson.php index 052eef5504a08..ae05d67a54999 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_adawson.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_adawson.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'App\\Bus' => 'getBusService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php index c1b00ed757b48..0a9c519c8e69c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Private extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'bar2' => 'getBar2Service', @@ -198,12 +196,8 @@ protected static function getConnection2Service($container) */ protected static function getDoctrine_EntityManagerService($container) { - $containerRef = $container->ref; - $a = new \stdClass(); - $a->resolver = new \stdClass(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + $a->resolver = new \stdClass(new RewindableGenerator(function () use ($container) { yield 0 => ($container->privates['doctrine.listener'] ?? self::getDoctrine_ListenerService($container)); }, 1)); $a->flag = 'ok'; @@ -526,11 +520,7 @@ protected static function getLevel5Service($container) */ protected static function getMailer_TransportService($container) { - $containerRef = $container->ref; - - return $container->privates['mailer.transport'] = (new \FactoryCircular(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->privates['mailer.transport'] = (new \FactoryCircular(new RewindableGenerator(function () use ($container) { yield 0 => ($container->privates['mailer.transport_factory.amazon'] ?? self::getMailer_TransportFactory_AmazonService($container)); yield 1 => self::getMailerInline_TransportFactory_AmazonService($container); }, 2)))->create(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php index f17a8aaa1bbeb..2250e860264dc 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'bar' => 'getBarService', @@ -273,11 +271,7 @@ protected static function getDispatcher2Service($container, $lazyLoad = true) */ protected static function getDoctrine_EntityListenerResolverService($container) { - $containerRef = $container->ref; - - return $container->services['doctrine.entity_listener_resolver'] = new \stdClass(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['doctrine.entity_listener_resolver'] = new \stdClass(new RewindableGenerator(function () use ($container) { yield 0 => ($container->services['doctrine.listener'] ?? self::getDoctrine_ListenerService($container)); }, 1)); } @@ -526,11 +520,7 @@ protected static function getMailer_TransportService($container) */ protected static function getMailer_TransportFactoryService($container) { - $containerRef = $container->ref; - - return $container->services['mailer.transport_factory'] = new \FactoryCircular(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['mailer.transport_factory'] = new \FactoryCircular(new RewindableGenerator(function () use ($container) { yield 0 => ($container->services['mailer.transport_factory.amazon'] ?? self::getMailer_TransportFactory_AmazonService($container)); yield 1 => ($container->services['mailer_inline.transport_factory.amazon'] ?? self::getMailerInline_TransportFactory_AmazonService($container)); }, 2)); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php index 41e1be5a93b20..97979327b7e9b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php index 8f64e9292ca0e..021599934834c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_Base64Parameters extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_closure_argument_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_closure_argument_compiled.php index a9dcc3ceb10c3..acd87be99655e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_closure_argument_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_closure_argument_compiled.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'foo' => 'getFooService', @@ -57,13 +55,7 @@ protected static function getFooService($container) */ protected static function getServiceClosureService($container) { - $containerRef = $container->ref; - - return $container->services['service_closure'] = new \Bar(#[\Closure(name: 'foo', class: 'Foo')] function () use ($containerRef) { - $container = $containerRef->get(); - - return ($container->services['foo'] ??= new \Foo()); - }); + return $container->services['service_closure'] = new \Bar(#[\Closure(name: 'foo', class: 'Foo')] fn () => ($container->services['foo'] ??= new \Foo())); } /** diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php index dc12622f95c41..2a48fdb329cc4 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_CsvParameters extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_current_factory_inlining.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_current_factory_inlining.php index 4c641bc877871..98d431ce4a5b1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_current_factory_inlining.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_current_factory_inlining.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Service_CurrentFactoryInlining extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'inlined_current' => 'getInlinedCurrentService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy.php index 6c2481a68dc20..006820f527fd8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'bar' => 'getBarService', @@ -53,10 +51,8 @@ protected function createProxy($class, \Closure $factory) */ protected static function getBarService($container, $lazyLoad = true) { - $containerRef = $container->ref; - if (true === $lazyLoad) { - return $container->services['bar'] = $container->createProxy('stdClassGhost2fc7938', static fn () => \stdClassGhost2fc7938::createLazyGhost(static fn ($proxy) => self::getBarService($containerRef->get(), $proxy))); + return $container->services['bar'] = $container->createProxy('stdClassGhost2fc7938', static fn () => \stdClassGhost2fc7938::createLazyGhost(static fn ($proxy) => self::getBarService($container, $proxy))); } return $lazyLoad; @@ -69,10 +65,8 @@ protected static function getBarService($container, $lazyLoad = true) */ protected static function getBazService($container, $lazyLoad = true) { - $containerRef = $container->ref; - if (true === $lazyLoad) { - return $container->services['baz'] = $container->createProxy('stdClassProxy2fc7938', static fn () => \stdClassProxy2fc7938::createLazyProxy(static fn () => self::getBazService($containerRef->get(), false))); + return $container->services['baz'] = $container->createProxy('stdClassProxy2fc7938', static fn () => \stdClassProxy2fc7938::createLazyProxy(static fn () => self::getBazService($container, false))); } return \foo_bar(); @@ -85,10 +79,8 @@ protected static function getBazService($container, $lazyLoad = true) */ protected static function getBuzService($container, $lazyLoad = true) { - $containerRef = $container->ref; - if (true === $lazyLoad) { - return $container->services['buz'] = $container->createProxy('stdClassProxy2fc7938', static fn () => \stdClassProxy2fc7938::createLazyProxy(static fn () => self::getBuzService($containerRef->get(), false))); + return $container->services['buz'] = $container->createProxy('stdClassProxy2fc7938', static fn () => \stdClassProxy2fc7938::createLazyProxy(static fn () => self::getBuzService($container, false))); } return \foo_bar(); @@ -101,10 +93,8 @@ protected static function getBuzService($container, $lazyLoad = true) */ protected static function getFooService($container, $lazyLoad = true) { - $containerRef = $container->ref; - if (true === $lazyLoad) { - return $container->services['foo'] = $container->createProxy('stdClassGhost2fc7938', static fn () => \stdClassGhost2fc7938::createLazyGhost(static fn ($proxy) => self::getFooService($containerRef->get(), $proxy))); + return $container->services['foo'] = $container->createProxy('stdClassGhost2fc7938', static fn () => \stdClassGhost2fc7938::createLazyGhost(static fn ($proxy) => self::getFooService($container, $proxy))); } return $lazyLoad; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php index 4b6c1e3936440..9c22c5f9e7ae1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_Deep_Graph extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'bar' => 'getBarService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php index 39e0c7f7570b1..292f0d6fed825 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_DefaultParameters extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deprecated_parameters.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deprecated_parameters.php index 2ed3522f6f578..90a79cba63a2a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deprecated_parameters.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deprecated_parameters.php @@ -19,11 +19,9 @@ class ProjectServiceContainer extends Container ]; protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deprecated_parameters_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deprecated_parameters_as_files.txt index 5081cf415d0cc..98476a4c1a171 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deprecated_parameters_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deprecated_parameters_as_files.txt @@ -47,11 +47,9 @@ class ProjectServiceContainer extends Container protected $targetDir; protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct(private array $buildParameters = [], protected string $containerDir = __DIR__) { - $this->ref = \WeakReference::create($this); $this->targetDir = \dirname($containerDir); $this->parameters = $this->getDefaultParameters(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php index 3673a1cdfe1fe..589d2e81f04b2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php index b6595bb34a7b7..7433eed182639 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Errored_Definition extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; @@ -330,11 +328,7 @@ protected static function getFooWithInlineService($container) */ protected static function getLazyContextService($container) { - $containerRef = $container->ref; - - return $container->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () use ($container) { yield 'k1' => ($container->services['foo.baz'] ?? self::getFoo_BazService($container)); yield 'k2' => $container; }, 2), new RewindableGenerator(fn () => new \EmptyIterator(), 0)); @@ -347,11 +341,7 @@ protected static function getLazyContextService($container) */ protected static function getLazyContextIgnoreInvalidRefService($container) { - $containerRef = $container->ref; - - return $container->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () use ($container) { yield 0 => ($container->services['foo.baz'] ?? self::getFoo_BazService($container)); }, 1), new RewindableGenerator(fn () => new \EmptyIterator(), 0)); } @@ -428,11 +418,7 @@ protected static function getServiceFromStaticMethodService($container) */ protected static function getTaggedIteratorService($container) { - $containerRef = $container->ref; - - return $container->services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + return $container->services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () use ($container) { yield 0 => ($container->services['foo'] ?? self::getFooService($container)); yield 1 => ($container->privates['tagged_iterator_foo'] ??= new \Bar()); }, 2)); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php index f184f64dca43a..cac95d6d6c1a8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\ParentNotExists' => 'getParentNotExistsService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_self_ref.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_self_ref.php index 4ccee1b0c2bc4..265dbe3741730 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_self_ref.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_self_ref.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_Inline_Self_Ref extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'App\\Foo' => 'getFooService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php index 35aa89cd07e72..2fd5aa4c3a958 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_JsonParameters extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php index 793dd0e84b173..2510e647d24c3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'bar_service' => 'getBarServiceService', @@ -72,17 +70,7 @@ protected static function getBarServiceService($container) */ protected static function getFooServiceService($container) { - $containerRef = $container->ref; - - return $container->services['foo_service'] = new \Symfony\Component\DependencyInjection\ServiceLocator(['bar' => #[\Closure(name: 'bar_service', class: 'stdClass')] function () use ($containerRef) { - $container = $containerRef->get(); - - return ($container->services['bar_service'] ?? self::getBarServiceService($container)); - }, 'baz' => #[\Closure(name: 'baz_service', class: 'stdClass')] function () use ($containerRef): \stdClass { - $container = $containerRef->get(); - - return ($container->privates['baz_service'] ??= new \stdClass()); - }, 'nil' => fn () => NULL]); + return $container->services['foo_service'] = new \Symfony\Component\DependencyInjection\ServiceLocator(['bar' => #[\Closure(name: 'bar_service', class: 'stdClass')] fn () => ($container->services['bar_service'] ?? self::getBarServiceService($container)), 'baz' => #[\Closure(name: 'baz_service', class: 'stdClass')] fn (): \stdClass => ($container->privates['baz_service'] ??= new \stdClass()), 'nil' => fn () => NULL]); } /** @@ -122,13 +110,7 @@ protected static function getTranslator_Loader3Service($container) */ protected static function getTranslator1Service($container) { - $containerRef = $container->ref; - - return $container->services['translator_1'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(['translator.loader_1' => #[\Closure(name: 'translator.loader_1', class: 'stdClass')] function () use ($containerRef) { - $container = $containerRef->get(); - - return ($container->services['translator.loader_1'] ??= new \stdClass()); - }])); + return $container->services['translator_1'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(['translator.loader_1' => #[\Closure(name: 'translator.loader_1', class: 'stdClass')] fn () => ($container->services['translator.loader_1'] ??= new \stdClass())])); } /** @@ -138,13 +120,7 @@ protected static function getTranslator1Service($container) */ protected static function getTranslator2Service($container) { - $containerRef = $container->ref; - - $container->services['translator_2'] = $instance = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(['translator.loader_2' => #[\Closure(name: 'translator.loader_2', class: 'stdClass')] function () use ($containerRef) { - $container = $containerRef->get(); - - return ($container->services['translator.loader_2'] ??= new \stdClass()); - }])); + $container->services['translator_2'] = $instance = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(['translator.loader_2' => #[\Closure(name: 'translator.loader_2', class: 'stdClass')] fn () => ($container->services['translator.loader_2'] ??= new \stdClass())])); $instance->addResource('db', ($container->services['translator.loader_2'] ??= new \stdClass()), 'nl'); @@ -158,13 +134,7 @@ protected static function getTranslator2Service($container) */ protected static function getTranslator3Service($container) { - $containerRef = $container->ref; - - $container->services['translator_3'] = $instance = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(['translator.loader_3' => #[\Closure(name: 'translator.loader_3', class: 'stdClass')] function () use ($containerRef) { - $container = $containerRef->get(); - - return ($container->services['translator.loader_3'] ??= new \stdClass()); - }])); + $container->services['translator_3'] = $instance = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(['translator.loader_3' => #[\Closure(name: 'translator.loader_3', class: 'stdClass')] fn () => ($container->services['translator.loader_3'] ??= new \stdClass())])); $a = ($container->services['translator.loader_3'] ??= new \stdClass()); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_new_in_initializer.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_new_in_initializer.php index 238fabbae8c6f..7a2ebe901adb1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_new_in_initializer.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_new_in_initializer.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'foo' => 'getFooService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_duplicates.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_duplicates.php index 30f5075304d2f..d3685cf9d9e00 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_duplicates.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_duplicates.php @@ -15,13 +15,10 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; protected \Closure $getService; public function __construct() { - $containerRef = $this->ref = \WeakReference::create($this); - $this->getService = static function () use ($containerRef) { return $containerRef->get()->getService(...\func_get_args()); }; $this->services = $this->privates = []; $this->methodMap = [ 'bar' => 'getBarService', @@ -66,7 +63,7 @@ protected static function getBarService($container) */ protected static function getBazService($container) { - return $container->services['baz'] = new \stdClass(new \Symfony\Component\DependencyInjection\Argument\ServiceLocator($container->getService, [ + return $container->services['baz'] = new \stdClass(new \Symfony\Component\DependencyInjection\Argument\ServiceLocator($container->getService ??= $container->getService(...), [ 'foo' => [false, 'foo', 'getFooService', false], ], [ 'foo' => '?', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy.php index d00f210156e34..f584bef6b97cc 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'bar' => 'getBarService', @@ -67,8 +65,6 @@ protected static function getBarService($container) */ protected static function getFooService($container, $lazyLoad = true) { - $containerRef = $container->ref; - $container->factories['service_container']['foo'] ??= self::getFooService(...); // lazy factory for stdClass diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt index 8cd2a9e190e70..ec0f4d6709c07 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt @@ -19,12 +19,10 @@ class getNonSharedFooService extends ProjectServiceContainer */ public static function do($container, $lazyLoad = true) { - $containerRef = $container->ref; - $container->factories['non_shared_foo'] ??= self::do(...); if (true === $lazyLoad) { - return $container->createProxy('FooLazyClassGhost0fc418d', static fn () => \FooLazyClassGhost0fc418d::createLazyGhost(static fn ($proxy) => self::do($containerRef->get(), $proxy))); + return $container->createProxy('FooLazyClassGhost0fc418d', static fn () => \FooLazyClassGhost0fc418d::createLazyGhost(static fn ($proxy) => self::do($container, $proxy))); } static $include = true; @@ -79,11 +77,9 @@ class ProjectServiceContainer extends Container { protected $targetDir; protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct(private array $buildParameters = [], protected string $containerDir = __DIR__) { - $this->ref = \WeakReference::create($this); $this->targetDir = \dirname($containerDir); $this->services = $this->privates = []; $this->fileMap = [ diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_ghost.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_ghost.php index 1a32c1974f7af..0082641c56ed0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_ghost.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_ghost.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'bar' => 'getBarService', @@ -67,12 +65,10 @@ protected static function getBarService($container) */ protected static function getFooService($container, $lazyLoad = true) { - $containerRef = $container->ref; - $container->factories['service_container']['foo'] ??= self::getFooService(...); if (true === $lazyLoad) { - return $container->createProxy('stdClassGhost2fc7938', static fn () => \stdClassGhost2fc7938::createLazyGhost(static fn ($proxy) => self::getFooService($containerRef->get(), $proxy))); + return $container->createProxy('stdClassGhost2fc7938', static fn () => \stdClassGhost2fc7938::createLazyGhost(static fn ($proxy) => self::getFooService($container, $proxy))); } return $lazyLoad; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php index 5d627cb89f0db..41eb55dd51e65 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'bar_service' => 'getBarServiceService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php index 6badcf4d0a48a..e2102b420c18a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'public_foo' => 'getPublicFooService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php index d3dc84d68c7c4..1a04af65f30e0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_QueryStringParameters extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php index 60700526ead94..556e91d783c31 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php @@ -15,13 +15,10 @@ class Symfony_DI_PhpDumper_Test_Rot13Parameters extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; protected \Closure $getService; public function __construct() { - $containerRef = $this->ref = \WeakReference::create($this); - $this->getService = static function () use ($containerRef) { return $containerRef->get()->getService(...\func_get_args()); }; $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; @@ -67,7 +64,7 @@ protected static function getRot13EnvVarProcessorService($container) */ protected static function getContainer_EnvVarProcessorsLocatorService($container) { - return $container->services['container.env_var_processors_locator'] = new \Symfony\Component\DependencyInjection\Argument\ServiceLocator($container->getService, [ + return $container->services['container.env_var_processors_locator'] = new \Symfony\Component\DependencyInjection\Argument\ServiceLocator($container->getService ??= $container->getService(...), [ 'rot13' => ['services', 'Symfony\\Component\\DependencyInjection\\Tests\\Dumper\\Rot13EnvVarProcessor', 'getRot13EnvVarProcessorService', false], ], [ 'rot13' => '?', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_service_locator_argument.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_service_locator_argument.php index f999184479893..83e8d3a3a75b3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_service_locator_argument.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_service_locator_argument.php @@ -15,13 +15,10 @@ class Symfony_DI_PhpDumper_Service_Locator_Argument extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; protected \Closure $getService; public function __construct() { - $containerRef = $this->ref = \WeakReference::create($this); - $this->getService = static function () use ($containerRef) { return $containerRef->get()->getService(...\func_get_args()); }; $this->services = $this->privates = []; $this->syntheticIds = [ 'foo5' => true, @@ -63,7 +60,7 @@ protected static function getBarService($container) { $container->services['bar'] = $instance = new \stdClass(); - $instance->locator = new \Symfony\Component\DependencyInjection\Argument\ServiceLocator($container->getService, [ + $instance->locator = new \Symfony\Component\DependencyInjection\Argument\ServiceLocator($container->getService ??= $container->getService(...), [ 'foo1' => ['services', 'foo1', 'getFoo1Service', false], 'foo2' => ['privates', 'foo2', 'getFoo2Service', false], 'foo3' => [false, 'foo3', 'getFoo3Service', false], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php index 77ed9e02882a4..c90f03c14b68d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php @@ -15,13 +15,10 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; protected \Closure $getService; public function __construct() { - $containerRef = $this->ref = \WeakReference::create($this); - $this->getService = static function () use ($containerRef) { return $containerRef->get()->getService(...\func_get_args()); }; $this->services = $this->privates = []; $this->methodMap = [ 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => 'getTestServiceSubscriberService', @@ -71,7 +68,7 @@ protected static function getTestServiceSubscriberService($container) */ protected static function getFooServiceService($container) { - return $container->services['foo_service'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber((new \Symfony\Component\DependencyInjection\Argument\ServiceLocator($container->getService, [ + return $container->services['foo_service'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber((new \Symfony\Component\DependencyInjection\Argument\ServiceLocator($container->getService ??= $container->getService(...), [ 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => ['privates', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition', 'getCustomDefinitionService', false], 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => ['services', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber', 'getTestServiceSubscriberService', false], 'bar' => ['services', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber', 'getTestServiceSubscriberService', false], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_tsantos.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_tsantos.php index 00dab8c875eee..77d78a6558fa6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_tsantos.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_tsantos.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'tsantos_serializer' => 'getTsantosSerializerService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php index b42db843a12c9..a24db964def5f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_Uninitialized_Reference extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'bar' => 'getBarService', @@ -55,25 +53,13 @@ public function getRemovedIds(): array */ protected static function getBarService($container) { - $containerRef = $container->ref; - $container->services['bar'] = $instance = new \stdClass(); $instance->foo1 = ($container->services['foo1'] ?? null); $instance->foo2 = null; $instance->foo3 = ($container->privates['foo3'] ?? null); - $instance->closures = [#[\Closure(name: 'foo1', class: 'stdClass')] function () use ($containerRef) { - $container = $containerRef->get(); - - return ($container->services['foo1'] ?? null); - }, #[\Closure(name: 'foo2')] fn () => null, #[\Closure(name: 'foo3', class: 'stdClass')] function () use ($containerRef) { - $container = $containerRef->get(); - - return ($container->privates['foo3'] ?? null); - }]; - $instance->iter = new RewindableGenerator(function () use ($containerRef) { - $container = $containerRef->get(); - + $instance->closures = [#[\Closure(name: 'foo1', class: 'stdClass')] fn () => ($container->services['foo1'] ?? null), #[\Closure(name: 'foo2')] fn () => null, #[\Closure(name: 'foo3', class: 'stdClass')] fn () => ($container->privates['foo3'] ?? null)]; + $instance->iter = new RewindableGenerator(function () use ($container) { if (isset($container->services['foo1'])) { yield 'foo1' => ($container->services['foo1'] ?? null); } @@ -83,11 +69,7 @@ protected static function getBarService($container) if (isset($container->privates['foo3'])) { yield 'foo3' => ($container->privates['foo3'] ?? null); } - }, function () use ($containerRef) { - $container = $containerRef->get(); - - return 0 + (int) (isset($container->services['foo1'])) + (int) (false) + (int) (isset($container->privates['foo3'])); - }); + }, fn () => 0 + (int) (isset($container->services['foo1'])) + (int) (false) + (int) (isset($container->privates['foo3']))); return $instance; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php index 3473edb993327..2849c8b53f04f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_Unsupported_Characters extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php index 154080cdbf257..7f0fb1d9d4af6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Test_UrlParameters extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php index a4f9e848197bd..bb8aa67c8f3ef 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Service_Wither extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'wither' => 'getWitherService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_annotation.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_annotation.php index a958df8ebdc0d..cad200e4d68df 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_annotation.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_annotation.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Service_Wither_Annotation extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'wither' => 'getWitherService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy.php index e5804f2e14805..f52f226597625 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Service_Wither_Lazy extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'wither' => 'getWitherService', @@ -57,10 +55,8 @@ protected function createProxy($class, \Closure $factory) */ protected static function getWitherService($container, $lazyLoad = true) { - $containerRef = $container->ref; - if (true === $lazyLoad) { - return $container->services['wither'] = $container->createProxy('WitherProxy580fe0f', static fn () => \WitherProxy580fe0f::createLazyProxy(static fn () => self::getWitherService($containerRef->get(), false))); + return $container->services['wither'] = $container->createProxy('WitherProxy580fe0f', static fn () => \WitherProxy580fe0f::createLazyProxy(static fn () => self::getWitherService($container, false))); } $instance = new \Symfony\Component\DependencyInjection\Tests\Compiler\Wither(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_staticreturntype.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_staticreturntype.php index 61de4e02dcadf..50c7664730e7b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_staticreturntype.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_staticreturntype.php @@ -15,11 +15,9 @@ class Symfony_DI_PhpDumper_Service_WitherStaticReturnType extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'wither' => 'getWitherService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/static_constructor.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/static_constructor.php index a262304550f89..497136eba6a87 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/static_constructor.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/static_constructor.php @@ -15,11 +15,9 @@ class ProjectServiceContainer extends Container { protected $parameters = []; - protected readonly \WeakReference $ref; public function __construct() { - $this->ref = \WeakReference::create($this); $this->services = $this->privates = []; $this->methodMap = [ 'static_constructor' => 'getStaticConstructorService',