Skip to content

Commit 7966bc0

Browse files
Merge branch '2.8' into 3.0
* 2.8: [TwigBundle] Removed redundant return statement. [DependencyInjection] Fixed deprecated default message template with XML [TwigBridge] Removed extra arguments in 2 places. [Process] Fix write access check for pipes on Windows [HttpKernel] Use flock() for HttpCache's lock files
2 parents 4499484 + 6de94bd commit 7966bc0

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private function parseDefinition(\DOMElement $service, $file)
164164
}
165165

166166
if ($deprecated = $this->getChildren($service, 'deprecated')) {
167-
$definition->setDeprecated(true, $deprecated[0]->nodeValue);
167+
$definition->setDeprecated(true, $deprecated[0]->nodeValue ?: null);
168168
}
169169

170170
$definition->setArguments($this->getArgumentsAsPhp($service, 'argument'));
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
3+
<services>
4+
<service id="foo" class="Foo">
5+
<deprecated />
6+
</service>
7+
<service id="bar" class="Bar">
8+
<deprecated>The "%service_id%" service is deprecated.</deprecated>
9+
</service>
10+
</services>
11+
</container>

Tests/Loader/XmlFileLoaderTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,21 @@ public function testParseTagWithEmptyNameThrowsException()
301301
$loader->load('tag_with_empty_name.xml');
302302
}
303303

304+
public function testDeprecated()
305+
{
306+
$container = new ContainerBuilder();
307+
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
308+
$loader->load('services_deprecated.xml');
309+
310+
$this->assertTrue($container->getDefinition('foo')->isDeprecated());
311+
$message = 'The "foo" service is deprecated. You should stop using it, as it will soon be removed.';
312+
$this->assertSame($message, $container->getDefinition('foo')->getDeprecationMessage('foo'));
313+
314+
$this->assertTrue($container->getDefinition('bar')->isDeprecated());
315+
$message = 'The "bar" service is deprecated.';
316+
$this->assertSame($message, $container->getDefinition('bar')->getDeprecationMessage('bar'));
317+
}
318+
304319
public function testConvertDomElementToArray()
305320
{
306321
$doc = new \DOMDocument('1.0');

0 commit comments

Comments
 (0)