Skip to content

Commit

Permalink
pass calls to overloaded method if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Gummibeer authored Jun 21, 2020
1 parent f7a3fa1 commit 323c5f2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Support/Reflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,19 @@ public static function call(object $object, string $method, array $args = [])
{
$reflectionClass = new ReflectionClass($object);

$reflectionMethod = $reflectionClass->getMethod($method);
try {
$reflectionMethod = $reflectionClass->getMethod($method);

$reflectionMethod->setAccessible(true);
$reflectionMethod->setAccessible(true);

return $reflectionMethod->invoke($object, ...$args);
return $reflectionMethod->invoke($object, ...$args);
} catch(ReflectionException $ex) {
if (method_exists($object, '__call')) {
return $object->__call($method, $args);
}

throw $ex;
}
}

/**
Expand Down

0 comments on commit 323c5f2

Please sign in to comment.