Skip to content

Commit 4b3e341

Browse files
committed
fix parsing calls of methods named "method"
1 parent ac666b6 commit 4b3e341

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ private function parseDefinition(string $id, $service, string $file, array $defa
471471
throw new InvalidArgumentException(sprintf('Invalid method call for service "%s", did you forgot a leading dash before "%s: ..." in "%s"?', $id, $k, $file));
472472
}
473473

474-
if (isset($call['method'])) {
474+
if (isset($call['method']) && \is_string($call['method'])) {
475475
$method = $call['method'];
476476
$args = $call['arguments'] ?? [];
477477
$returnsClone = $call['returns_clone'] ?? false;

Tests/Fixtures/yaml/alt_call.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ services:
33
calls:
44
- foo: [1, 2, 3]
55
- bar: !returns_clone [1, 2, 3]
6+
- method:
7+
- url

Tests/Loader/YamlFileLoaderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,7 @@ public function testAlternativeMethodCalls()
968968
$expected = [
969969
['foo', [1, 2, 3]],
970970
['bar', [1, 2, 3], true],
971+
['method', ['url']],
971972
];
972973

973974
$this->assertSame($expected, $container->getDefinition('foo')->getMethodCalls());

0 commit comments

Comments
 (0)