8000 [DependencyInjection] Support Yaml calls without arguments · phreaknerd/symfony@24a0d0a · GitHub
[go: up one dir, main page]

Skip to content

Commit 24a0d0a

Browse files
committed
[DependencyInjection] Support Yaml calls without arguments
1 parent 72e82eb commit 24a0d0a

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ private function parseDefinition($id, $service, $file)
196196

197197
if (isset($service['calls'])) {
198198
foreach ($service['calls'] as $call) {
199-
$definition->addMethodCall($call[0], $this->resolveServices($call[1]));
199+
$args = isset($call[1]) ? $this->resolveServices($call[1]) : array();
200+
$definition->addMethodCall($call[0], $args);
200201
}
201202
}
202203

tests/Symfony/Tests/Component/DependencyInjection/Fixtures/yaml/services6.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ services:
1414
class: FooClass
1515
calls:
1616
- [ setBar, [] ]
17+
- [ setBar ]
1718
method_call2:
1819
class: FooClass
1920
calls:

tests/Symfony/Tests/Component/DependencyInjection/Loader/YamlFileLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function testLoadServices()
113113
$this->assertEquals('sc_configure', $services['configurator1']->getConfigurator(), '->load() parses the configurator tag');
114114
$this->assertEquals(array(new Reference('baz'), 'configure'), $services['configurator2']->getConfigurator(), '->load() parses the configurator tag');
115115
$this->assertEquals(array('BazClass', 'configureStatic'), $services['configurator3']->getConfigurator(), '->load() parses the configurator tag');
116-
$this->assertEquals(array(array('setBar', array())), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag');
116+
$this->assertEquals(array(array('setBar', array()), array('setBar', array())), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag');
117117
$this->assertEquals(array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), $services['method_call2']->getMethodCalls(), '->load() parses the method_call tag');
118118
$this->assertEquals('baz_factory', $services['factory_service']->getFactoryService());
119119

0 commit comments

Comments
 (0)
0