Make the condition more readable in ArgumentAutowirer
MODIFY
src/Behat/Behat/HelperContainer/ArgumentAutowirer.php
src/Behat/Behat/HelperContainer/ArgumentAutowirer.php
@@ -14,6 +14,7 @@ use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use ReflectionFunctionAbstract;
use ReflectionParameter;
+use ReflectionException;
/**
* Automatically wires arguments of a given function from inside the container by using type-hitns.
@@ -72,6 +73,18 @@ final class ArgumentAutowirer
*/
private function isArgumentWireable(array $arguments, $index, ReflectionParameter $parameter)
{
- return !isset($arguments[$index]) && !isset($arguments[$parameter->getName()]) && !array_key_exists($index, $arguments) && !array_key_exists($parameter->getName(), $arguments) && $parameter->getClass();
+ if (isset($arguments[$index]) || array_key_exists($index, $arguments)) {
+ return false;
+ }
+
+ if (isset($arguments[$parameter->getName()]) || array_key_exists($parameter->getName(), $arguments)) {
+ return false;
+ }
+
+ try {
+ return (bool) $parameter->getClass();
+ } catch (ReflectionException $e) {
+ return false;
+ }
}
}

Make the condition more readable in ArgumentAutowirer