This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection/Tests
Nicolas Grekas fd16993a37 feature #22187 [DependencyInjection] Support local binding (GuilhemN)
This PR was squashed before being merged into the 3.4 branch (closes #22187).

Discussion
----------

[DependencyInjection] Support local binding

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | https://github.com/symfony/symfony/issues/22167, #23718
| License       | MIT
| Doc PR        |

> A great idea came out on Slack about local bindings.
> We could allow injecting services based on type hints on a per service/file basis:
> ```yml
> services:
>     _defaults:
>         bind:
>             BarInterface: '@usual_bar'
>
>     Foo:
>         bind:
>             BarInterface: '@alternative_bar'
>             $quz: 'quzvalue'
> ```
>
> This way, `@usual_bar` will be injected in any parameter type hinted as `BarInterface` (in a constructor or a method signature), but only for this service/file.
> Note that bindings could be unused, giving a better solution than https://github.com/symfony/symfony/pull/22152 to https://github.com/symfony/symfony/pull/21711.
>
> As named parameters are usable in arguments, bindings could be usable in arguments too:
> ```yml
> services:
>     Foo:
>         arguments:
>             BarInterface: '@bar'
> ```

~Named parameters aren't supported yet.~

Edit:

> Note that bindings could be unused

Current behavior is throwing an exception when a binding is not used at all, in no services of a file if it was inherited from `_defaults` or in no services created from a prototype.
It will pass if the bindings are all used in at least one service.

Commits
-------

81f2652 [DependencyInjection] Support local binding
2017-08-09 11:26:28 +02:00
..
Argument [DI] Introduce "container.service_locator" tag, replaces ServiceLocatorArgument 2017-03-17 17:49:32 +01:00
Compiler feature #22187 [DependencyInjection] Support local binding (GuilhemN) 2017-08-09 11:26:28 +02:00
Config [DI][Router][DX] Invalidate routing cache when container parameters changed 2017-03-05 20:24:24 +01:00
Dumper [DI] Generate one file per service factory 2017-08-06 20:25:40 +02:00
Extension Update to PHPUnit namespaces 2017-02-18 08:02:39 -08:00
Fixtures feature #22187 [DependencyInjection] Support local binding (GuilhemN) 2017-08-09 11:26:28 +02:00
LazyProxy [DI][ProxyManager] Pass the factory code to execute to DumperInterface::getProxyFactoryCode() 2017-07-27 19:12:50 +02:00
Loader feature #22187 [DependencyInjection] Support local binding (GuilhemN) 2017-08-09 11:26:28 +02:00
ParameterBag Refactored other PHPUnit method calls to work with namespaced PHPUnit 6 2017-02-21 11:04:38 +01:00
ChildDefinitionTest.php [DependencyInjection] Fix named args support in ChildDefinition 2017-06-05 09:24:55 -07:00
ContainerBuilderTest.php Merge branch '3.2' into 3.3 2017-07-17 16:07:10 +02:00
ContainerTest.php Merge branch '3.3' into 3.4 2017-07-17 16:07:19 +02:00
CrossCheckTest.php Merge branch '3.2' 2017-02-18 18:35:19 +01:00
DefinitionDecoratorTest.php [DI] Replace wildcard-based methods autowiring by @required annotation 2017-02-28 10:00:46 +01:00
DefinitionTest.php [DI] Introducing autoconfigure: automatic _instanceof configuration 2017-04-20 11:20:30 -06:00
ParameterTest.php Update to PHPUnit namespaces 2017-02-18 08:02:39 -08:00
ReferenceTest.php Merge branch '3.2' 2017-02-18 18:35:19 +01:00
ServiceLocatorTest.php [DI] Remove useless state from ServiceLocator 2017-03-16 19:18:58 +01:00