1 | <?php |
||
13 | class CollectionUtils { |
||
14 | |||
15 | /** |
||
16 | * Returns a proper collection for the given array (also transforms nested collections) |
||
17 | * (experimental API) |
||
18 | * |
||
19 | * @param array|Iterator $collection |
||
20 | * @return Map|ArrayList the collection |
||
21 | * @throws InvalidArgumentException |
||
22 | */ |
||
23 | 8 | public static function fromCollection($collection) { |
|
30 | |||
31 | /** |
||
32 | * @deprecated use fromCollection instead (will be removed in version 1.3) |
||
33 | * @param Iterator $array |
||
34 | * @return Map|ArrayList the collection |
||
35 | */ |
||
36 | public static function fromArray($array) { |
||
39 | |||
40 | 9 | private static function toCollection($data) { |
|
59 | |||
60 | /** |
||
61 | * Recursively transforms data into a map (on the first level, deeper levels |
||
62 | * transformed to an appropriate collection) (experimental API) |
||
63 | * |
||
64 | * @param array|Iterator $collection |
||
65 | * @return Map |
||
66 | */ |
||
67 | 7 | public static function toMap($collection) { |
|
75 | |||
76 | /** |
||
77 | * Recursively transforms data into a list (on the first level, deeper levels |
||
78 | * transformed to an appropriate collection) (experimental API) |
||
79 | * |
||
80 | * @param array|Iterator $collection |
||
81 | * @return ArrayList |
||
82 | */ |
||
83 | 7 | public static function toList($collection) { |
|
90 | |||
91 | /** |
||
92 | * Recursively exports a collection to an array |
||
93 | * |
||
94 | * @param mixed $collection |
||
95 | * @return array |
||
96 | */ |
||
97 | 1 | public static function toArrayRecursive($collection) { |
|
110 | |||
111 | } |
||
112 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.