/** * Call the given callable, using arguments determined from the given values using the getArguments() method. * * @param callable $callable Method or function reference, name or reflection object. * @param array|null $fixedValues Values that are required at the start of the argument list. These will be used * before any other values in determining the argument list. If there are more elements than the number of * arguments specified by the callable, then not all elements will be used. * @param array|null $typedValues Values that are detected by type hinting. Not all these values are necessarily * used, only those that are matched by type against the callable's argument list. * @param array|null $remainingValues Values that are used when all the fixed values are used, and there are no * matching typed values. Remaining values are used in preference to the parameter default values. * * @return mixed Result of invoking the given callable using the arguments as determined using supplied values. * * @throws \RuntimeException If there are insufficient matching values provided to pass for all required arguments. */ public static function invokeCallable($callable, array $fixedValues = null, array $typedValues = null, array $remainingValues = null) { return call_user_func_array($callable, TypeUtilities::getArguments($callable, $fixedValues, $typedValues, $remainingValues)); }