-
-
Notifications
You must be signed in to change notification settings - Fork 327
Description
Thanks for merging the PR on #362, but unfortunately I've just discovered a couple of bugs that it creates/reveals.
There are two big issues:
-
If a type-hinted factory parameter is resolvable from the container, any supplied parameter will be ignored
This is an easy fix - just need to bump AssociativeArrayResolver to the top of the ResolverChain in FactoryResolver.php
-
FactoryParameterResolver overwrites already resolved parameters
Again, a simple fix - just needs this preamble added (taken from other resolvers in php-di/invoker):
$parameters = $reflection->getParameters(); // Skip parameters already resolved if (! empty($resolvedParameters)) { $parameters = array_diff_key($parameters, $resolvedParameters); }
I'm happy to prepare a PR to fix these (or just provide tests for reproduction), but wanted your input: FactoryParameterResolver could be replaced with a combination of TypeHintResolver and TypeHintContainerResolver. Would you prefer a fix to FactoryParameterResolver, or removing it in favour of the two TypeHint resolvers?