Skip to content

Commit

Permalink
Ensure that inlined services with parameterized class name can be dumped
Browse files Browse the repository at this point in the history
  • Loading branch information
sroze committed Dec 6, 2017
1 parent 730b156 commit 28f0086
Showing 1 changed file with 26 additions and 0 deletions.
Expand Up @@ -23,6 +23,7 @@
use Symfony\Component\DependencyInjection\ContainerInterface as SymfonyContainerInterface;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
use Symfony\Component\DependencyInjection\EnvVarProcessorInterface;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator;
Expand Down Expand Up @@ -822,6 +823,31 @@ public function testDumpHandlesLiteralClassWithRootNamespace()
$this->assertInstanceOf('stdClass', $container->get('foo'));
}

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.
Expand Down

0 comments on commit 28f0086

Please sign in to comment.