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
Fabien Potencier 831bdc3201 bug #25282 [DI] Register singly-implemented interfaces when doing PSR-4 discovery (nicolas-grekas)
This PR was merged into the 3.4 branch.

Discussion
----------

[DI] Register singly-implemented interfaces when doing PSR-4 discovery

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

I'm feeling bad for not having this idea before 3.4.0 went out, therefore submitting on 3.4, despite this being a new feature, technically. On a DX pov still, this is a bugfix :) I'll let you accept the argument or not...

So, when doing PSR-4-based service registration, we keep only classes as services.
This systematically leads to the question: "But what about interfaces, shouldn't we type-hint against abstractions and not classes?!"
And the answer has invariably been: "Well, just create an alias!"
Which means doing configuration manually.

I fear that if we leave things as is, we're going to grow a "generation" of devs that will hijack autowiring and abuse hinting for classes instead of interfaces.

BUT, here is the idea implemented by this PR: let's create an alias for every singly-implemented interface we discover while looking for classes!
Plain local, simple, and obvious, isn't it?

Votes pending :)

Commits
-------

fcd4aa7807 [DI] Register singly-implemented interfaces when doing PSR-4 discovery
2017-12-04 11:20:32 -08:00
..
config Throw on service:method factory notation in PHP-based DI configuration 2017-11-17 12:52:23 +03:00
containers [DI] Fix false-positive circular exception 2017-12-01 14:16:38 +01:00
directory [DI][Routing] recursive directory loading 2015-06-02 16:17:59 -07:00
graphviz [DI] Reference tagged services in config 2017-09-28 16:10:08 +02:00
includes Merge branch '3.3' into 3.4 2017-11-23 12:03:08 +01:00
ini [DI] FileLoaders: Allow to explicit type to load 2017-01-10 12:54:54 +01:00
php bug #25255 [Console][DI] Fail gracefully (nicolas-grekas) 2017-12-02 15:04:03 -08:00
Prototype [DI] Register singly-implemented interfaces when doing PSR-4 discovery 2017-12-04 19:49:26 +01:00
xml feature #24484 [DI] Throw accurate failures when accessing removed services (nicolas-grekas) 2017-10-09 21:07:35 -07:00
yaml [DI] Fix cannot bind env var 2017-11-07 09:01:11 +01:00
array.json [DI] Allow processing env vars 2017-09-07 08:08:52 +02:00
Bar.php [DependencyInjection] Support local binding 2017-08-09 11:26:25 +02:00
BarInterface.php [DependencyInjection] Support local binding 2017-08-09 11:26:25 +02:00
CaseSensitiveClass.php Test that named arguments are prioritized over typehinted 2017-11-17 10:42:21 +02:00
CustomDefinition.php [DI] Fixed custom services definition BC break introduced in ec7e70fb… 2016-11-24 11:34:23 +01:00
DeprecatedClass.php [DI] Prevent AutowirePass from triggering irrelevant deprecations 2017-04-05 16:41:09 +02:00
FactoryDummy.php [DependencyInjection] Automatically detect the definitions class when possible 2016-07-31 12:30:18 +02:00
NamedArgumentsDummy.php [DependencyInjection] Support local binding 2017-08-09 11:26:25 +02:00
ParentNotExists.php [DI] Prevent a ReflectionException during cache:clear when the parent class doesn't exist 2017-11-27 10:49:34 +01:00
SimilarArgumentsDummy.php [DI] Remove scalar typehint in class used in test case 2017-11-19 14:43:05 +01:00
StubbedTranslator.php [DI] Test references inside ServiceLocator are not inlined 2017-04-29 20:26:40 +02:00
TestServiceSubscriber.php [DI] Restrict autowired registration to "same-vendor" namespaces 2017-04-06 11:28:30 +02:00