Skip to content

Commit 28f0086

Browse files
committed
Ensure that inlined services with parameterized class name can be dumped
1 parent 730b156 commit 28f0086

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Symfony\Component\DependencyInjection\ContainerInterface as SymfonyContainerInterface;
2424
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
2525
use Symfony\Component\DependencyInjection\EnvVarProcessorInterface;
26+
use Symfony\Component\DependencyInjection\Parameter;
2627
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
2728
use Symfony\Component\DependencyInjection\Reference;
2829
use Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator;
@@ -822,6 +823,31 @@ public function testDumpHandlesLiteralClassWithRootNamespace()
822823
$this->assertInstanceOf('stdClass', $container->get('foo'));
823824
}
824825

826+
public function testDumpHandlesObjectClassNames()
827+
{
828+
$container = new ContainerBuilder(new ParameterBag(array(
829+
'class' => 'stdClass',
830+
)));
831+
832+
$container->setDefinition('foo', new Definition(new Parameter('class')));
833+
$container->setDefinition('bar', new Definition('stdClass', array(
834+
new Reference('foo'),
835+
)))->setPublic(true);
836+
837+
$container->setParameter('inline_requires', true);
838+
$container->compile();
839+
840+
$dumper = new PhpDumper($container);
841+
eval('?>'.$dumper->dump(array(
842+
'class' => 'Symfony_DI_PhpDumper_Test_Object_Class_Name',
843+
'inline_class_loader_parameter' => 'inline_requires',
844+
)));
845+
846+
$container = new \Symfony_DI_PhpDumper_Test_Object_Class_Name();
847+
848+
$this->assertInstanceOf('stdClass', $container->get('bar'));
849+
}
850+
825851
/**
826852
* @group legacy
827853
* @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.

0 commit comments

Comments
 (0)