From a9de390676996fbebdce6be1e9754b7f2d4e62ab Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 3 Mar 2021 13:08:43 +0100 Subject: [PATCH] fix parsing calls of methods named "method" --- .../Component/DependencyInjection/Loader/YamlFileLoader.php | 2 +- .../DependencyInjection/Tests/Fixtures/yaml/alt_call.yaml | 2 ++ .../DependencyInjection/Tests/Loader/YamlFileLoaderTest.php | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 1133254c6c..e9b09cc2eb 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -471,7 +471,7 @@ class YamlFileLoader extends FileLoader throw new InvalidArgumentException(sprintf('Invalid method call for service "%s", did you forgot a leading dash before "%s: ..." in "%s"?', $id, $k, $file)); } - if (isset($call['method'])) { + if (isset($call['method']) && \is_string($call['method'])) { $method = $call['method']; $args = $call['arguments'] ?? []; $returnsClone = $call['returns_clone'] ?? false; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/alt_call.yaml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/alt_call.yaml index 26cf9e628c..fb7f3440de 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/alt_call.yaml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/alt_call.yaml @@ -3,3 +3,5 @@ services: calls: - foo: [1, 2, 3] - bar: !returns_clone [1, 2, 3] + - method: + - url diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 2e15f615fb..b20302cf97 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -968,6 +968,7 @@ class YamlFileLoaderTest extends TestCase $expected = [ ['foo', [1, 2, 3]], ['bar', [1, 2, 3], true], + ['method', ['url']], ]; $this->assertSame($expected, $container->getDefinition('foo')->getMethodCalls());