Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a38eb2b

Browse filesBrowse files
committed
disable inlining deprecated services
1 parent 0c6096f commit a38eb2b
Copy full SHA for a38eb2b

File tree

3 files changed

+44
-1
lines changed
Filter options

3 files changed

+44
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,25 @@ public function testAutowiring()
891891

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

896915
class FooClass

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,4 +360,28 @@ public function testDumpHandlesLiteralClassWithRootNamespace()
360360

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.