bug #40350 [DependencyInjection] fix parsing calls of methods named "method" (xabbuh)

This PR was merged into the 4.4 branch.

Discussion
----------

[DependencyInjection] fix parsing calls of methods named "method"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #40349
| License       | MIT
| Doc PR        |

Commits
-------

a9de390676 fix parsing calls of methods named "method"
This commit is contained in:
Alexander M. Turek 2021-03-03 13:27:34 +01:00
commit 6d2998e4d7
3 changed files with 4 additions and 1 deletions

View File

@ -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;

View File

@ -3,3 +3,5 @@ services:
calls:
- foo: [1, 2, 3]
- bar: !returns_clone [1, 2, 3]
- method:
- url

View File

@ -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());