mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
Pass callback wrapper parameters by reference (#2485)
Because invokable class objects are not directly called and instead it's the callback wrapper that calls these objects, it's currently not possible to receive arguments by reference on an invokable class. To fix this we pass the arguments by reference by default when calling the object in the callback wrapper.
This commit is contained in:
@@ -24,10 +24,10 @@ class ContainerUtil
|
||||
public static function wrapCallback($callback, Container $container)
|
||||
{
|
||||
if (is_string($callback)) {
|
||||
$callback = function () use ($container, $callback) {
|
||||
$callback = function (&...$args) use ($container, $callback) {
|
||||
$callback = $container->make($callback);
|
||||
|
||||
return call_user_func_array($callback, func_get_args());
|
||||
return $callback(...$args);
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user