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

Fix: PHP 8 Support - do not call deprecated ReflectionProperty::getClass #298

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"behat/behat": "^3.0.13",
"friends-of-behat/mink-extension": "^2.3.1",
"justinrainbow/json-schema": "^5.0",
"symfony/property-access": "^2.3|^3.0|^4.0|^5.0",
"symfony/http-foundation": "^2.3|^3.0|^4.0|^5.0",
"symfony/dom-crawler": "^2.4|^3.0|^4.0|^5.0"
"symfony/property-access": "^2.3|^3.0|^4.0|^5.0|^6.0|^7.0",
"symfony/http-foundation": "^2.3|^3.0|^4.0|^5.0|^6.0|^7.0",
"symfony/dom-crawler": "^2.4|^3.0|^4.0|^5.0|^6.0|^7.0"
},

"require-dev": {
Expand Down
3 changes: 3 additions & 0 deletions src/Context/JsonContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ public function theJsonNodeShouldExist($name)
} catch (\Exception $e) {
throw new \Exception("The node '$name' does not exist.");
}
if (!$node) {
throw new \Exception("The node '$name' does not exist.");
}
return $node;
}

Expand Down
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;
}
}