[DI] Autoregister FQCN refs as definitions when target does not exist #21904
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was looking for a way to save a definition declaration when one uses a FQCN reference:
and not have to declare
App\Foo.One way to achieve this is to couple it with autowiring: if the
@App\Fooref is invalid,AutowirePasscan create the target service. This was done in #21859 and further enhanced in #21873 (which adds the requirement that this can happen only in autowired holder definitions.)Then I wondered: what would one expect with
_defaultsand_instanceof?eg
Should the
App\Foodefinition get thefoo_tag? Might be a yes, especially if we teach that:is equivalent to:
you still follow me?
This is what this PR achieves - and for this, it needs to work at the loader level.
The next step is working with
@App\FooInterface: to me, since this cannot be a definition, it has to play well with autowiring, which should be applicable (opt-in-only as usual) to find the correct service implenentingApp\FooInterface. OK?But then, let's says we have
class Bar extends Foo {}, and this config:What should
@App\Foobe resolved to?App\Baras autowiring would do with the corresponding type hint? Or an implicit newApp\Foodefinition as the previous equivalence principle would lead to?That's ambiguous to me.