831bdc3201
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
-------
|
||
---|---|---|
.. | ||
config | ||
containers | ||
directory | ||
graphviz | ||
includes | ||
ini | ||
php | ||
Prototype | ||
xml | ||
yaml | ||
array.json | ||
Bar.php | ||
BarInterface.php | ||
CaseSensitiveClass.php | ||
CustomDefinition.php | ||
DeprecatedClass.php | ||
FactoryDummy.php | ||
NamedArgumentsDummy.php | ||
ParentNotExists.php | ||
SimilarArgumentsDummy.php | ||
StubbedTranslator.php | ||
TestServiceSubscriber.php |