Skip to content

Commit c080da7

Browse files
Fix deprecation errors related to Reflection
1 parent 58e1f2d commit c080da7

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

ArgumentValidator.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ public function __construct(
3030

3131
public function validate(\ReflectionParameter $parameter, $argument)
3232
{
33-
if ($parameter->isArray()) {
33+
$parameterType = $parameter->getType();
34+
if ($parameterType === null) {
35+
return;
36+
}
37+
38+
if ($parameterType->getName() === 'array') {
3439
$this->validateArrayArgument($parameter, $argument);
35-
} elseif ($parameter->getClass()) {
36-
$this->validateObjectArgument($parameter->getClass()->getName(), $argument, $parameter->allowsNull());
40+
} elseif (class_exists($parameterType->getName())) {
41+
$this->validateObjectArgument($parameterType->getName(), $argument, $parameter->allowsNull());
3742
}
3843

3944
// other arguments don't need to be or can't be validated

ArgumentsValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private function shouldParameterHaveAnArgument(\ReflectionParameter $parameter)
4141
return false;
4242
}
4343

44-
if ($parameter->getClass() && $parameter->allowsNull()) {
44+
if ($parameter->getType() instanceof \ReflectionType && $parameter->getType()->allowsNull()) {
4545
// e.g. LoggerInterface $logger = null
4646
return false;
4747
}

0 commit comments

Comments
 (0)