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
Fabien Potencier 6cc9dc7586 feature #22060 [DI] Add "by-id" autowiring: a side-effect free variant of it based on the class<>id convention (nicolas-grekas)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Add "by-id" autowiring: a side-effect free variant of it based on the class<>id convention

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This PR adds a new autowiring mode, based only on the class <> id convention.
This way of autowiring is free from any conflicting behavior, which is what I was looking for to begin with.

The expected DX is a bit more involving than the current way we do autowiring. But it's worth it to me, because it's plain predictable - a lot less "magic" imho.

So in this mode, for each `App\Foo` type hint, a reference to an "App\Foo" service will be created. If no such service exists, an exception will be thrown. To me, this opens a nice DX: when type hinting interfaces (which is the best practice), this will tell you when you need to create the explicit interface <> id mapping that is missing - thus encourage things to be made explicit, but only when required, and gradually, in a way that will favor discoverability by devs.

Of course, this is opt-in, and BC. You'd need to do eg in yaml: `autowire: by_id`.
For consistency, the current mode (`autowire: true`) can be configured using `autowire: by_type`.

Commits
-------

c298f2a90c [DI] Add "by-id" autowiring: a side-effect free variant of it based on the class<>id convention
2017-03-25 13:18:59 -07: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
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 [DependencyInjection] Resolve aliases before removing abstract services + add tests 2016-04-06 19:38:23 +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 [*Bundle] Add autowiring aliases for common services 2017-03-21 22:34:27 +01: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 [DI] Add "by-id" autowiring: a side-effect free variant of it based on the class<>id convention 2017-03-24 15:54:23 +01:00
services29.xml [DI] Allow definitions to inherit tags from parent context 2017-01-07 17:43:10 +01:00
services_deprecated.xml [DependencyInjection] Fixed deprecated default message template with XML 2016-07-26 18:50:32 +02:00
services_instanceof.xml [DI] Replace wildcard-based methods autowiring by @required annotation 2017-02-28 10:00:46 +01:00
services_named_args.xml [DependencyInjection] Add a new pass to check arguments validity 2017-02-13 10:03:44 +01:00
services_prototype.xml [DI] Add "psr4" service attribute for PSR4-based discovery and registration 2017-02-12 23:09:17 +01: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