Skip to content

Commit

Permalink
fix deprecated reflection calls for php 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaleta committed Nov 4, 2021
1 parent b6781ab commit b71cfde
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Hydrator/ReadOnlyHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,20 +306,19 @@ protected function getPhpForMethod(\ReflectionMethod $reflectionMethod, array $p
*/
protected function getPhpForParameter(\ReflectionParameter $parameter)
{
$type = $parameter->getType();

$php = null;
if (
version_compare(PHP_VERSION, '7.1.0', '>=')
&& $parameter->hasType()
&& $parameter->getType()->allowsNull()
&& $type->allowsNull()
) {
$php .= '?';
}
if ($parameter->getClass() instanceof \ReflectionClass) {
$php .= $this->getFullQualifiedClassName($parameter->getClass()->name) . ' ';
} elseif ($parameter->isCallable()) {
$php .= 'callable ';
} elseif ($parameter->isArray()) {
$php .= 'array ';

if ($type instanceof \ReflectionClass) {
$php .= $this->getFullQualifiedClassName($type->getName()) . ' ';
} elseif (
version_compare(PHP_VERSION, '7.0.0', '>=')
&& $parameter->hasType()
Expand Down

0 comments on commit b71cfde

Please sign in to comment.