1 | <?php |
||
8 | class ArrayFunctions |
||
9 | { |
||
10 | /** |
||
11 | * Merge two arrays together. |
||
12 | * |
||
13 | * If an integer key exists in both arrays, the value from the second array |
||
14 | * will be appended the the first array. If both values are arrays, they |
||
15 | * are merged together, else the value of the second array overwrites the |
||
16 | * one of the first array. |
||
17 | * |
||
18 | * @see http://packages.zendframework.com/docs/latest/manual/en/index.html#zend-stdlib |
||
19 | * @param array $a |
||
20 | * @param array $b |
||
21 | * @return array |
||
22 | */ |
||
23 | public static function mergeArrays(array $a, array $b) |
||
41 | |||
42 | /** |
||
43 | * @param array $matrix |
||
44 | * @param string $key key to filter |
||
45 | * @param mixed $value to compare against (strict comparison) |
||
46 | * @return array |
||
47 | */ |
||
48 | public static function matrixFilterByValue(array $matrix, $key, $value) |
||
54 | |||
55 | /** |
||
56 | * @param array $matrix |
||
57 | * @param string $key to filter |
||
58 | * @param string $value to compare against |
||
59 | * @return array |
||
60 | */ |
||
61 | public static function matrixFilterStartswith(array $matrix, $key, $value) |
||
67 | |||
68 | /** |
||
69 | * @param array $matrix |
||
70 | * @param callable $callback that when return true on the row will unset it |
||
71 | * @return array |
||
72 | */ |
||
73 | private static function matrixCallbackFilter(array $matrix, $callback) |
||
83 | |||
84 | /** |
||
85 | * @param string[] $columns |
||
86 | * @param array $table |
||
87 | * @return array table with ordered columns |
||
88 | */ |
||
89 | public static function columnOrderArrayTable(array $columns, array $table) |
||
103 | |||
104 | /** |
||
105 | * order array entries (named and numbered) of array by the columns given as string keys. |
||
106 | * |
||
107 | * non-existent columns default to numbered entries or if no numbered entries exists any longer, to null. |
||
108 | * |
||
109 | * entries in array that could not consume any column are put after the columns. |
||
110 | * |
||
111 | * @param string[] $columns |
||
112 | * @param array $array |
||
113 | * @return array |
||
114 | */ |
||
115 | public static function columnOrder(array $columns, array $array) |
||
147 | } |
||
148 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.