Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

Commit

Permalink
Support PHP 8 + fix deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon committed Oct 30, 2020
1 parent 78b29a4 commit a72d06f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/HttpCall/HttpCallResultPoolResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Behatch\HttpCall;

use Behat\Behat\Context\Argument\ArgumentResolver;
use ReflectionClass;

class HttpCallResultPoolResolver implements ArgumentResolver
{
Expand All @@ -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];
}
}
}
Expand Down

0 comments on commit a72d06f

Please sign in to comment.