disable inlining deprecated services

This commit is contained in:
Alessandro Chitolina 2017-07-17 11:57:18 +02:00
parent 0c6096fc32
commit 6ab8ca0d36
No known key found for this signature in database
GPG Key ID: 245FF08D9662DB42
3 changed files with 48 additions and 1 deletions

View File

@ -113,7 +113,7 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface
return true;
}
if ($definition->isPublic() || $definition->isLazy()) {
if ($definition->isDeprecated() || $definition->isPublic() || $definition->isLazy()) {
return false;
}

View File

@ -891,6 +891,27 @@ class ContainerBuilderTest extends TestCase
$this->assertEquals('a', (string) $container->getDefinition('b')->getArgument(0));
}
/**
* This test checks the trigger of a deprecation note and should not be removed in major releases.
*
* @group legacy
* @expectedDeprecation The "foo" service is deprecated. You should stop using it, as it will soon be removed.
*/
public function testPrivateServiceTriggersDeprecation()
{
$container = new ContainerBuilder();
$container->register('foo', 'stdClass')
->setPublic(false)
->setDeprecated(true);
$container->register('bar', 'stdClass')
->setPublic(true)
->setProperty('foo', new Reference('foo'));
$container->compile();
$container->get('bar');
}
}
class FooClass

View File

@ -360,4 +360,30 @@ class PhpDumperTest extends TestCase
$this->assertInstanceOf('stdClass', $container->get('foo'));
}
/**
* This test checks the trigger of a deprecation note and should not be removed in major releases.
*
* @group legacy
* @expectedDeprecation The "foo" service is deprecated. You should stop using it, as it will soon be removed.
*/
public function testPrivateServiceTriggersDeprecation()
{
$container = new ContainerBuilder();
$container->register('foo', 'stdClass')
->setPublic(false)
->setDeprecated(true);
$container->register('bar', 'stdClass')
->setPublic(true)
->setProperty('foo', new Reference('foo'));
$container->compile();
$dumper = new PhpDumper($container);
eval('?>'.$dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Private_Service_Triggers_Deprecation')));
$container = new \Symfony_DI_PhpDumper_Test_Private_Service_Triggers_Deprecation();
$container->get('bar');
}
}