+ public function testDumpHandlesObjectClassNames()
+ {
+ $container = new ContainerBuilder(new ParameterBag(array(
+ 'class' => 'stdClass',
+ )));
+
+ $container->setDefinition('foo', new Definition(new Parameter('class')));
+ $container->setDefinition('bar', new Definition('stdClass', array(
+ new Reference('foo'),
+ )))->setPublic(true);
+
+ $container->setParameter('inline_requires', true);
+ $container->compile();
+
+ $dumper = new PhpDumper($container);
+ eval('?>'.$dumper->dump(array(
+ 'class' => 'Symfony_DI_PhpDumper_Test_Object_Class_Name',
+ 'inline_class_loader_parameter' => 'inline_requires',
+ )));
+
+ $container = new \Symfony_DI_PhpDumper_Test_Object_Class_Name();
+
+ $this->assertInstanceOf('stdClass', $container->get('bar'));
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation The "private" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.
+ * @expectedDeprecation The "private_alias" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.
+ * @expectedDeprecation The "decorated_private" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.
+ * @expectedDeprecation The "decorated_private_alias" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.
+ * @expectedDeprecation The "private_not_inlined" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.
+ * @expectedDeprecation The "private_not_removed" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.
+ * @expectedDeprecation The "private_child" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.
+ * @expectedDeprecation The "private_parent" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.
+ */
+ public function testLegacyPrivateServices()
+ {
+ $container = new ContainerBuilder();
+ $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
+ $loader->load('services_legacy_privates.yml');
+
+ $container->setDefinition('private_child', new ChildDefinition('foo'));
+ $container->setDefinition('private_parent', new ChildDefinition('private'));
+
+ $container->getDefinition('private')->setPrivate(true);
+ $container->getDefinition('private_not_inlined')->setPrivate(true);
+ $container->getDefinition('private_not_removed')->setPrivate(true);
+ $container->getDefinition('decorated_private')->setPrivate(true);
+ $container->getDefinition('private_child')->setPrivate(true);
+ $container->getAlias('decorated_private_alias')->setPrivate(true);
+ $container->getAlias('private_alias')->setPrivate(true);
+
+ $container->compile();
+ $dumper = new PhpDumper($container);
+
+ $this->assertStringEqualsFile(self::$fixturesPath.'/php/services_legacy_privates.php', $dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Legacy_Privates', 'file' => self::$fixturesPath.'/php/services_legacy_privates.php')));
+
+ require self::$fixturesPath.'/php/services_legacy_privates.php';
+
+ $container = new \Symfony_DI_PhpDumper_Test_Legacy_Privates();
+
+ $container->get('private');
+ $container->get('private_alias');
+ $container->get('alias_to_private');
+ $container->get('decorated_private');
+ $container->get('decorated_private_alias');
+ $container->get('private_not_inlined');
+ $container->get('private_not_removed');
+ $container->get('private_child');
+ $container->get('private_parent');
+ $container->get('public_child');
+ }
+