8000 disable inlining deprecated services · symfony/symfony@6ab8ca0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6ab8ca0

Browse files
committed
disable inlining deprecated services
1 parent 0c6096f commit 6ab8ca0

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private function isInlineableDefinition(ContainerBuilder $container, $id, Defini
113113
return true;
114114
}
115115

116-
if ($definition->isPublic() || $definition->isLazy()) {
116+
if ($definition->isDeprecated() || $definition->isPublic() || $definition->isLazy()) {
117117
return false;
118118
}
119119

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,27 @@ public function testAutowiring()
891891

892892
$this->assertEquals('a', (string) $container->getDefinition('b')->getArgument(0));
893893
}
894+
895+
/**
896+
* This test checks the trigger of a deprecation note and should not be removed in major releases.
897+
*
898+
* @group legacy
899+
* @expectedDeprecation The "foo" service is deprecated. You should stop using it, as it will soon be removed.
900+
*/
901+
public function testPrivateServiceTriggersDeprecation()
902+
{
903+
$container = new ContainerBuilder();
904+
$container->register('foo', 'stdClass')
905+
->setPublic(false)
906+
->setDeprecated(true);
907+
$container->register('bar', 'stdClass')
908+
->setPublic(true)
909+
->setProperty('foo', new Reference('foo'));
910+
911+
$container->compile();
912+
913+
$container->get('bar');
914+
}
894915
}
895916

896917
class FooClass

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,4 +360,30 @@ public function testDumpHandlesLiteralClassWithRootNamespace()
360360

361361
$this->assertInstanceOf('stdClass', $container->get('foo'));
362362
}
363+
364+
/**
365+
* This test checks the trigger of a deprecation note and should not be removed in major releases.
366+
*
367+
* @group legacy
368+
* @expectedDeprecation The "foo" service is deprecated. You should stop using it, as it will soon be removed.
369+
*/
370+
public function testPrivateServiceTriggersDeprecation()
371+
{
372+
$container = new ContainerBuilder();
373+
$container->register('foo', 'stdClass')
374+
->setPublic(false)
375+
->setDeprecated(true);
376+
$container->register('bar', 'stdClass')
377+
->setPublic(true)
378+
->setProperty('foo', new Reference('foo'));
379+
380+
$container->compile();
381+
382+
$dumper = new PhpDumper($container);
383+
eval('?>'.$dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Private_Service_Triggers_Deprecation')));
384+
385+
$container = new \Symfony_DI_PhpDumper_Test_Private_Service_Triggers_Deprecation();
386+
387+
$container->get('bar');
388+
}
363389
}

0 commit comments

Comments
 (0)
0