bug #32722 [DependencyInjection] Fix bindings and tagged_locator (deguif)

This PR was merged into the 4.3 branch.

Discussion
----------

[DependencyInjection] Fix bindings and tagged_locator

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        |

Working `tagged_locator`

```yaml
App\XXX:
    arguments:
        $taggedLocator: !tagged_locator { tag: 'my_tag', index_by: 'my_key' }
```

Not working `tagged_locator`
```yaml
App\XXX:
    bind:
        $taggedLocator: !tagged_locator { tag: 'my_tag', index_by: 'my_key' }
```

Currently `ResolveBindingsPass` is executed after `ServiceLocatorTagPass`, which produces empty service locators when using `bind`.
I'm proposing to change the optimization passes order, so that this issue is solved.
I'm not confident with the impact, so let's discuss about it.

Commits
-------

bf4c713ad7 Fix bindings and tagged_locator
This commit is contained in:
Nicolas Grekas 2019-07-30 15:26:51 +02:00
commit 79420828d2

View File

@ -51,15 +51,15 @@ class PassConfig
$this->optimizationPasses = [[
new ValidateEnvPlaceholdersPass(),
new ResolveChildDefinitionsPass(),
new ServiceLocatorTagPass(),
new RegisterServiceSubscribersPass(),
new DecoratorServicePass(),
new ResolveParameterPlaceHoldersPass(false),
new ResolveFactoryClassPass(),
new CheckDefinitionValidityPass(),
new ResolveNamedArgumentsPass(),
new AutowireRequiredMethodsPass(),
new ResolveBindingsPass(),
new ServiceLocatorTagPass(),
new CheckDefinitionValidityPass(),
new AutowirePass(false),
new ResolveTaggedIteratorArgumentPass(),
new ResolveServiceSubscribersPass(),