pass calls to overloaded method if possible

fix #108
This commit is contained in:
Tom Witkowski
2020-06-21 11:55:32 +02:00
committed by GitHub
parent f7a3fa15f4
commit 323c5f211f

View File

@ -27,11 +27,19 @@ final class Reflection
{ {
$reflectionClass = new ReflectionClass($object); $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;
}
} }
/** /**