From ff2ab5831a9fcaf2847e3dc48afd97c52a026165 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 19 Sep 2017 22:53:21 +0200 Subject: [PATCH] [DI] Fix private-by-default BC layer --- .../Tests/LazyProxy/ContainerBuilderTest.php | 2 +- .../FrameworkExtensionTest.php | 1 + .../WebProfilerExtensionTest.php | 14 +++++--- .../DependencyInjection/ChildDefinition.php | 1 + .../Compiler/RemoveUnusedDefinitionsPass.php | 2 +- .../DependencyInjection/ContainerBuilder.php | 30 ++++++++++++---- .../Loader/XmlFileLoader.php | 6 +--- .../Tests/ContainerBuilderTest.php | 34 ++++++++++++------- .../Tests/Dumper/XmlDumperTest.php | 8 ++--- .../Tests/Fixtures/php/services1-1.php | 3 -- .../Tests/Fixtures/php/services1.php | 3 -- .../Tests/Fixtures/php/services10.php | 3 -- .../Tests/Fixtures/php/services12.php | 3 -- .../Tests/Fixtures/php/services13.php | 3 -- .../Tests/Fixtures/php/services19.php | 3 -- .../Tests/Fixtures/php/services24.php | 3 -- .../Tests/Fixtures/php/services26.php | 3 -- .../Tests/Fixtures/php/services33.php | 3 -- .../Tests/Fixtures/php/services8.php | 3 -- .../Tests/Fixtures/php/services9_as_files.txt | 1 - .../Tests/Fixtures/php/services9_compiled.php | 1 - .../Fixtures/php/services_array_params.php | 3 -- .../Fixtures/php/services_base64_env.php | 3 -- .../Fixtures/php/services_legacy_privates.php | 1 - .../Tests/Fixtures/php/services_locator.php | 1 - .../Fixtures/php/services_private_frozen.php | 1 - .../php/services_private_in_expression.php | 1 - .../Tests/Fixtures/php/services_rot13_env.php | 3 -- .../Fixtures/php/services_subscriber.php | 1 - .../php/services_uninitialized_ref.php | 1 - .../Tests/Fixtures/xml/services1.xml | 2 +- .../Tests/Fixtures/xml/services21.xml | 2 +- .../Tests/Fixtures/xml/services24.xml | 2 +- .../Tests/Fixtures/xml/services8.xml | 2 +- .../Tests/Fixtures/xml/services9.xml | 2 +- .../Tests/Fixtures/xml/services_abstract.xml | 2 +- .../Tests/Fixtures/xml/services_dump_load.xml | 2 +- .../Tests/Fixtures/yaml/services1.yml | 1 + .../Tests/Fixtures/yaml/services24.yml | 1 + .../Tests/Fixtures/yaml/services8.yml | 1 + .../Tests/Fixtures/yaml/services9.yml | 1 + .../Tests/Fixtures/yaml/services_inline.yml | 1 + .../DependencyInjection/FormPassTest.php | 15 ++++---- .../ResettableServicePassTest.php | 3 ++ .../ServiceResetListenerTest.php | 5 +-- .../Component/HttpKernel/Tests/KernelTest.php | 2 +- 46 files changed, 91 insertions(+), 98 deletions(-) diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php index 858e9d76b64c9..fc5af78fac182 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php @@ -31,7 +31,7 @@ public function testCreateProxyServiceWithRuntimeInstantiator() $builder->setProxyInstantiator(new RuntimeInstantiator()); - $builder->register('foo1', 'ProxyManagerBridgeFooClass')->setFile(__DIR__.'/Fixtures/includes/foo.php'); + $builder->register('foo1', 'ProxyManagerBridgeFooClass')->setFile(__DIR__.'/Fixtures/includes/foo.php')->setPublic(true); $builder->getDefinition('foo1')->setLazy(true); $builder->compile(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index e32db4097da64..89f8f48182157 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -953,6 +953,7 @@ public function testEventDispatcherService() $this->loadFromFile($container, 'default_config'); $container ->register('foo', \stdClass::class) + ->setPublic(true) ->setProperty('dispatcher', new Reference('event_dispatcher')); $container->compile(); $this->assertInstanceOf(EventDispatcherInterface::class, $container->get('foo')->dispatcher); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php index 25e352e7124ce..fbb3ca072046e 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php @@ -52,11 +52,11 @@ protected function setUp() $this->kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\KernelInterface')->getMock(); $this->container = new ContainerBuilder(); - $this->container->register('event_dispatcher', EventDispatcher::class); - $this->container->register('router', $this->getMockClass('Symfony\\Component\\Routing\\RouterInterface')); - $this->container->register('twig', 'Twig\Environment'); - $this->container->register('twig_loader', 'Twig\Loader\ArrayLoader')->addArgument(array()); - $this->container->register('twig', 'Twig\Environment')->addArgument(new Reference('twig_loader')); + $this->container->register('event_dispatcher', EventDispatcher::class)->setPublic(true); + $this->container->register('router', $this->getMockClass('Symfony\\Component\\Routing\\RouterInterface'))->setPublic(true); + $this->container->register('twig', 'Twig\Environment')->setPublic(true); + $this->container->register('twig_loader', 'Twig\Loader\ArrayLoader')->addArgument(array())->setPublic(true); + $this->container->register('twig', 'Twig\Environment')->addArgument(new Reference('twig_loader'))->setPublic(true); $this->container->setParameter('kernel.bundles', array()); $this->container->setParameter('kernel.cache_dir', __DIR__); $this->container->setParameter('kernel.debug', false); @@ -65,6 +65,7 @@ protected function setUp() $this->container->setParameter('debug.file_link_format', null); $this->container->setParameter('profiler.class', array('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')); $this->container->register('profiler', $this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')) + ->setPublic(true) ->addArgument(new Definition($this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\ProfilerStorageInterface'))); $this->container->setParameter('data_collector.templates', array()); $this->container->set('kernel', $this->kernel); @@ -123,6 +124,9 @@ public function getDebugModes() private function getCompiledContainer() { + if ($this->container->has('web_profiler.debug_toolbar')) { + $this->container->getDefinition('web_profiler.debug_toolbar')->setPublic(true); + } $this->container->compile(); $this->container->set('kernel', $this->kernel); diff --git a/src/Symfony/Component/DependencyInjection/ChildDefinition.php b/src/Symfony/Component/DependencyInjection/ChildDefinition.php index d72c762c5c6dd..f363a64829c24 100644 --- a/src/Symfony/Component/DependencyInjection/ChildDefinition.php +++ b/src/Symfony/Component/DependencyInjection/ChildDefinition.php @@ -30,6 +30,7 @@ class ChildDefinition extends Definition public function __construct($parent) { $this->parent = $parent; + $this->setPrivate(false); } /** diff --git a/src/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php index 7fcf6cc634283..9a200499fa69a 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php @@ -68,8 +68,8 @@ public function process(ContainerBuilder $container) if (1 === count($referencingAliases) && false === $isReferenced) { $container->setDefinition((string) reset($referencingAliases), $definition); - $definition->setPrivate(reset($referencingAliases)->isPrivate()); $definition->setPublic(!$definition->isPrivate()); + $definition->setPrivate(reset($referencingAliases)->isPrivate()); $container->removeDefinition($id); $container->log($this, sprintf('Removed service "%s"; reason: replaces alias %s.', $id, reset($referencingAliases))); } elseif (0 === count($referencingAliases) && false === $isReferenced) { diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 4881f828f1c6f..d46da389f05b4 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -126,7 +126,7 @@ public function __construct(ParameterBagInterface $parameterBag = null) parent::__construct($parameterBag); $this->trackResources = interface_exists('Symfony\Component\Config\Resource\ResourceInterface'); - $this->setDefinition('service_container', (new Definition(ContainerInterface::class))->setSynthetic(true)); + $this->setDefinition('service_container', (new Definition(ContainerInterface::class))->setSynthetic(true)->setPublic(true)); $this->setAlias(PsrContainerInterface::class, new Alias('service_container', false)); $this->setAlias(ContainerInterface::class, new Alias('service_container', false)); } @@ -562,6 +562,22 @@ public function has($id) * @see Reference */ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) + { + if ($this->isCompiled()) { + $id = $this->normalizeId($id); + + if (isset($this->definitions[$id]) && $this->definitions[$id]->isPrivate()) { + @trigger_error(sprintf('Fetching the "%s" private service is deprecated and will fail in Symfony 4.0. Make the service public instead.', $id), E_USER_DEPRECATED); + } + if (isset($this->aliasDefinitions[$id]) && $this->aliasDefinitions[$id]->isPrivate()) { + @trigger_error(sprintf('Fetching the "%s" private alias is deprecated and will fail in Symfony 4.0. Make the alias public instead.', $id), E_USER_DEPRECATED); + } + } + + return $this->doGet($id, $invalidBehavior); + } + + private function doGet($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { $id = $this->normalizeId($id); @@ -573,7 +589,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV } if (!isset($this->definitions[$id]) && isset($this->aliasDefinitions[$id])) { - return $this->get((string) $this->aliasDefinitions[$id], $invalidBehavior); + return $this->doGet((string) $this->aliasDefinitions[$id], $invalidBehavior); } try { @@ -1122,7 +1138,7 @@ private function createService(Definition $definition, $id, $tryProxy = true) $callable[0] = $parameterBag->resolveValue($callable[0]); if ($callable[0] instanceof Reference) { - $callable[0] = $this->get((string) $callable[0], $callable[0]->getInvalidBehavior()); + $callable[0] = $this->doGet((string) $callable[0], $callable[0]->getInvalidBehavior()); } elseif ($callable[0] instanceof Definition) { $callable[0] = $this->createService($callable[0], null); } @@ -1166,7 +1182,7 @@ public function resolveServices($value) } } foreach (self::getInitializedConditionals($v) as $s) { - if (!$this->get($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) { + if (!$this->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) { continue 2; } } @@ -1182,7 +1198,7 @@ public function resolveServices($value) } } foreach (self::getInitializedConditionals($v) as $s) { - if (!$this->get($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) { + if (!$this->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) { continue 2; } } @@ -1193,7 +1209,7 @@ public function resolveServices($value) return $count; }); } elseif ($value instanceof Reference) { - $value = $this->get((string) $value, $value->getInvalidBehavior()); + $value = $this->doGet((string) $value, $value->getInvalidBehavior()); } elseif ($value instanceof Definition) { $value = $this->createService($value, null); } elseif ($value instanceof Expression) { @@ -1518,7 +1534,7 @@ private function callMethod($service, $call) } } foreach (self::getInitializedConditionals($call[1]) as $s) { - if (!$this->get($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) { + if (!$this->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) { return; } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 6bebf2133c57b..f152d462676e2 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -255,11 +255,7 @@ private function parseDefinition(\DOMElement $service, $file, array $defaults) $definition->setChanges(array()); } - if ($publicAttr = $service->getAttribute('public')) { - $definition->setPublic(XmlUtils::phpize($publicAttr)); - } - - foreach (array('class', 'shared', 'synthetic', 'lazy', 'abstract') as $key) { + foreach (array('class', 'public', 'shared', 'synthetic', 'lazy', 'abstract') as $key) { if ($value = $service->getAttribute($key)) { $method = 'set'.$key; $definition->$method(XmlUtils::phpize($value)); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index d074189cbeab7..80c9eb4559809 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -630,6 +630,7 @@ public function testCompileWithResolveEnv() $container->setParameter('env(HTTP_DUMMY_VAR)', '123'); $container->register('teatime', 'stdClass') ->setProperty('foo', '%env(DUMMY_ENV_VAR)%') + ->setPublic(true) ; $container->compile(true); @@ -687,9 +688,11 @@ public function testCastEnv() $container = new ContainerBuilder(); $container->setParameter('env(FAKE)', '123'); - $container->register('foo', 'stdClass')->setProperties(array( - 'fake' => '%env(int:FAKE)%', - )); + $container->register('foo', 'stdClass') + ->setPublic(true) + ->setProperties(array( + 'fake' => '%env(int:FAKE)%', + )); $container->compile(true); @@ -701,7 +704,9 @@ public function testEnvAreNullable() $container = new ContainerBuilder(); $container->setParameter('env(FAKE)', null); - $container->register('foo', 'stdClass')->setProperties(array( + $container->register('foo', 'stdClass') + ->setPublic(true) + ->setProperties(array( 'fake' => '%env(int:FAKE)%', )); @@ -860,7 +865,7 @@ public function testCompilesClassDefinitionsOfLazyServices() $this->assertEmpty($container->getResources(), 'No resources get registered without resource tracking'); - $container->register('foo', 'BarClass'); + $container->register('foo', 'BarClass')->setPublic(true); $container->getDefinition('foo')->setLazy(true); $container->compile(); @@ -959,7 +964,7 @@ public function testPrivateServiceUser() $container->addDefinitions(array( 'bar' => $fooDefinition, - 'bar_user' => $fooUserDefinition, + 'bar_user' => $fooUserDefinition->setPublic(true), )); $container->compile(); @@ -973,7 +978,7 @@ public function testThrowsExceptionWhenSetServiceOnACompiledContainer() { $container = new ContainerBuilder(); $container->setResourceTracking(false); - $container->setDefinition('a', new Definition('stdClass')); + $container->register('a', 'stdClass')->setPublic(true); $container->compile(); $container->set('a', new \stdClass()); } @@ -990,7 +995,7 @@ public function testNoExceptionWhenSetSyntheticServiceOnACompiledContainer() { $container = new ContainerBuilder(); $def = new Definition('stdClass'); - $def->setSynthetic(true); + $def->setSynthetic(true)->setPublic(true); $container->setDefinition('a', $def); $container->compile(); $container->set('a', $a = new \stdClass()); @@ -1031,10 +1036,10 @@ public function testAbstractAlias() $container = new ContainerBuilder(); $abstract = new Definition('AbstractClass'); - $abstract->setAbstract(true); + $abstract->setAbstract(true)->setPublic(true); $container->setDefinition('abstract_service', $abstract); - $container->setAlias('abstract_alias', 'abstract_service'); + $container->setAlias('abstract_alias', 'abstract_service')->setPublic(true); $container->compile(); @@ -1048,6 +1053,7 @@ public function testLazyLoadedService() $container->set('a', new \BazClass()); $definition = new Definition('BazClass'); $definition->setLazy(true); + $definition->setPublic(true); $container->setDefinition('a', $definition); }); @@ -1075,6 +1081,7 @@ public function testInitializePropertiesBeforeMethodCalls() $container = new ContainerBuilder(); $container->register('foo', 'stdClass'); $container->register('bar', 'MethodCallClass') + ->setPublic(true) ->setProperty('simple', 'bar') ->setProperty('complex', new Reference('foo')) ->addMethodCall('callMe'); @@ -1088,9 +1095,10 @@ public function testAutowiring() { $container = new ContainerBuilder(); - $container->register(A::class); + $container->register(A::class)->setPublic(true); $bDefinition = $container->register('b', __NAMESPACE__.'\B'); $bDefinition->setAutowired(true); + $bDefinition->setPublic(true); $container->compile(); @@ -1149,12 +1157,13 @@ public function testServiceLocator() { $container = new ContainerBuilder(); $container->register('foo_service', ServiceLocator::class) + ->setPublic(true) ->addArgument(array( 'bar' => new ServiceClosureArgument(new Reference('bar_service')), 'baz' => new ServiceClosureArgument(new TypedReference('baz_service', 'stdClass')), )) ; - $container->register('bar_service', 'stdClass')->setArguments(array(new Reference('baz_service'))); + $container->register('bar_service', 'stdClass')->setArguments(array(new Reference('baz_service')))->setPublic(true); $container->register('baz_service', 'stdClass')->setPublic(false); $container->compile(); @@ -1234,6 +1243,7 @@ public function testParameterWithMixedCase() { $container = new ContainerBuilder(new ParameterBag(array('foo' => 'bar'))); $container->register('foo', 'stdClass') + ->setPublic(true) ->setProperty('foo', '%FOO%'); $container->compile(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php index 7904ed0c9e6db..2e4ccf1fdbe4c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php @@ -74,7 +74,7 @@ public function testDumpAnonymousServices() $this->assertEquals(' - + @@ -98,7 +98,7 @@ public function testDumpEntities() $this->assertEquals(" - + foo<>&bar @@ -127,7 +127,7 @@ public function provideDecoratedServicesData() array(" - + @@ -137,7 +137,7 @@ public function provideDecoratedServicesData() array(" - + 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 d87e61e14aa19..44631328ce606 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php @@ -29,9 +29,6 @@ class Container extends AbstractContainer public function __construct() { $this->services = array(); - $this->privates = array( - 'service_container' => true, - ); $this->aliases = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php index 69fc82e056966..9ad021ece802b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php @@ -27,9 +27,6 @@ class ProjectServiceContainer extends Container public function __construct() { $this->services = array(); - $this->privates = array( - 'service_container' => true, - ); $this->aliases = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index 26c73706168d3..d8478d677f4ff 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -32,9 +32,6 @@ public function __construct() $this->methodMap = array( 'test' => 'getTestService', ); - $this->privates = array( - 'service_container' => true, - ); $this->aliases = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index 65891c77b994d..976c720768752 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -36,9 +36,6 @@ public function __construct() $this->methodMap = array( 'test' => 'getTestService', ); - $this->privates = array( - 'service_container' => true, - ); $this->aliases = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php index 1525115f5b74a..42b9e78963662 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php @@ -30,9 +30,6 @@ public function __construct() $this->methodMap = array( 'bar' => 'getBarService', ); - $this->privates = array( - 'service_container' => true, - ); $this->aliases = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php index 44822ac27d8b0..3af42c502c0b4 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php @@ -31,9 +31,6 @@ public function __construct() 'service_from_anonymous_factory' => 'getServiceFromAnonymousFactoryService', 'service_with_method_call_and_factory' => 'getServiceWithMethodCallAndFactoryService', ); - $this->privates = array( - 'service_container' => true, - ); $this->aliases = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php index 8fbfc408caa4c..116972d25b8fc 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php @@ -30,9 +30,6 @@ public function __construct() $this->methodMap = array( 'foo' => 'getFooService', ); - $this->privates = array( - 'service_container' => true, - ); $this->aliases = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php index d3349f02b3007..3a38cff1a1539 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php @@ -36,9 +36,6 @@ public function __construct() $this->methodMap = array( 'test' => 'getTestService', ); - $this->privates = array( - 'service_container' => true, - ); $this->aliases = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php index 327d9e1c4136c..20eda55d99e0f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php @@ -35,9 +35,6 @@ public function __construct() 'Bar\\Foo' => 'getFooService', 'Foo\\Foo' => 'getFoo2Service', ); - $this->privates = array( - 'service_container' => true, - ); $this->aliases = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php index f46835ef9dfc1..1689a9658668a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php @@ -29,9 +29,6 @@ public function __construct() $this->parameters = $this->getDefaultParameters(); $this->services = array(); - $this->privates = array( - 'service_container' => true, - ); $this->aliases = array(); } 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 0af1392afd0f6..059f0912815ca 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 @@ -295,7 +295,6 @@ class Container%s extends Container ); $this->privates = array( 'factory_simple' => true, - 'service_container' => true, ); $this->aliases = array( 'alias_for_alias' => 'foo', 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 3478d54ec52be..103bb0de34d88 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -52,7 +52,6 @@ public function __construct() ); $this->privates = array( 'factory_simple' => true, - 'service_container' => true, ); $this->aliases = array( 'alias_for_alias' => 'foo', 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 872b5179532b6..d848941013388 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 @@ -36,9 +36,6 @@ public function __construct() $this->methodMap = array( 'bar' => 'getBarService', ); - $this->privates = array( - 'service_container' => true, - ); $this->aliases = array(); } 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 8ebd8f0580c58..4f4c7e79df38b 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 @@ -29,9 +29,6 @@ public function __construct() $this->parameters = $this->getDefaultParameters(); $this->services = array(); - $this->privates = array( - 'service_container' => true, - ); $this->aliases = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php index aa154e2c435aa..611b0cf4acadd 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php @@ -52,7 +52,6 @@ public function __construct() 'private_not_inlined' => true, 'private_not_removed' => true, 'private_parent' => true, - 'service_container' => true, ); $this->aliases = array( 'alias_to_private' => 'private', 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 fb2bbbcde8a5a..751ad8e4fa454 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php @@ -40,7 +40,6 @@ public function __construct() ); $this->privates = array( 'baz_service' => true, - 'service_container' => true, ); $this->aliases = array(); 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 6c24edc01801c..a6717fd6abf8f 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 @@ -34,7 +34,6 @@ public function __construct() ); $this->privates = array( 'baz_service' => true, - 'service_container' => true, ); $this->aliases = array(); 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 121951a26f998..e5129d4f36566 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 @@ -33,7 +33,6 @@ public function __construct() ); $this->privates = array( 'private_foo' => true, - 'service_container' => true, ); $this->aliases = array(); 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 22496e69a4dce..2e08cdcb42f92 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 @@ -36,9 +36,6 @@ public function __construct() 'Symfony\\Component\\DependencyInjection\\Tests\\Dumper\\Rot13EnvVarProcessor' => 'getRot13EnvVarProcessorService', 'container.env_var_processors_locator' => 'getContainer_EnvVarProcessorsLocatorService', ); - $this->privates = array( - 'service_container' => true, - ); $this->aliases = array(); } 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 21fcf03c1efe3..3d7cc80336831 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php @@ -38,7 +38,6 @@ public function __construct() ); $this->privates = array( 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => true, - 'service_container' => true, ); $this->aliases = array(); 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 5a2990e303840..4c26d58d70c28 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 @@ -35,7 +35,6 @@ public function __construct() ); $this->privates = array( 'foo3' => true, - 'service_container' => true, ); $this->aliases = array(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services1.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services1.xml index fd7bb3cf9b080..6dc3ea6618c6d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services1.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services1.xml @@ -1,7 +1,7 @@ - + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services21.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services21.xml index 34fd11ef097c2..36fc8cfd81c68 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services21.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services21.xml @@ -1,7 +1,7 @@ - + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml index 7183435842f13..abf389bc8d632 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml @@ -1,7 +1,7 @@ - + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml index 533d2a38d765e..bc1186bd93ccf 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml @@ -20,7 +20,7 @@ - + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml index 59fa6b102ab42..06f314f5eff73 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml @@ -6,7 +6,7 @@ bar - + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_abstract.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_abstract.xml index bf9e07e5b083c..22abf54681f6a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_abstract.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_abstract.xml @@ -1,7 +1,7 @@ - + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_dump_load.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_dump_load.xml index e763aa870a028..e70be185c0ee1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_dump_load.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_dump_load.xml @@ -1,7 +1,7 @@ - + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services1.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services1.yml index 7b0d3dc697852..071742f2e0519 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services1.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services1.yml @@ -1,6 +1,7 @@ services: service_container: class: Symfony\Component\DependencyInjection\ContainerInterface + public: true synthetic: true Psr\Container\ContainerInterface: alias: service_container diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml index 5faf830410afc..f59354e3e2509 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml @@ -2,6 +2,7 @@ services: service_container: class: Symfony\Component\DependencyInjection\ContainerInterface + public: true synthetic: true foo: class: Foo diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml index 9efdf3e0d4d0a..4e37bc9315c9b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml @@ -8,6 +8,7 @@ parameters: services: service_container: class: Symfony\Component\DependencyInjection\ContainerInterface + public: true synthetic: true Psr\Container\ContainerInterface: alias: service_container diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml index 1744611a1a7e0..b6b76da513106 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml @@ -6,6 +6,7 @@ parameters: services: service_container: class: Symfony\Component\DependencyInjection\ContainerInterface + public: true synthetic: true foo: class: Bar\FooClass diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_inline.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_inline.yml index 15d78b50a7725..b985cabd9649e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_inline.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_inline.yml @@ -2,6 +2,7 @@ services: service_container: class: Symfony\Component\DependencyInjection\ContainerInterface + public: true synthetic: true foo: class: Class1 diff --git a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php index 4e9971ea8ccf3..f045e3f9f5d50 100644 --- a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php +++ b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php @@ -51,8 +51,8 @@ public function testAddTaggedTypes() $container = $this->createContainerBuilder(); $container->setDefinition('form.extension', $this->createExtensionDefinition()); - $container->register('my.type1', __CLASS__.'_Type1')->addTag('form.type'); - $container->register('my.type2', __CLASS__.'_Type2')->addTag('form.type'); + $container->register('my.type1', __CLASS__.'_Type1')->addTag('form.type')->setPublic(true); + $container->register('my.type2', __CLASS__.'_Type2')->addTag('form.type')->setPublic(true); $container->compile(); @@ -73,8 +73,8 @@ public function testAddTaggedTypesToDebugCommand() $container->setDefinition('form.extension', $this->createExtensionDefinition()); $container->setDefinition(DebugCommand::class, $this->createDebugCommandDefinition()); - $container->register('my.type1', __CLASS__.'_Type1')->addTag('form.type'); - $container->register('my.type2', __CLASS__.'_Type2')->addTag('form.type'); + $container->register('my.type1', __CLASS__.'_Type1')->addTag('form.type')->setPublic(true); + $container->register('my.type2', __CLASS__.'_Type2')->addTag('form.type')->setPublic(true); $container->compile(); @@ -163,6 +163,7 @@ public function testAddTaggedFormTypeExtensionWithoutExtendedTypeAttribute() $container->setDefinition('form.extension', $this->createExtensionDefinition()); $container->register('my.type_extension', 'stdClass') + ->setPublic(true) ->addTag('form.type_extension'); $container->compile(); @@ -178,8 +179,8 @@ public function testAddTaggedGuessers() $definition2->addTag('form.type_guesser'); $container->setDefinition('form.extension', $this->createExtensionDefinition()); - $container->setDefinition('my.guesser1', $definition1); - $container->setDefinition('my.guesser2', $definition2); + $container->setDefinition('my.guesser1', $definition1)->setPublic(true); + $container->setDefinition('my.guesser2', $definition2)->setPublic(true); $container->compile(); @@ -249,6 +250,7 @@ function (ContainerBuilder $container) { private function createExtensionDefinition() { $definition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension'); + $definition->setPublic(true); $definition->setArguments(array( array(), array(), @@ -261,6 +263,7 @@ private function createExtensionDefinition() private function createDebugCommandDefinition() { $definition = new Definition('Symfony\Component\Form\Command\DebugCommand'); + $definition->setPublic(true); $definition->setArguments(array( $formRegistry = $this->getMockBuilder(FormRegistryInterface::class)->getMock(), array(), diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ResettableServicePassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ResettableServicePassTest.php index 7363586f99588..c998ef2eaf086 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ResettableServicePassTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ResettableServicePassTest.php @@ -18,11 +18,14 @@ public function testCompilerPass() { $container = new ContainerBuilder(); $container->register('one', ResettableService::class) + ->setPublic(true) ->addTag('kernel.reset', array('method' => 'reset')); $container->register('two', ClearableService::class) + ->setPublic(true) ->addTag('kernel.reset', array('method' => 'clear')); $container->register(ServiceResetListener::class) + ->setPublic(true) ->setArguments(array(null, array())); $container->addCompilerPass(new ResettableServicePass('kernel.reset')); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ServiceResetListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ServiceResetListenerTest.php index 4675fbe71e5a2..603d11b2bf412 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ServiceResetListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ServiceResetListenerTest.php @@ -56,10 +56,11 @@ public function testResetServicesTwice() private function buildContainer() { $container = new ContainerBuilder(); - $container->register('one', ResettableService::class); - $container->register('two', ClearableService::class); + $container->register('one', ResettableService::class)->setPublic(true); + $container->register('two', ClearableService::class)->setPublic(true); $container->register('reset_subscriber', ServiceResetListener::class) + ->setPublic(true) ->addArgument(new IteratorArgument(array( 'one' => new Reference('one', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE), 'two' => new Reference('two', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE), diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 4a093472b9df1..a408f87f87a32 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -824,7 +824,7 @@ public function testKernelReset() $this->assertFileExists($containerFile); unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta'); - $kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass'); }); + $kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass')->setPublic(true); }); $kernel->boot(); $this->assertTrue(get_class($kernel->getContainer()) !== $containerClass); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy