Skip to content

Commit

Permalink
Add missing parameter type (#84)
Browse files Browse the repository at this point in the history
Co-authored-by: Rafa Gómez <rgomezcasas@gmail.com>
  • Loading branch information
jdreesen and rgomezcasas authored Jun 30, 2020
1 parent a5e02f2 commit 2e41ff9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
* This function tries to solve the problem of calling a function stored in a class attribute, because if you try
* `$this->callable($arg1, $arg2)` PHP expects `$this->callable` to be a function and not a property. And to avoid
* use the magic method _invoke_ that will properly work `$this->callable->__invoke($arg1, $arg2)` we use go with
* `apply($this->callable, $arg1, $arg2)`.
* `apply($this->callable, [$arg1, $arg2])`.
*
* Be aware that using this function most IDEs will lose the path, so they will not detect that your are passing the
* wrong number of parameters or will not do as you expect a change of signature. To have a good test suite would be a
* requirement for a widely use of this function in your code.
*
* @param callable $fn function to be executed
* @param mixed[] $args arguments to be passed to the called function
* @param iterable $args arguments to be passed to the called function
*
* @return mixed
*
* @since 0.1
*/
function apply(callable $fn, $args = [])
function apply(callable $fn, iterable $args = [])
{
return $fn(...to_array($args));
}
Expand Down

0 comments on commit 2e41ff9

Please sign in to comment.