From a72d06f32f04baef44b7950a9e98229f1a5eec10 Mon Sep 17 00:00:00 2001 From: Vincent Chalamon Date: Fri, 30 Oct 2020 13:24:32 +0100 Subject: [PATCH] Support PHP 8 + fix deprecation --- src/HttpCall/HttpCallResultPoolResolver.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/HttpCall/HttpCallResultPoolResolver.php b/src/HttpCall/HttpCallResultPoolResolver.php index 988d8533..f8810806 100644 --- a/src/HttpCall/HttpCallResultPoolResolver.php +++ b/src/HttpCall/HttpCallResultPoolResolver.php @@ -3,6 +3,7 @@ namespace Behatch\HttpCall; use Behat\Behat\Context\Argument\ArgumentResolver; +use ReflectionClass; class HttpCallResultPoolResolver implements ArgumentResolver { @@ -23,11 +24,12 @@ public function resolveArguments(\ReflectionClass $classReflection, array $argum if ($constructor !== null) { $parameters = $constructor->getParameters(); foreach ($parameters as $parameter) { - if ( - null !== $parameter->getClass() - && isset($this->dependencies[$parameter->getClass()->name]) - ) { - $arguments[$parameter->name] = $this->dependencies[$parameter->getClass()->name]; + $class = PHP_VERSION_ID < 80000 ? $parameter->getClass() : ($parameter->getType() && !$parameter->getType()->isBuiltin() + ? new ReflectionClass($parameter->getType()->getName()) + : null + ); + if (null !== $class && isset($this->dependencies[$class->name])) { + $arguments[$parameter->name] = $this->dependencies[$class->name]; } } }