Skip to content

Commit

Permalink
DependencyChecker: fixed compatibility with PHP 8 [Closes #247]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 4, 2020
1 parent 8d796de commit 47688f3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/DI/DependencyChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,15 @@ class_uses($name),
}
foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
if ($method->getDeclaringClass() == $class) { // intentionally ==
$type = $method->getReturnType();
$hash[] = [
$name,
$method->name,
$method->getDocComment(),
self::hashParameters($method),
$method->hasReturnType()
? [$method->getReturnType()->getName(), $method->getReturnType()->allowsNull()]
: null,
PHP_VERSION_ID < 80000
? ($type ? [$type->getName(), $type->allowsNull()] : null)
: (string) $type,
];
}
}
Expand All @@ -158,14 +159,15 @@ class_uses($name),
$method = new \ReflectionFunction($name);
$uses = null;
}
$type = $method->getReturnType();
$hash[] = [
$name,
$uses,
$method->getDocComment(),
self::hashParameters($method),
$method->hasReturnType()
? [$method->getReturnType()->getName(), $method->getReturnType()->allowsNull()]
: null,
PHP_VERSION_ID < 80000
? ($type ? [$type->getName(), $type->allowsNull()] : null)
: (string) $type,
];
}

Expand All @@ -179,8 +181,9 @@ private static function hashParameters(\ReflectionFunctionAbstract $method): arr
foreach ($method->getParameters() as $param) {
$res[] = [
$param->name,
Reflection::getParameterType($param),
$param->allowsNull(),
PHP_VERSION_ID < 80000
? [Reflection::getParameterType($param), $param->allowsNull()]
: (string) $param->getType(),
$param->isVariadic(),
$param->isDefaultValueAvailable()
? [Reflection::getParameterDefaultValue($param)]
Expand Down

0 comments on commit 47688f3

Please sign in to comment.