Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

derrabus
Copy link
Member

@derrabus derrabus commented Jul 18, 2022

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Part of #44282
License MIT
Doc PR N/A

Symfony 4.4 does not support autowiring union types. Unfortunately, we run into a fatal error when autowiring is attempted for a parameter with an intersection type nested into a union ((A&B)|C). Ironically, the error occurs while we try to generate a nice exception message.

This PR fixes this, so the developer gets a nice exception message about the parameter that cannot be autowired.

For nullable unions however, null is injected. This already was the case for A|null and it works out of the box for (A&B)|null. I've added a test case that covers this case.

@carsonbot carsonbot changed the title Fail gracefully when attempting to autowire composite types [DependencyInjection] Fail gracefully when attempting to autowire composite types Jul 18, 2022
@carsonbot carsonbot added this to the 4.4 milestone Jul 18, 2022
@derrabus derrabus mentioned this pull request Jul 18, 2022
29 tasks
@fabpot
Copy link
Member

fabpot commented Jul 19, 2022

Thank you @derrabus.

@fabpot fabpot merged commit 64afde5 into symfony:4.4 Jul 19, 2022
@derrabus derrabus deleted the bugfix/autowire-composite-types branch July 19, 2022 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants