-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Add iterable to possible binding type #44979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Please add a test case that covers the situation. |
Add test for this case |
@nicolas-grekas done |
@@ -212,6 +213,31 @@ public function testEmptyBindingTypehint() | |||
$pass->process($container); | |||
} | |||
|
|||
public function testIterableBindingTypehint() | |||
{ | |||
spl_autoload_register( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this required? if not let's remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's required to show the problem, if this function will run it will mean that code of ResolveBindingsPass.php working incorrect
$pass = new ResolveBindingsPass(); | ||
$pass->process($container); | ||
|
||
$this->assertInstanceOf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on one line please
); | ||
|
||
$container = new ContainerBuilder(); | ||
$bindings = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the variable could be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(for 4.4)
Thank you @sveneld. |
This PR was submitted for the 5.4 branch but it was merged into the 4.4 branch instead. Discussion ---------- [DependencyInjection] Fix type binding | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | License | MIT If $type is a scalar compiler pass should not check it in function is_subclass_of($type, \UnitEnum::class), because is_subclass_of trying to autoload class with name array, string, etc. Related to #44979 Commits ------- 3754018 Fix type binding
When iterable type is set in binding like in example https://symfony.com/doc/current/service_container.html#binding-arguments-by-name-or-type, system tries to autoload class iterable here src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php:137