Extra check when asking for the type
MODIFY
src/Behat/Behat/HelperContainer/ArgumentAutowirer.php
src/Behat/Behat/HelperContainer/ArgumentAutowirer.php
@@ -83,17 +83,17 @@ final class ArgumentAutowirer
return false;
}
- if (!$parameter->getType() instanceof ReflectionNamedType) {
- return false;
- }
-
return (bool) $this->getClassFromParameter($parameter);
}
private function getClassFromParameter(ReflectionParameter $parameter) : ?string
{
+ if (!($type = $parameter->getType()) || !($type instanceof ReflectionNamedType)) {
+ return null;
+ }
+
try {
- $typeString = $parameter->getType()->getName();
+ $typeString = $type->getName();
if ($typeString == 'self') {
return $parameter->getDeclaringClass()->getName();

Extra check when asking for the type