diff --git a/src/Support/Reflection.php b/src/Support/Reflection.php index c25709b9..1fac05b7 100644 --- a/src/Support/Reflection.php +++ b/src/Support/Reflection.php @@ -153,4 +153,21 @@ final class Reflection return $name; } + + /** + * Receive a map of function argument names to their types. + * + * @return array + */ + public static function getFunctionArguments(Closure $function): array + { + $parameters = (new ReflectionFunction($function))->getParameters(); + $arguments = []; + + foreach ($parameters as $parameter) { + $arguments[$parameter->getName()] = ($parameter->hasType()) ? $parameter->getType() : 'mixed'; + } + + return $arguments; + } }