[Autowiring] - Rephrase aliasing when multiple classes with same interface #9755
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.
This PR aims to enforce the "non-magic" aspect of the Autowiring.
Especially that sentence:
If you register this as a service, you now have two services that implement the App\Util\TransformerInterface type. Symfony doesn't know which one should be used for autowiring, so you need to choose one by creating an alias from the type to the correct service id (see Working with Interfaces).
This:
Symfony doesn't know which one should be used for autowiring
The more I read the more I think it is clear, but somehow It feels like, after one or two readings, you could understand that Symfony is somehow "choosing" by some sort of magic the service (i.e: Reflection for instance). Where it is definitely not and the "developer" must decide and tells the autowiring which one to use.
I think the current sentence is also clearer when you read all the documentation page where often (I guess) developers go straight to what they need and in this case "how to configure when you have an interface and multiple classes"
So I propose this change (which should not hurt) and open the discussion. Feel free to close if you think it is useless, I won't mind it did not take that long to do the PR ;)