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/Fixtures/xml
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
..
extension1 moved component and bridge unit tests to the src/ directory 2012-03-29 08:37:22 +02:00
extension2 moved component and bridge unit tests to the src/ directory 2012-03-29 08:37:22 +02:00
extensions moved component and bridge unit tests to the src/ directory 2012-03-29 08:37:22 +02:00
class_from_id.xml [DI] Add tests for class named services 2017-01-07 16:55:01 +01:00
legacy_invalid_alias_definition.xml [DependencyInjection] Deprecate unsupported attributes/elements for alias 2016-01-16 15:18:32 +01:00
namespaces.xml [DependencyInjection] Use DOM instead of SimpleXML for namespace support 2014-04-02 17:32:21 +02:00
nested_service_without_id.xml [DI] Deprecate XML services without ID 2017-05-25 11:24:58 +02:00
nonvalid.xml moved component and bridge unit tests to the src/ directory 2012-03-29 08:37:22 +02:00
services1.xml [*Bundle] Add autowiring aliases for common services 2017-03-21 22:34:27 +01:00
services2.xml Merge branch '2.3' into 2.4 2014-09-17 11:45:32 +02:00
services3.xml moved component and bridge unit tests to the src/ directory 2012-03-29 08:37:22 +02:00
services4_bad_import.xml moved component and bridge unit tests to the src/ directory 2012-03-29 08:37:22 +02:00
services4.xml [DI] FileLoaders: Allow to explicit type to load 2017-01-10 12:54:54 +01:00
services5.xml [DI] Deprecate XML services without ID 2017-05-25 11:24:58 +02:00
services6.xml [DependencyInjection] Use current class as default class for factory declarations 2017-01-24 00:01:39 +01:00
services7.xml moved component and bridge unit tests to the src/ directory 2012-03-29 08:37:22 +02:00
services8.xml [*Bundle] Add autowiring aliases for common services 2017-03-21 22:34:27 +01:00
services9.xml [DI] Generate one file per service factory 2017-08-06 20:25:40 +02:00
services10.xml Do normalization on tag options 2013-12-16 17:04:48 +01:00
services13.xml moved component and bridge unit tests to the src/ directory 2012-03-29 08:37:22 +02:00
services14.xml [DependencyInjection] Fix #10626, use better check on attribute existence and values on XML load 2014-04-03 14:00:33 +02:00
services21.xml [*Bundle] Add autowiring aliases for common services 2017-03-21 22:34:27 +01:00
services22.xml [DependencyInjection] Add autowiring capabilities 2015-10-03 08:39:08 +02:00
services23.xml [DependencyInjection] Add autowiring capabilities 2015-10-03 08:39:08 +02:00
services24.xml [BC BREAK][DI] Always autowire "by id" instead of using reflection against all existing services 2017-04-05 23:48:42 +02:00
services28.xml [DI] Deprecate XML services without ID 2017-05-25 11:24:58 +02:00
services_abstract.xml Merge branch '3.2' into 3.3 2017-05-25 16:10:31 -07:00
services_autoconfigure_with_parent.xml Not allowing autoconfigure, instanceofConditionals or defaults for ChildDefinition 2017-04-28 17:09:21 -04:00
services_autoconfigure.xml [DI] Introducing autoconfigure: automatic _instanceof configuration 2017-04-20 11:20:30 -06:00
services_bindings.xml [DependencyInjection] Support local binding 2017-08-09 11:26:25 +02:00
services_defaults_with_parent.xml Not allowing autoconfigure, instanceofConditionals or defaults for ChildDefinition 2017-04-28 17:09:21 -04:00
services_deprecated.xml [DependencyInjection] Fixed deprecated default message template with XML 2016-07-26 18:50:32 +02:00
services_instanceof_with_parent.xml Not allowing autoconfigure, instanceofConditionals or defaults for ChildDefinition 2017-04-28 17:09:21 -04:00
services_instanceof.xml [DependencyInjection] Support local binding 2017-08-09 11:26:25 +02:00
services_named_args.xml [DependencyInjection] Support local binding 2017-08-09 11:26:25 +02:00
services_prototype.xml Allowing prototype/PSR4 service loading ability to exclude, because glob doesn't support this 2017-05-13 13:10:49 -04:00
services_without_id.xml [DI] Deprecate XML services without ID 2017-05-25 11:24:58 +02:00
tag_with_empty_name.xml [DependencyInjection] enforce tags to have a name 2016-01-27 23:29:55 +01:00
tag_without_name.xml [DependencyInjection] enforce tags to have a name 2016-01-27 23:29:55 +01:00
with_key_outside_collection.xml Cast result to int before adding to it 2016-11-25 15:42:00 +01:00
withdoctype.xml Merge branch '2.0' 2012-08-28 09:54:42 +02:00
xml_with_wrong_ext.php [DI] FileLoaders: Allow to explicit type to load 2017-01-10 12:54:54 +01:00