1 | <?php |
||
58 | class lambda |
||
59 | { |
||
60 | /** |
||
61 | * Returns a function with the given arguments already entered or partially applied. |
||
62 | * @param callable $callable The function to curry |
||
63 | * @param array $partialArgs unlimited Optional arguments to curry the function with |
||
64 | * @param array $defaultArgs optional default values |
||
65 | * @return callable |
||
66 | */ |
||
67 | 4 | public static function partial(callable $callable, $partialArgs, $defaultArgs = []) |
|
71 | |||
72 | |||
73 | /** |
||
74 | * Returns a function with named arguments. The peppered function accepts one argument - a named array of values |
||
75 | * @param callable $callable The function or method to pepper |
||
76 | * @param array $namedArgs Optional. The named arguments to pepper the function with, the order must be the order |
||
77 | * in which the unpeppered function expects them. If not set, pepper will use Reflection to get them. |
||
78 | * Format is [ 'argumentName' => 'defaultValue' ] |
||
79 | * @return callable |
||
80 | */ |
||
81 | 2 | public static function pepper(callable $callable, $namedArgs=null) |
|
96 | |||
97 | /** |
||
98 | * Returns a method that will generate and call the given function only once and return its result for every call. |
||
99 | * The first call generates the result. Each subsequent call simply returns that same result. This allows you |
||
100 | * to create in-context singletons for any kind of object. |
||
101 | * <code> |
||
102 | * $proto = \arc\lambda::prototype([ |
||
103 | * 'getSingleton' => \arc\lambda::singleton( function () { |
||
104 | * return new ComplexObject(); |
||
105 | * }) |
||
106 | * ]); |
||
107 | * </code> |
||
108 | * @param callable $f The function to generate the singleton. |
||
109 | * @return mixed The singleton. |
||
110 | */ |
||
111 | 2 | public static function singleton($f) |
|
115 | |||
116 | } |
||
117 |
This check looks for calls to
isset(...)
orempty()
on variables that are yet undefined. These calls will always produce the same result and can be removed.This is most likely caused by the renaming of a variable or the removal of a function/method parameter.