1 | <?php |
||
13 | class Helper |
||
14 | { |
||
15 | /** |
||
16 | * Merges two or more arrays into one recursively. |
||
17 | * Based on Yii2 yii\helpers\BaseArrayHelper::merge. |
||
18 | * @param array $a array to be merged to |
||
19 | * @param array $b array to be merged from |
||
20 | * @return array the merged array |
||
21 | */ |
||
22 | public static function mergeConfig($a, $b) |
||
23 | { |
||
24 | $args = func_get_args(); |
||
25 | $res = array_shift($args); |
||
26 | foreach ($args as $items) { |
||
27 | if (!is_array($items)) { |
||
28 | continue; |
||
29 | } |
||
30 | foreach ($items as $k => $v) { |
||
31 | if (is_int($k)) { |
||
32 | if (isset($res[$k])) { |
||
33 | $res[] = $v; |
||
34 | } else { |
||
35 | $res[$k] = $v; |
||
36 | } |
||
37 | } elseif (is_array($v) && isset($res[$k]) && is_array($res[$k])) { |
||
38 | $res[$k] = self::mergeConfig($res[$k], $v); |
||
39 | } else { |
||
40 | $res[$k] = $v; |
||
41 | } |
||
42 | } |
||
43 | } |
||
44 | |||
45 | return $res; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Dumps closure object to string. |
||
50 | * Based on http://www.metashock.de/2013/05/dump-source-code-of-closure-in-php/ |
||
51 | * @param Closure $c |
||
52 | * @return string |
||
53 | */ |
||
54 | public static function dumpClosure(Closure $c) { |
||
83 | |||
84 | /** |
||
85 | * Returns a parsable string representation of given value. |
||
86 | * In contrast to var_dump outputs Closures as PHP code. |
||
87 | * @param mixed $value |
||
88 | * @return string |
||
89 | */ |
||
90 | public static function exportVar($value) |
||
104 | |||
105 | /** |
||
106 | * Collects closures from given input. |
||
107 | * Substitutes closures with a tag. |
||
108 | * @param mixed $input will be changed |
||
109 | * @return array array of found closures |
||
110 | */ |
||
111 | private static function collectClosures(&$input) { |
||
129 | } |
||
130 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.