File tree 1 file changed +3
-3
lines changed
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 10
10
* This function tries to solve the problem of calling a function stored in a class attribute, because if you try
11
11
* `$this->callable($arg1, $arg2)` PHP expects `$this->callable` to be a function and not a property. And to avoid
12
12
* use the magic method _invoke_ that will properly work `$this->callable->__invoke($arg1, $arg2)` we use go with
13
- * `apply($this->callable, $arg1, $arg2)`.
13
+ * `apply($this->callable, [ $arg1, $arg2] )`.
14
14
*
15
15
* Be aware that using this function most IDEs will lose the path, so they will not detect that your are passing the
16
16
* wrong number of parameters or will not do as you expect a change of signature. To have a good test suite would be a
17
17
* requirement for a widely use of this function in your code.
18
18
*
19
19
* @param callable $fn function to be executed
20
- * @param mixed[] $args arguments to be passed to the called function
20
+ * @param iterable $args arguments to be passed to the called function
21
21
*
22
22
* @return mixed
23
23
*
24
24
* @since 0.1
25
25
*/
26
- function apply (callable $ fn , $ args = [])
26
+ function apply (callable $ fn , iterable $ args = [])
27
27
{
28
28
return $ fn (...to_array ($ args ));
29
29
}
You can’t perform that action at this time.
0 commit comments