1
0
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:
Sami Mazouz
2020-12-06 20:58:45 +01:00
committed by GitHub
parent cfa533ebd6
commit 056d420c7b
2 changed files with 142 additions and 2 deletions

View File

@@ -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);
};
}