Skip to content

Commit

Permalink
Merge pull request #3 from campings-group/php-8
Browse files Browse the repository at this point in the history
fix(php): do not call deprecated ReflectionProperty::getClass
  • Loading branch information
cboucaut-campings authored Sep 6, 2021
2 parents fedd96d + 5e2654a commit 3de8dd0
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/HttpCall/HttpCallResultPoolResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,35 @@ 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];
if ($dependency = $this->resolveDependency($parameter)) {
$arguments[$parameter->name] = $dependency;
}
}
}
return $arguments;
}

private function resolveDependency(\ReflectionParameter $parameter)
{
if (method_exists($parameter, 'getType')) {
if (
($type = $parameter->getType()) &&
!$type->isBuiltin() &&
($name = $type->getName()) &&
isset($this->dependencies[$name])
) {
return $this->dependencies[$name];
}
return null;
}

if (
null !== $parameter->getClass()
&& isset($this->dependencies[$parameter->getClass()->name])
) {
return $this->dependencies[$parameter->getClass()->name];
}

return null;
}
}

0 comments on commit 3de8dd0

Please sign in to comment.