Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Arrayy often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Arrayy, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
27 | class Arrayy extends \ArrayObject implements \IteratorAggregate, \ArrayAccess, \Serializable, \JsonSerializable, \Countable |
||
28 | { |
||
29 | const ARRAYY_HELPER_TYPES_FOR_ALL_PROPERTIES = '!!!!Arrayy_Helper_Types_For_All_Properties!!!!'; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | * |
||
34 | * @psalm-var array<mixed,mixed>|array<TKey,T> |
||
35 | */ |
||
36 | protected $array = []; |
||
37 | |||
38 | /** |
||
39 | * @var \Arrayy\ArrayyRewindableGenerator|null |
||
40 | * |
||
41 | * @psalm-var \Arrayy\ArrayyRewindableGenerator<TKey,T>|null |
||
42 | */ |
||
43 | protected $generator; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | * |
||
48 | * @psalm-var class-string<\Arrayy\ArrayyIterator> |
||
49 | */ |
||
50 | protected $iteratorClass = ArrayyIterator::class; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $pathSeparator = '.'; |
||
56 | |||
57 | /** |
||
58 | * @var bool |
||
59 | */ |
||
60 | protected $checkPropertyTypes = false; |
||
61 | |||
62 | /** |
||
63 | * @var bool |
||
64 | */ |
||
65 | protected $checkForMissingPropertiesInConstructor = false; |
||
66 | |||
67 | /** |
||
68 | * @var bool |
||
69 | */ |
||
70 | protected $checkPropertiesMismatchInConstructor = false; |
||
71 | |||
72 | /** |
||
73 | * @var bool |
||
74 | */ |
||
75 | protected $checkPropertiesMismatch = true; |
||
76 | |||
77 | /** |
||
78 | * @var array<int|string,TypeCheckInterface>|mixed|TypeCheckArray<int|string,TypeCheckInterface>|TypeInterface |
||
79 | */ |
||
80 | protected $properties = []; |
||
81 | |||
82 | /** |
||
83 | * Initializes |
||
84 | * |
||
85 | * @param mixed $data <p> |
||
86 | * Should be an array or a generator, otherwise it will try |
||
87 | * to convert it into an array. |
||
88 | * </p> |
||
89 | * @param string $iteratorClass optional <p> |
||
90 | * You can overwrite the ArrayyIterator, but mostly you don't |
||
91 | * need this option. |
||
92 | * </p> |
||
93 | * @param bool $checkPropertiesInConstructor optional <p> |
||
94 | * You need to extend the "Arrayy"-class and you need to set |
||
95 | * the $checkPropertiesMismatchInConstructor class property |
||
96 | * to |
||
97 | * true, otherwise this option didn't not work anyway. |
||
98 | * </p> |
||
99 | * |
||
100 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
101 | */ |
||
102 | 1196 | public function __construct( |
|
119 | |||
120 | /** |
||
121 | * @return void |
||
122 | */ |
||
123 | 50 | public function __clone() |
|
133 | |||
134 | /** |
||
135 | * Call object as function. |
||
136 | * |
||
137 | * @param mixed $key |
||
138 | * |
||
139 | * @return mixed |
||
140 | */ |
||
141 | 1 | public function __invoke($key = null) |
|
151 | |||
152 | /** |
||
153 | * Whether or not an element exists by key. |
||
154 | * |
||
155 | * @param mixed $key |
||
156 | * |
||
157 | * @return bool |
||
158 | * <p>True is the key/index exists, otherwise false.</p> |
||
159 | */ |
||
160 | public function __isset($key): bool |
||
164 | |||
165 | /** |
||
166 | * Assigns a value to the specified element. |
||
167 | * |
||
168 | * @param mixed $key |
||
169 | * @param mixed $value |
||
170 | * |
||
171 | * @return void |
||
172 | */ |
||
173 | 3 | public function __set($key, $value) |
|
177 | |||
178 | /** |
||
179 | * magic to string |
||
180 | * |
||
181 | * @return string |
||
182 | */ |
||
183 | 15 | public function __toString(): string |
|
187 | |||
188 | /** |
||
189 | * Unset element by key. |
||
190 | * |
||
191 | * @param mixed $key |
||
192 | */ |
||
193 | public function __unset($key) |
||
197 | |||
198 | /** |
||
199 | * Get a value by key. |
||
200 | * |
||
201 | * @param mixed $key |
||
202 | * |
||
203 | * @return mixed |
||
204 | * <p>Get a Value from the current array.</p> |
||
205 | */ |
||
206 | 8 | public function &__get($key) |
|
216 | |||
217 | /** |
||
218 | * Add new values (optional using dot-notation). |
||
219 | * |
||
220 | * @param mixed $value |
||
221 | * @param int|string|null $key |
||
222 | * |
||
223 | * @return static |
||
224 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
225 | * |
||
226 | * @psalm-param T $value |
||
227 | * @psalm-return static<TKey,T> |
||
228 | */ |
||
229 | 12 | public function add($value, $key = null) |
|
247 | |||
248 | /** |
||
249 | * Append a (key) + value to the current array. |
||
250 | * |
||
251 | * @param mixed $value |
||
252 | * @param mixed $key |
||
253 | * |
||
254 | * @return $this |
||
255 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
256 | * |
||
257 | * @psalm-return static<TKey,T> |
||
258 | */ |
||
259 | 19 | public function append($value, $key = null): self |
|
287 | |||
288 | /** |
||
289 | * Sort the entries by value. |
||
290 | * |
||
291 | * @param int $sort_flags [optional] <p> |
||
292 | * You may modify the behavior of the sort using the optional |
||
293 | * parameter sort_flags, for details |
||
294 | * see sort. |
||
295 | * </p> |
||
296 | * |
||
297 | * @return $this |
||
298 | * <p>(Mutable) Return this Arrayy object.</p> |
||
299 | * |
||
300 | * @psalm-return static<TKey,T> |
||
301 | */ |
||
302 | 4 | public function asort(int $sort_flags = 0): self |
|
310 | |||
311 | /** |
||
312 | * Sort the entries by value. |
||
313 | * |
||
314 | * @param int $sort_flags [optional] <p> |
||
315 | * You may modify the behavior of the sort using the optional |
||
316 | * parameter sort_flags, for details |
||
317 | * see sort. |
||
318 | * </p> |
||
319 | * |
||
320 | * @return $this |
||
321 | * <p>(Immutable) Return this Arrayy object.</p> |
||
322 | * |
||
323 | * @psalm-return static<TKey,T> |
||
324 | * @psalm-mutation-free |
||
325 | */ |
||
326 | 4 | public function asortImmutable(int $sort_flags = 0): self |
|
337 | |||
338 | /** |
||
339 | * Counts all elements in an array, or something in an object. |
||
340 | * |
||
341 | * <p> |
||
342 | * For objects, if you have SPL installed, you can hook into count() by implementing interface {@see Countable}. |
||
343 | * The interface has exactly one method, {@see Countable::count()}, which returns the return value for the count() |
||
344 | * function. Please see the {@see Array} section of the manual for a detailed explanation of how arrays are |
||
345 | * implemented and used in PHP. |
||
346 | * </p> |
||
347 | * |
||
348 | * @see http://php.net/manual/en/function.count.php |
||
349 | * |
||
350 | * @param int $mode [optional] If the optional mode parameter is set to |
||
351 | * COUNT_RECURSIVE (or 1), count |
||
352 | * will recursively count the array. This is particularly useful for |
||
353 | * counting all the elements of a multidimensional array. count does not detect infinite recursion. |
||
354 | * |
||
355 | * @return int |
||
356 | * <p> |
||
357 | * The number of elements in var, which is |
||
358 | * typically an array, since anything else will have one |
||
359 | * element. |
||
360 | * </p> |
||
361 | * <p> |
||
362 | * If var is not an array or an object with |
||
363 | * implemented Countable interface, |
||
364 | * 1 will be returned. |
||
365 | * There is one exception, if var is &null;, |
||
366 | * 0 will be returned. |
||
367 | * </p> |
||
368 | * <p> |
||
369 | * Caution: count may return 0 for a variable that isn't set, |
||
370 | * but it may also return 0 for a variable that has been initialized with an |
||
371 | * empty array. Use isset to test if a variable is set. |
||
372 | * </p> |
||
373 | * @psalm-mutation-free |
||
374 | */ |
||
375 | 147 | public function count(int $mode = \COUNT_NORMAL): int |
|
387 | |||
388 | /** |
||
389 | * Exchange the array for another one. |
||
390 | * |
||
391 | * @param array|static $data |
||
392 | * |
||
393 | * @return array |
||
394 | * |
||
395 | * @psalm-param array<TKey,T>|self<TKey,T> $data |
||
396 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
397 | */ |
||
398 | 1 | public function exchangeArray($data): array |
|
404 | |||
405 | /** |
||
406 | * Creates a copy of the ArrayyObject. |
||
407 | * |
||
408 | * @return array |
||
409 | * |
||
410 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
411 | */ |
||
412 | 6 | public function getArrayCopy(): array |
|
418 | |||
419 | /** |
||
420 | * Returns a new iterator, thus implementing the \Iterator interface. |
||
421 | * |
||
422 | * @return \Iterator<mixed, mixed> |
||
423 | * <p>An iterator for the values in the array.</p> |
||
424 | * @psalm-return \Iterator<array-key|TKey, mixed|T> |
||
425 | */ |
||
426 | 27 | public function getIterator(): \Iterator |
|
443 | |||
444 | /** |
||
445 | * Gets the iterator classname for the ArrayObject. |
||
446 | * |
||
447 | * @return string |
||
448 | * |
||
449 | * @psalm-return class-string |
||
450 | */ |
||
451 | 26 | public function getIteratorClass(): string |
|
455 | |||
456 | /** |
||
457 | * Sort the entries by key. |
||
458 | * |
||
459 | * @param int $sort_flags [optional] <p> |
||
460 | * You may modify the behavior of the sort using the optional |
||
461 | * parameter sort_flags, for details |
||
462 | * see sort. |
||
463 | * </p> |
||
464 | * |
||
465 | * @return $this |
||
466 | * <p>(Mutable) Return this Arrayy object.</p> |
||
467 | * |
||
468 | * @psalm-return static<TKey,T> |
||
469 | */ |
||
470 | 4 | public function ksort(int $sort_flags = 0): self |
|
478 | |||
479 | /** |
||
480 | * Sort the entries by key. |
||
481 | * |
||
482 | * @param int $sort_flags [optional] <p> |
||
483 | * You may modify the behavior of the sort using the optional |
||
484 | * parameter sort_flags, for details |
||
485 | * see sort. |
||
486 | * </p> |
||
487 | * |
||
488 | * @return $this |
||
489 | * <p>(Immutable) Return this Arrayy object.</p> |
||
490 | * |
||
491 | * @psalm-return static<TKey,T> |
||
492 | */ |
||
493 | 4 | public function ksortImmutable(int $sort_flags = 0): self |
|
504 | |||
505 | /** |
||
506 | * Sort an array using a case insensitive "natural order" algorithm. |
||
507 | * |
||
508 | * @return $this |
||
509 | * <p>(Mutable) Return this Arrayy object.</p> |
||
510 | * |
||
511 | * @psalm-return static<TKey,T> |
||
512 | */ |
||
513 | 8 | public function natcasesort(): self |
|
521 | |||
522 | /** |
||
523 | * Sort an array using a case insensitive "natural order" algorithm. |
||
524 | * |
||
525 | * @return $this |
||
526 | * <p>(Immutable) Return this Arrayy object.</p> |
||
527 | * |
||
528 | * @psalm-return static<TKey,T> |
||
529 | * @psalm-mutation-free |
||
530 | */ |
||
531 | 4 | public function natcasesortImmutable(): self |
|
542 | |||
543 | /** |
||
544 | * Sort entries using a "natural order" algorithm. |
||
545 | * |
||
546 | * @return $this |
||
547 | * <p>(Mutable) Return this Arrayy object.</p> |
||
548 | * |
||
549 | * @psalm-return static<TKey,T> |
||
550 | */ |
||
551 | 10 | public function natsort(): self |
|
559 | |||
560 | /** |
||
561 | * Sort entries using a "natural order" algorithm. |
||
562 | * |
||
563 | * @return $this |
||
564 | * <p>(Immutable) Return this Arrayy object.</p> |
||
565 | * |
||
566 | * @psalm-return static<TKey,T> |
||
567 | * @psalm-mutation-free |
||
568 | */ |
||
569 | 4 | public function natsortImmutable(): self |
|
580 | |||
581 | /** |
||
582 | * Whether or not an offset exists. |
||
583 | * |
||
584 | * @param bool|int|string $offset |
||
585 | * |
||
586 | * @return bool |
||
587 | * |
||
588 | * @noinspection PhpSillyAssignmentInspection |
||
589 | * |
||
590 | * @psalm-mutation-free |
||
591 | */ |
||
592 | 157 | public function offsetExists($offset): bool |
|
654 | |||
655 | /** |
||
656 | * Returns the value at specified offset. |
||
657 | * |
||
658 | * @param int|string $offset |
||
659 | * |
||
660 | * @return mixed |
||
661 | * <p>Will return null if the offset did not exists.</p> |
||
662 | */ |
||
663 | 126 | public function offsetGet($offset) |
|
667 | |||
668 | /** |
||
669 | * Assigns a value to the specified offset + check the type. |
||
670 | * |
||
671 | * @param int|string|null $offset |
||
672 | * @param mixed $value |
||
673 | * |
||
674 | * @return void |
||
675 | */ |
||
676 | 26 | public function offsetSet($offset, $value) |
|
698 | |||
699 | /** |
||
700 | * Unset an offset. |
||
701 | * |
||
702 | * @param int|string $offset |
||
703 | * |
||
704 | * @return void |
||
705 | * <p>(Mutable) Return nothing.</p> |
||
706 | */ |
||
707 | 25 | public function offsetUnset($offset) |
|
758 | |||
759 | /** |
||
760 | * Serialize the current "Arrayy"-object. |
||
761 | * |
||
762 | * @return string |
||
763 | */ |
||
764 | 2 | public function serialize(): string |
|
774 | |||
775 | /** |
||
776 | * Sets the iterator classname for the current "Arrayy"-object. |
||
777 | * |
||
778 | * @param string $iteratorClass |
||
779 | * |
||
780 | * @throws \InvalidArgumentException |
||
781 | * |
||
782 | * @return void |
||
783 | * |
||
784 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
785 | */ |
||
786 | 1187 | public function setIteratorClass($iteratorClass) |
|
808 | |||
809 | /** |
||
810 | * Sort the entries with a user-defined comparison function and maintain key association. |
||
811 | * |
||
812 | * @param callable $function |
||
813 | * |
||
814 | * @throws \InvalidArgumentException |
||
815 | * |
||
816 | * @return $this |
||
817 | * <p>(Mutable) Return this Arrayy object.</p> |
||
818 | * |
||
819 | * @psalm-return static<TKey,T> |
||
820 | */ |
||
821 | 8 | View Code Duplication | public function uasort($function): self |
833 | |||
834 | /** |
||
835 | * Sort the entries with a user-defined comparison function and maintain key association. |
||
836 | * |
||
837 | * @param callable $function |
||
838 | * |
||
839 | * @throws \InvalidArgumentException |
||
840 | * |
||
841 | * @return $this |
||
842 | * <p>(Immutable) Return this Arrayy object.</p> |
||
843 | * |
||
844 | * @psalm-return static<TKey,T> |
||
845 | * @psalm-mutation-free |
||
846 | */ |
||
847 | 4 | public function uasortImmutable($function): self |
|
858 | |||
859 | /** |
||
860 | * Sort the entries by keys using a user-defined comparison function. |
||
861 | * |
||
862 | * @param callable $function |
||
863 | * |
||
864 | * @throws \InvalidArgumentException |
||
865 | * |
||
866 | * @return static |
||
867 | * <p>(Mutable) Return this Arrayy object.</p> |
||
868 | * |
||
869 | * @psalm-return static<TKey,T> |
||
870 | */ |
||
871 | 5 | public function uksort($function): self |
|
875 | |||
876 | /** |
||
877 | * Sort the entries by keys using a user-defined comparison function. |
||
878 | * |
||
879 | * @param callable $function |
||
880 | * |
||
881 | * @throws \InvalidArgumentException |
||
882 | * |
||
883 | * @return static |
||
884 | * <p>(Immutable) Return this Arrayy object.</p> |
||
885 | * |
||
886 | * @psalm-return static<TKey,T> |
||
887 | * @psalm-mutation-free |
||
888 | */ |
||
889 | 1 | public function uksortImmutable($function): self |
|
893 | |||
894 | /** |
||
895 | * Unserialize an string and return the instance of the "Arrayy"-class. |
||
896 | * |
||
897 | * @param string $string |
||
898 | * |
||
899 | * @return $this |
||
900 | * |
||
901 | * @psalm-return static<TKey,T> |
||
902 | */ |
||
903 | 2 | public function unserialize($string): self |
|
913 | |||
914 | /** |
||
915 | * Append a (key) + values to the current array. |
||
916 | * |
||
917 | * @param array $values |
||
918 | * @param mixed $key |
||
919 | * |
||
920 | * @return $this |
||
921 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
922 | * |
||
923 | * @psalm-param array<mixed,T> $values |
||
924 | * @psalm-param TKey|null $key |
||
925 | * @psalm-return static<TKey,T> |
||
926 | */ |
||
927 | 1 | public function appendArrayValues(array $values, $key = null) |
|
953 | |||
954 | /** |
||
955 | * Add a suffix to each key. |
||
956 | * |
||
957 | * @param mixed $prefix |
||
958 | * |
||
959 | * @return static |
||
960 | * <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> |
||
961 | * |
||
962 | * @psalm-return static<TKey,T> |
||
963 | * @psalm-mutation-free |
||
964 | */ |
||
965 | 10 | View Code Duplication | public function appendToEachKey($prefix): self |
984 | |||
985 | /** |
||
986 | * Add a prefix to each value. |
||
987 | * |
||
988 | * @param mixed $prefix |
||
989 | * |
||
990 | * @return static |
||
991 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
||
992 | * |
||
993 | * @psalm-return static<TKey,T> |
||
994 | * @psalm-mutation-free |
||
995 | */ |
||
996 | 10 | View Code Duplication | public function appendToEachValue($prefix): self |
1015 | |||
1016 | /** |
||
1017 | * Sort an array in reverse order and maintain index association. |
||
1018 | * |
||
1019 | * @return $this |
||
1020 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1021 | * |
||
1022 | * @psalm-return static<TKey,T> |
||
1023 | */ |
||
1024 | 4 | public function arsort(): self |
|
1032 | |||
1033 | /** |
||
1034 | * Sort an array in reverse order and maintain index association. |
||
1035 | * |
||
1036 | * @return $this |
||
1037 | * <p>(Immutable) Return this Arrayy object.</p> |
||
1038 | * |
||
1039 | * @psalm-return static<TKey,T> |
||
1040 | * @psalm-mutation-free |
||
1041 | */ |
||
1042 | 10 | public function arsortImmutable(): self |
|
1052 | |||
1053 | /** |
||
1054 | * Iterate over the current array and execute a callback for each loop. |
||
1055 | * |
||
1056 | * @param \Closure $closure |
||
1057 | * |
||
1058 | * @return static |
||
1059 | * <p>(Immutable)</p> |
||
1060 | * |
||
1061 | * @psalm-return static<TKey,T> |
||
1062 | * @psalm-mutation-free |
||
1063 | */ |
||
1064 | 2 | public function at(\Closure $closure): self |
|
1078 | |||
1079 | /** |
||
1080 | * Returns the average value of the current array. |
||
1081 | * |
||
1082 | * @param int $decimals <p>The number of decimal-numbers to return.</p> |
||
1083 | * |
||
1084 | * @return float|int |
||
1085 | * <p>The average value.</p> |
||
1086 | * @psalm-mutation-free |
||
1087 | */ |
||
1088 | 10 | public function average($decimals = 0) |
|
1102 | |||
1103 | /** |
||
1104 | * Changes all keys in an array. |
||
1105 | * |
||
1106 | * @param int $case [optional] <p> Either <strong>CASE_UPPER</strong><br /> |
||
1107 | * or <strong>CASE_LOWER</strong> (default)</p> |
||
1108 | * |
||
1109 | * @return static |
||
1110 | * <p>(Immutable)</p> |
||
1111 | * |
||
1112 | * @psalm-return static<TKey,T> |
||
1113 | * @psalm-mutation-free |
||
1114 | */ |
||
1115 | 1 | public function changeKeyCase(int $case = \CASE_LOWER): self |
|
1144 | |||
1145 | /** |
||
1146 | * Change the path separator of the array wrapper. |
||
1147 | * |
||
1148 | * By default, the separator is: "." |
||
1149 | * |
||
1150 | * @param string $separator <p>Separator to set.</p> |
||
1151 | * |
||
1152 | * @return $this |
||
1153 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1154 | * |
||
1155 | * @psalm-return static<TKey,T> |
||
1156 | */ |
||
1157 | 11 | public function changeSeparator($separator): self |
|
1163 | |||
1164 | /** |
||
1165 | * Create a chunked version of the current array. |
||
1166 | * |
||
1167 | * @param int $size <p>Size of each chunk.</p> |
||
1168 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
1169 | * |
||
1170 | * @return static |
||
1171 | * <p>(Immutable) A new array of chunks from the original array.</p> |
||
1172 | * |
||
1173 | * @psalm-return static<TKey,T> |
||
1174 | * @psalm-mutation-free |
||
1175 | */ |
||
1176 | 5 | public function chunk($size, $preserveKeys = false): self |
|
1184 | |||
1185 | /** |
||
1186 | * Clean all falsy values from the current array. |
||
1187 | * |
||
1188 | * @return static |
||
1189 | * <p>(Immutable)</p> |
||
1190 | * |
||
1191 | * @psalm-return static<TKey,T> |
||
1192 | * @psalm-mutation-free |
||
1193 | */ |
||
1194 | 8 | public function clean(): self |
|
1202 | |||
1203 | /** |
||
1204 | * WARNING!!! -> Clear the current full array or a $key of it. |
||
1205 | * |
||
1206 | * @param int|int[]|string|string[]|null $key |
||
1207 | * |
||
1208 | * @return $this |
||
1209 | * <p>(Mutable) Return this Arrayy object, with an empty array.</p> |
||
1210 | * |
||
1211 | * @psalm-return static<TKey,T> |
||
1212 | */ |
||
1213 | 10 | public function clear($key = null): self |
|
1232 | |||
1233 | /** |
||
1234 | * Check if an item is in the current array. |
||
1235 | * |
||
1236 | * @param float|int|string $value |
||
1237 | * @param bool $recursive |
||
1238 | * @param bool $strict |
||
1239 | * |
||
1240 | * @return bool |
||
1241 | * @psalm-mutation-free |
||
1242 | */ |
||
1243 | 23 | public function contains($value, bool $recursive = false, bool $strict = true): bool |
|
1264 | |||
1265 | /** |
||
1266 | * Check if an (case-insensitive) string is in the current array. |
||
1267 | * |
||
1268 | * @param mixed $value |
||
1269 | * @param bool $recursive |
||
1270 | * |
||
1271 | * @return bool |
||
1272 | * @psalm-mutation-free |
||
1273 | * |
||
1274 | * @psalm-suppress InvalidCast - hack for int|float|bool support |
||
1275 | */ |
||
1276 | 26 | public function containsCaseInsensitive($value, $recursive = false): bool |
|
1305 | |||
1306 | /** |
||
1307 | * Check if the given key/index exists in the array. |
||
1308 | * |
||
1309 | * @param int|string $key <p>key/index to search for</p> |
||
1310 | * |
||
1311 | * @return bool |
||
1312 | * <p>Returns true if the given key/index exists in the array, false otherwise.</p> |
||
1313 | * |
||
1314 | * @psalm-mutation-free |
||
1315 | */ |
||
1316 | 4 | public function containsKey($key): bool |
|
1320 | |||
1321 | /** |
||
1322 | * Check if all given needles are present in the array as key/index. |
||
1323 | * |
||
1324 | * @param array $needles <p>The keys you are searching for.</p> |
||
1325 | * @param bool $recursive |
||
1326 | * |
||
1327 | * @return bool |
||
1328 | * <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p> |
||
1329 | * |
||
1330 | * @psalm-param array<mixed,mixed>|array<TKey> $needles |
||
1331 | * @psalm-mutation-free |
||
1332 | */ |
||
1333 | 2 | public function containsKeys(array $needles, $recursive = false): bool |
|
1361 | |||
1362 | /** |
||
1363 | * Check if all given needles are present in the array as key/index. |
||
1364 | * |
||
1365 | * @param array $needles <p>The keys you are searching for.</p> |
||
1366 | * |
||
1367 | * @return bool |
||
1368 | * <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p> |
||
1369 | * |
||
1370 | * @psalm-param array<mixed,mixed>|array<TKey> $needles |
||
1371 | * @psalm-mutation-free |
||
1372 | */ |
||
1373 | 1 | public function containsKeysRecursive(array $needles): bool |
|
1377 | |||
1378 | /** |
||
1379 | * alias: for "Arrayy->contains()" |
||
1380 | * |
||
1381 | * @param float|int|string $value |
||
1382 | * |
||
1383 | * @return bool |
||
1384 | * |
||
1385 | * @see Arrayy::contains() |
||
1386 | * @psalm-mutation-free |
||
1387 | */ |
||
1388 | 9 | public function containsValue($value): bool |
|
1392 | |||
1393 | /** |
||
1394 | * alias: for "Arrayy->contains($value, true)" |
||
1395 | * |
||
1396 | * @param float|int|string $value |
||
1397 | * |
||
1398 | * @return bool |
||
1399 | * |
||
1400 | * @see Arrayy::contains() |
||
1401 | * @psalm-mutation-free |
||
1402 | */ |
||
1403 | 18 | public function containsValueRecursive($value): bool |
|
1407 | |||
1408 | /** |
||
1409 | * Check if all given needles are present in the array. |
||
1410 | * |
||
1411 | * @param array $needles |
||
1412 | * |
||
1413 | * @return bool |
||
1414 | * <p>Returns true if all the given values exists in the array, false otherwise.</p> |
||
1415 | * |
||
1416 | * @psalm-param array<mixed>|array<T> $needles |
||
1417 | * @psalm-mutation-free |
||
1418 | */ |
||
1419 | 1 | public function containsValues(array $needles): bool |
|
1425 | |||
1426 | /** |
||
1427 | * Counts all the values of an array |
||
1428 | * |
||
1429 | * @see http://php.net/manual/en/function.array-count-values.php |
||
1430 | * |
||
1431 | * @return static |
||
1432 | * <p> |
||
1433 | * (Immutable) |
||
1434 | * An associative Arrayy-object of values from input as |
||
1435 | * keys and their count as value. |
||
1436 | * </p> |
||
1437 | * |
||
1438 | * @psalm-return static<TKey,T> |
||
1439 | * @psalm-mutation-free |
||
1440 | */ |
||
1441 | 7 | public function countValues(): self |
|
1445 | |||
1446 | /** |
||
1447 | * Creates an Arrayy object. |
||
1448 | * |
||
1449 | * @param mixed $data |
||
1450 | * @param string $iteratorClass |
||
1451 | * @param bool $checkPropertiesInConstructor |
||
1452 | * |
||
1453 | * @return static |
||
1454 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1455 | * |
||
1456 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
1457 | * |
||
1458 | * @psalm-mutation-free |
||
1459 | */ |
||
1460 | 715 | public static function create( |
|
1471 | |||
1472 | /** |
||
1473 | * Flatten an array with the given character as a key delimiter |
||
1474 | * |
||
1475 | * @param string $delimiter |
||
1476 | * @param string $prepend |
||
1477 | * @param array|null $items |
||
1478 | * |
||
1479 | * @return array |
||
1480 | */ |
||
1481 | 2 | public function flatten($delimiter = '.', $prepend = '', $items = null) |
|
1504 | |||
1505 | /** |
||
1506 | * WARNING: Creates an Arrayy object by reference. |
||
1507 | * |
||
1508 | * @param array $array |
||
1509 | * |
||
1510 | * @return $this |
||
1511 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1512 | * |
||
1513 | * @psalm-param array<mixed,mixed>|array<array-key,mixed> $array |
||
1514 | */ |
||
1515 | 2 | public function createByReference(array &$array = []): self |
|
1523 | |||
1524 | /** |
||
1525 | * Create an new instance from a callable function which will return an Generator. |
||
1526 | * |
||
1527 | * @param callable $generatorFunction |
||
1528 | * |
||
1529 | * @return static |
||
1530 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1531 | * |
||
1532 | * @psalm-param callable():\Generator<array-key,mixed> $generatorFunction |
||
1533 | * |
||
1534 | * @psalm-mutation-free |
||
1535 | */ |
||
1536 | 7 | public static function createFromGeneratorFunction(callable $generatorFunction): self |
|
1540 | |||
1541 | /** |
||
1542 | * Create an new instance filled with a copy of values from a "Generator"-object. |
||
1543 | * |
||
1544 | * @param \Generator $generator |
||
1545 | * |
||
1546 | * @return static |
||
1547 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1548 | * |
||
1549 | * @psalm-param \Generator<array-key,mixed> $generator |
||
1550 | * |
||
1551 | * @psalm-mutation-free |
||
1552 | */ |
||
1553 | 4 | public static function createFromGeneratorImmutable(\Generator $generator): self |
|
1557 | |||
1558 | /** |
||
1559 | * Create an new Arrayy object via JSON. |
||
1560 | * |
||
1561 | * @param string $json |
||
1562 | * |
||
1563 | * @return static |
||
1564 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1565 | * |
||
1566 | * @psalm-mutation-free |
||
1567 | */ |
||
1568 | 5 | public static function createFromJson(string $json): self |
|
1572 | |||
1573 | /** |
||
1574 | * Create an new Arrayy object via JSON. |
||
1575 | * |
||
1576 | * @param array $array |
||
1577 | * |
||
1578 | * @return static |
||
1579 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1580 | * |
||
1581 | * @psalm-mutation-free |
||
1582 | */ |
||
1583 | 1 | public static function createFromArray(array $array): self |
|
1587 | |||
1588 | /** |
||
1589 | * Create an new instance filled with values from an object that is iterable. |
||
1590 | * |
||
1591 | * @param \Traversable $object <p>iterable object</p> |
||
1592 | * |
||
1593 | * @return static |
||
1594 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1595 | * |
||
1596 | * @psalm-param \Traversable<array-key,mixed> $object |
||
1597 | * |
||
1598 | * @psalm-mutation-free |
||
1599 | */ |
||
1600 | 4 | public static function createFromObject(\Traversable $object): self |
|
1620 | |||
1621 | /** |
||
1622 | * Create an new instance filled with values from an object. |
||
1623 | * |
||
1624 | * @param object $object |
||
1625 | * |
||
1626 | * @return static |
||
1627 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1628 | * |
||
1629 | * @psalm-mutation-free |
||
1630 | */ |
||
1631 | 5 | public static function createFromObjectVars($object): self |
|
1635 | |||
1636 | /** |
||
1637 | * Create an new Arrayy object via string. |
||
1638 | * |
||
1639 | * @param string $str <p>The input string.</p> |
||
1640 | * @param string|null $delimiter <p>The boundary string.</p> |
||
1641 | * @param string|null $regEx <p>Use the $delimiter or the $regEx, so if $pattern is null, $delimiter will be |
||
1642 | * used.</p> |
||
1643 | * |
||
1644 | * @return static |
||
1645 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1646 | * |
||
1647 | * @psalm-mutation-free |
||
1648 | */ |
||
1649 | 10 | public static function createFromString(string $str, string $delimiter = null, string $regEx = null): self |
|
1681 | |||
1682 | /** |
||
1683 | * Create an new instance filled with a copy of values from a "Traversable"-object. |
||
1684 | * |
||
1685 | * @param \Traversable $traversable |
||
1686 | * |
||
1687 | * @return static |
||
1688 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1689 | * |
||
1690 | * @psalm-param \Traversable<array-key,mixed> $traversable |
||
1691 | * |
||
1692 | * @psalm-mutation-free |
||
1693 | */ |
||
1694 | 1 | public static function createFromTraversableImmutable(\Traversable $traversable): self |
|
1698 | |||
1699 | /** |
||
1700 | * Create an new instance containing a range of elements. |
||
1701 | * |
||
1702 | * @param float|int|string $low <p>First value of the sequence.</p> |
||
1703 | * @param float|int|string $high <p>The sequence is ended upon reaching the end value.</p> |
||
1704 | * @param float|int $step <p>Used as the increment between elements in the sequence.</p> |
||
1705 | * |
||
1706 | * @return static |
||
1707 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1708 | * |
||
1709 | * @psalm-mutation-free |
||
1710 | */ |
||
1711 | 2 | public static function createWithRange($low, $high, $step = 1): self |
|
1715 | |||
1716 | /** |
||
1717 | * Gets the element of the array at the current internal iterator position. |
||
1718 | * |
||
1719 | * @return false|mixed |
||
1720 | */ |
||
1721 | public function current() |
||
1725 | |||
1726 | /** |
||
1727 | * Custom sort by index via "uksort". |
||
1728 | * |
||
1729 | * @see http://php.net/manual/en/function.uksort.php |
||
1730 | * |
||
1731 | * @param callable $function |
||
1732 | * |
||
1733 | * @throws \InvalidArgumentException |
||
1734 | * |
||
1735 | * @return $this |
||
1736 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1737 | * |
||
1738 | * @psalm-return static<TKey,T> |
||
1739 | */ |
||
1740 | 5 | public function customSortKeys(callable $function): self |
|
1748 | |||
1749 | /** |
||
1750 | * Custom sort by index via "uksort". |
||
1751 | * |
||
1752 | * @see http://php.net/manual/en/function.uksort.php |
||
1753 | * |
||
1754 | * @param callable $function |
||
1755 | * |
||
1756 | * @throws \InvalidArgumentException |
||
1757 | * |
||
1758 | * @return $this |
||
1759 | * <p>(Immutable) Return this Arrayy object.</p> |
||
1760 | * |
||
1761 | * @psalm-return static<TKey,T> |
||
1762 | * @psalm-mutation-free |
||
1763 | */ |
||
1764 | 1 | public function customSortKeysImmutable(callable $function): self |
|
1777 | |||
1778 | /** |
||
1779 | * Custom sort by value via "usort". |
||
1780 | * |
||
1781 | * @see http://php.net/manual/en/function.usort.php |
||
1782 | * |
||
1783 | * @param callable $function |
||
1784 | * |
||
1785 | * @throws \InvalidArgumentException |
||
1786 | * |
||
1787 | * @return $this |
||
1788 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1789 | * |
||
1790 | * @psalm-return static<TKey,T> |
||
1791 | */ |
||
1792 | 10 | View Code Duplication | public function customSortValues($function): self |
1804 | |||
1805 | /** |
||
1806 | * Custom sort by value via "usort". |
||
1807 | * |
||
1808 | * @see http://php.net/manual/en/function.usort.php |
||
1809 | * |
||
1810 | * @param callable $function |
||
1811 | * |
||
1812 | * @throws \InvalidArgumentException |
||
1813 | * |
||
1814 | * @return $this |
||
1815 | * <p>(Immutable) Return this Arrayy object.</p> |
||
1816 | * |
||
1817 | * @psalm-return static<TKey,T> |
||
1818 | * @psalm-mutation-free |
||
1819 | */ |
||
1820 | 4 | public function customSortValuesImmutable($function): self |
|
1831 | |||
1832 | /** |
||
1833 | * Delete the given key or keys. |
||
1834 | * |
||
1835 | * @param int|int[]|string|string[] $keyOrKeys |
||
1836 | * |
||
1837 | * @return void |
||
1838 | */ |
||
1839 | 9 | public function delete($keyOrKeys) |
|
1847 | |||
1848 | /** |
||
1849 | * Return values that are only in the current array. |
||
1850 | * |
||
1851 | * @param array ...$array |
||
1852 | * |
||
1853 | * @return static |
||
1854 | * <p>(Immutable)</p> |
||
1855 | * |
||
1856 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
1857 | * @psalm-return static<TKey,T> |
||
1858 | * @psalm-mutation-free |
||
1859 | */ |
||
1860 | 13 | public function diff(...$array): self |
|
1868 | |||
1869 | /** |
||
1870 | * Return values that are only in the current array. |
||
1871 | * |
||
1872 | * @param array ...$array |
||
1873 | * |
||
1874 | * @return static |
||
1875 | * <p>(Immutable)</p> |
||
1876 | * |
||
1877 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
1878 | * @psalm-return static<TKey,T> |
||
1879 | * @psalm-mutation-free |
||
1880 | */ |
||
1881 | 8 | public function diffKey(...$array): self |
|
1889 | |||
1890 | /** |
||
1891 | * Return values and Keys that are only in the current array. |
||
1892 | * |
||
1893 | * @param array $array |
||
1894 | * |
||
1895 | * @return static |
||
1896 | * <p>(Immutable)</p> |
||
1897 | * |
||
1898 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1899 | * @psalm-return static<TKey,T> |
||
1900 | * @psalm-mutation-free |
||
1901 | */ |
||
1902 | 8 | public function diffKeyAndValue(array $array = []): self |
|
1910 | |||
1911 | /** |
||
1912 | * Return values that are only in the current multi-dimensional array. |
||
1913 | * |
||
1914 | * @param array $array |
||
1915 | * @param array|\Generator|null $helperVariableForRecursion <p>(only for internal usage)</p> |
||
1916 | * |
||
1917 | * @return static |
||
1918 | * <p>(Immutable)</p> |
||
1919 | * |
||
1920 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1921 | * @psalm-param null|array<TKey,T>|\Generator<TKey,T> $helperVariableForRecursion |
||
1922 | * @psalm-return static<TKey,T> |
||
1923 | * @psalm-mutation-free |
||
1924 | */ |
||
1925 | 1 | public function diffRecursive(array $array = [], $helperVariableForRecursion = null): self |
|
1960 | |||
1961 | /** |
||
1962 | * Return values that are only in the new $array. |
||
1963 | * |
||
1964 | * @param array $array |
||
1965 | * |
||
1966 | * @return static |
||
1967 | * <p>(Immutable)</p> |
||
1968 | * |
||
1969 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1970 | * @psalm-return static<TKey,T> |
||
1971 | * @psalm-mutation-free |
||
1972 | */ |
||
1973 | 8 | public function diffReverse(array $array = []): self |
|
1981 | |||
1982 | /** |
||
1983 | * Divide an array into two arrays. One with keys and the other with values. |
||
1984 | * |
||
1985 | * @return static |
||
1986 | * <p>(Immutable)</p> |
||
1987 | * |
||
1988 | * @psalm-return static<TKey,T> |
||
1989 | * @psalm-mutation-free |
||
1990 | */ |
||
1991 | 1 | public function divide(): self |
|
2002 | |||
2003 | /** |
||
2004 | * Iterate over the current array and modify the array's value. |
||
2005 | * |
||
2006 | * @param \Closure $closure |
||
2007 | * |
||
2008 | * @return static |
||
2009 | * <p>(Immutable)</p> |
||
2010 | * |
||
2011 | * @psalm-return static<TKey,T> |
||
2012 | * @psalm-mutation-free |
||
2013 | */ |
||
2014 | 5 | View Code Duplication | public function each(\Closure $closure): self |
2029 | |||
2030 | /** |
||
2031 | * Sets the internal iterator to the last element in the array and returns this element. |
||
2032 | * |
||
2033 | * @return mixed |
||
2034 | */ |
||
2035 | public function end() |
||
2039 | |||
2040 | /** |
||
2041 | * Check if a value is in the current array using a closure. |
||
2042 | * |
||
2043 | * @param \Closure $closure |
||
2044 | * |
||
2045 | * @return bool |
||
2046 | * <p>Returns true if the given value is found, false otherwise.</p> |
||
2047 | */ |
||
2048 | 4 | public function exists(\Closure $closure): bool |
|
2063 | |||
2064 | /** |
||
2065 | * Fill the array until "$num" with "$default" values. |
||
2066 | * |
||
2067 | * @param int $num |
||
2068 | * @param mixed $default |
||
2069 | * |
||
2070 | * @return static |
||
2071 | * <p>(Immutable)</p> |
||
2072 | * |
||
2073 | * @psalm-return static<TKey,T> |
||
2074 | * @psalm-mutation-free |
||
2075 | */ |
||
2076 | 8 | public function fillWithDefaults(int $num, $default = null): self |
|
2099 | |||
2100 | /** |
||
2101 | * Find all items in an array that pass the truth test. |
||
2102 | * |
||
2103 | * @param \Closure|null $closure [optional] <p> |
||
2104 | * The callback function to use |
||
2105 | * </p> |
||
2106 | * <p> |
||
2107 | * If no callback is supplied, all entries of |
||
2108 | * input equal to false (see |
||
2109 | * converting to |
||
2110 | * boolean) will be removed. |
||
2111 | * </p> |
||
2112 | * @param int $flag [optional] <p> |
||
2113 | * Flag determining what arguments are sent to <i>callback</i>: |
||
2114 | * </p><ul> |
||
2115 | * <li> |
||
2116 | * <b>ARRAY_FILTER_USE_KEY</b> [1] - pass key as the only argument |
||
2117 | * to <i>callback</i> instead of the value</span> |
||
2118 | * </li> |
||
2119 | * <li> |
||
2120 | * <b>ARRAY_FILTER_USE_BOTH</b> [2] - pass both value and key as |
||
2121 | * arguments to <i>callback</i> instead of the value</span> |
||
2122 | * </li> |
||
2123 | * </ul> |
||
2124 | * |
||
2125 | * @return static |
||
2126 | * <p>(Immutable)</p> |
||
2127 | * |
||
2128 | * @psalm-param \Closure(T=,TKey=):bool|\Closure(T=):bool $closure |
||
2129 | * @psalm-return static<TKey,T> |
||
2130 | * @psalm-mutation-free |
||
2131 | */ |
||
2132 | 12 | public function filter($closure = null, int $flag = \ARRAY_FILTER_USE_BOTH) |
|
2144 | |||
2145 | /** |
||
2146 | * Filters an array of objects (or a numeric array of associative arrays) based on the value of a particular |
||
2147 | * property within that. |
||
2148 | * |
||
2149 | * @param string $property |
||
2150 | * @param string|string[] $value |
||
2151 | * @param string $comparisonOp |
||
2152 | * <p> |
||
2153 | * 'eq' (equals),<br /> |
||
2154 | * 'gt' (greater),<br /> |
||
2155 | * 'gte' || 'ge' (greater or equals),<br /> |
||
2156 | * 'lt' (less),<br /> |
||
2157 | * 'lte' || 'le' (less or equals),<br /> |
||
2158 | * 'ne' (not equals),<br /> |
||
2159 | * 'contains',<br /> |
||
2160 | * 'notContains',<br /> |
||
2161 | * 'newer' (via strtotime),<br /> |
||
2162 | * 'older' (via strtotime),<br /> |
||
2163 | * </p> |
||
2164 | * |
||
2165 | * @return static |
||
2166 | * <p>(Immutable)</p> |
||
2167 | * |
||
2168 | * @psalm-return static<TKey,T> |
||
2169 | * @psalm-mutation-free |
||
2170 | * |
||
2171 | * @psalm-suppress MissingClosureReturnType |
||
2172 | * @psalm-suppress MissingClosureParamType |
||
2173 | */ |
||
2174 | 1 | public function filterBy( |
|
2246 | |||
2247 | /** |
||
2248 | * Find the first item in an array that passes the truth test, |
||
2249 | * otherwise return false |
||
2250 | * |
||
2251 | * @param \Closure $closure |
||
2252 | * |
||
2253 | * @return false|mixed |
||
2254 | * <p>Return false if we did not find the value.</p> |
||
2255 | */ |
||
2256 | 8 | View Code Duplication | public function find(\Closure $closure) |
2266 | |||
2267 | /** |
||
2268 | * find by ... |
||
2269 | * |
||
2270 | * @param string $property |
||
2271 | * @param string|string[] $value |
||
2272 | * @param string $comparisonOp |
||
2273 | * |
||
2274 | * @return static |
||
2275 | * <p>(Immutable)</p> |
||
2276 | * |
||
2277 | * @psalm-return static<TKey,T> |
||
2278 | * @psalm-mutation-free |
||
2279 | */ |
||
2280 | 1 | public function findBy(string $property, $value, string $comparisonOp = 'eq'): self |
|
2284 | |||
2285 | /** |
||
2286 | * Get the first value from the current array. |
||
2287 | * |
||
2288 | * @return mixed |
||
2289 | * <p>Return null if there wasn't a element.</p> |
||
2290 | */ |
||
2291 | 22 | public function first() |
|
2300 | |||
2301 | /** |
||
2302 | * Get the first key from the current array. |
||
2303 | * |
||
2304 | * @return mixed |
||
2305 | * <p>Return null if there wasn't a element.</p> |
||
2306 | * @psalm-mutation-free |
||
2307 | */ |
||
2308 | 29 | public function firstKey() |
|
2314 | |||
2315 | /** |
||
2316 | * Get the first value(s) from the current array. |
||
2317 | * And will return an empty array if there was no first entry. |
||
2318 | * |
||
2319 | * @param int|null $number <p>How many values you will take?</p> |
||
2320 | * |
||
2321 | * @return static |
||
2322 | * <p>(Immutable)</p> |
||
2323 | * |
||
2324 | * @psalm-return static<TKey,T> |
||
2325 | * @psalm-mutation-free |
||
2326 | */ |
||
2327 | 37 | View Code Duplication | public function firstsImmutable(int $number = null): self |
2344 | |||
2345 | /** |
||
2346 | * Get the first value(s) from the current array. |
||
2347 | * And will return an empty array if there was no first entry. |
||
2348 | * |
||
2349 | * @param int|null $number <p>How many values you will take?</p> |
||
2350 | * |
||
2351 | * @return static |
||
2352 | * <p>(Immutable)</p> |
||
2353 | * |
||
2354 | * @psalm-return static<TKey,T> |
||
2355 | * @psalm-mutation-free |
||
2356 | */ |
||
2357 | 3 | View Code Duplication | public function firstsKeys(int $number = null): self |
2374 | |||
2375 | /** |
||
2376 | * Get and rmove the first value(s) from the current array. |
||
2377 | * And will return an empty array if there was no first entry. |
||
2378 | * |
||
2379 | * @param int|null $number <p>How many values you will take?</p> |
||
2380 | * |
||
2381 | * @return $this |
||
2382 | * <p>(Mutable)</p> |
||
2383 | * |
||
2384 | * @psalm-return static<TKey,T> |
||
2385 | */ |
||
2386 | 34 | public function firstsMutable(int $number = null): self |
|
2399 | |||
2400 | /** |
||
2401 | * Exchanges all keys with their associated values in an array. |
||
2402 | * |
||
2403 | * @return static |
||
2404 | * <p>(Immutable)</p> |
||
2405 | * |
||
2406 | * @psalm-return static<TKey,T> |
||
2407 | * @psalm-mutation-free |
||
2408 | */ |
||
2409 | 1 | public function flip(): self |
|
2417 | |||
2418 | /** |
||
2419 | * Get a value from an array (optional using dot-notation). |
||
2420 | * |
||
2421 | * @param mixed $key <p>The key to look for.</p> |
||
2422 | * @param mixed $fallback <p>Value to fallback to.</p> |
||
2423 | * @param array $array <p>The array to get from, if it's set to "null" we use the current array from the |
||
2424 | * class.</p> |
||
2425 | * |
||
2426 | * @return mixed|static |
||
2427 | * |
||
2428 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
2429 | * @psalm-mutation-free |
||
2430 | */ |
||
2431 | 240 | public function get($key, $fallback = null, array $array = null) |
|
2523 | |||
2524 | /** |
||
2525 | * alias: for "Arrayy->toArray()" |
||
2526 | * |
||
2527 | * @return array |
||
2528 | * |
||
2529 | * @see Arrayy::getArray() |
||
2530 | * |
||
2531 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
2532 | */ |
||
2533 | 14 | public function getAll(): array |
|
2537 | |||
2538 | /** |
||
2539 | * Get the current array from the "Arrayy"-object. |
||
2540 | * |
||
2541 | * alias for "toArray()" |
||
2542 | * |
||
2543 | * @param bool $convertAllArrayyElements <p> |
||
2544 | * Convert all Child-"Arrayy" objects also to arrays. |
||
2545 | * </p> |
||
2546 | * @param bool $preserveKeys <p> |
||
2547 | * e.g.: A generator maybe return the same key more then once, |
||
2548 | * so maybe you will ignore the keys. |
||
2549 | * </p> |
||
2550 | * |
||
2551 | * @return array |
||
2552 | * |
||
2553 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
2554 | * @psalm-mutation-free |
||
2555 | * |
||
2556 | * @see Arrayy::toArray() |
||
2557 | */ |
||
2558 | 498 | public function getArray( |
|
2567 | |||
2568 | /** |
||
2569 | * @param string $json |
||
2570 | * |
||
2571 | * @return $this |
||
2572 | */ |
||
2573 | 3 | public static function createFromJsonMapper(string $json) |
|
2589 | |||
2590 | /** |
||
2591 | * @return array<int|string,TypeCheckInterface>|mixed|TypeCheckArray<int|string,TypeCheckInterface>|TypeInterface |
||
2592 | */ |
||
2593 | 6 | public function getPhpDocPropertiesFromClass() |
|
2601 | |||
2602 | /** |
||
2603 | * Get the current array from the "Arrayy"-object as list. |
||
2604 | * |
||
2605 | * alias for "toList()" |
||
2606 | * |
||
2607 | * @param bool $convertAllArrayyElements <p> |
||
2608 | * Convert all Child-"Arrayy" objects also to arrays. |
||
2609 | * </p> |
||
2610 | * |
||
2611 | * @return array |
||
2612 | * |
||
2613 | * @psalm-return array<int,mixed>|array<int,T> |
||
2614 | * @psalm-mutation-free |
||
2615 | * |
||
2616 | * @see Arrayy::toList() |
||
2617 | */ |
||
2618 | 1 | public function getList(bool $convertAllArrayyElements = false): array |
|
2622 | |||
2623 | /** |
||
2624 | * Returns the values from a single column of the input array, identified by |
||
2625 | * the $columnKey, can be used to extract data-columns from multi-arrays. |
||
2626 | * |
||
2627 | * Info: Optionally, you may provide an $indexKey to index the values in the returned |
||
2628 | * array by the values from the $indexKey column in the input array. |
||
2629 | * |
||
2630 | * @param mixed $columnKey |
||
2631 | * @param mixed $indexKey |
||
2632 | * |
||
2633 | * @return static |
||
2634 | * <p>(Immutable)</p> |
||
2635 | * |
||
2636 | * @psalm-return static<TKey,T> |
||
2637 | * @psalm-mutation-free |
||
2638 | */ |
||
2639 | 1 | public function getColumn($columnKey = null, $indexKey = null): self |
|
2647 | |||
2648 | /** |
||
2649 | * Get the current array from the "Arrayy"-object as generator by reference. |
||
2650 | * |
||
2651 | * @return \Generator |
||
2652 | * |
||
2653 | * @psalm-return \Generator<mixed,T>|\Generator<TKey,T> |
||
2654 | */ |
||
2655 | 75 | public function &getGeneratorByReference(): \Generator |
|
2673 | |||
2674 | /** |
||
2675 | * Get the current array from the "Arrayy"-object as generator. |
||
2676 | * |
||
2677 | * @return \Generator |
||
2678 | * |
||
2679 | * @psalm-return \Generator<mixed,T>|\Generator<TKey,T> |
||
2680 | * @psalm-mutation-free |
||
2681 | */ |
||
2682 | 994 | public function getGenerator(): \Generator |
|
2692 | |||
2693 | /** |
||
2694 | * alias: for "Arrayy->keys()" |
||
2695 | * |
||
2696 | * @return static |
||
2697 | * <p>(Immutable)</p> |
||
2698 | * |
||
2699 | * @see Arrayy::keys() |
||
2700 | * |
||
2701 | * @psalm-return static<array-key,TKey> |
||
2702 | * @psalm-mutation-free |
||
2703 | */ |
||
2704 | 2 | public function getKeys() |
|
2708 | |||
2709 | /** |
||
2710 | * Get the current array from the "Arrayy"-object as object. |
||
2711 | * |
||
2712 | * @return \stdClass |
||
2713 | */ |
||
2714 | 4 | public function getObject(): \stdClass |
|
2718 | |||
2719 | /** |
||
2720 | * alias: for "Arrayy->randomImmutable()" |
||
2721 | * |
||
2722 | * @return static |
||
2723 | * <p>(Immutable)</p> |
||
2724 | * |
||
2725 | * @see Arrayy::randomImmutable() |
||
2726 | * |
||
2727 | * @psalm-return static<int|array-key,T> |
||
2728 | */ |
||
2729 | 4 | public function getRandom(): self |
|
2733 | |||
2734 | /** |
||
2735 | * alias: for "Arrayy->randomKey()" |
||
2736 | * |
||
2737 | * @return mixed |
||
2738 | * <p>Get a key/index or null if there wasn't a key/index.</p> |
||
2739 | * |
||
2740 | * @see Arrayy::randomKey() |
||
2741 | */ |
||
2742 | 3 | public function getRandomKey() |
|
2746 | |||
2747 | /** |
||
2748 | * alias: for "Arrayy->randomKeys()" |
||
2749 | * |
||
2750 | * @param int $number |
||
2751 | * |
||
2752 | * @return static |
||
2753 | * <p>(Immutable)</p> |
||
2754 | * |
||
2755 | * @see Arrayy::randomKeys() |
||
2756 | * |
||
2757 | * @psalm-return static<TKey,T> |
||
2758 | */ |
||
2759 | 8 | public function getRandomKeys(int $number): self |
|
2763 | |||
2764 | /** |
||
2765 | * alias: for "Arrayy->randomValue()" |
||
2766 | * |
||
2767 | * @return mixed |
||
2768 | * <p>Get a random value or null if there wasn't a value.</p> |
||
2769 | * |
||
2770 | * @see Arrayy::randomValue() |
||
2771 | */ |
||
2772 | 3 | public function getRandomValue() |
|
2776 | |||
2777 | /** |
||
2778 | * alias: for "Arrayy->randomValues()" |
||
2779 | * |
||
2780 | * @param int $number |
||
2781 | * |
||
2782 | * @return static |
||
2783 | * <p>(Immutable)</p> |
||
2784 | * |
||
2785 | * @see Arrayy::randomValues() |
||
2786 | * |
||
2787 | * @psalm-return static<TKey,T> |
||
2788 | */ |
||
2789 | 6 | public function getRandomValues(int $number): self |
|
2793 | |||
2794 | /** |
||
2795 | * Gets all values. |
||
2796 | * |
||
2797 | * @return static |
||
2798 | * <p>The values of all elements in this array, in the order they |
||
2799 | * appear in the array.</p> |
||
2800 | * |
||
2801 | * @psalm-return static<TKey,T> |
||
2802 | */ |
||
2803 | 4 | public function getValues() |
|
2813 | |||
2814 | /** |
||
2815 | * Gets all values via Generator. |
||
2816 | * |
||
2817 | * @return \Generator |
||
2818 | * <p>The values of all elements in this array, in the order they |
||
2819 | * appear in the array as Generator.</p> |
||
2820 | * |
||
2821 | * @psalm-return \Generator<TKey,T> |
||
2822 | */ |
||
2823 | 4 | public function getValuesYield(): \Generator |
|
2827 | |||
2828 | /** |
||
2829 | * Group values from a array according to the results of a closure. |
||
2830 | * |
||
2831 | * @param callable|string $grouper <p>A callable function name.</p> |
||
2832 | * @param bool $saveKeys |
||
2833 | * |
||
2834 | * @return static |
||
2835 | * <p>(Immutable)</p> |
||
2836 | * |
||
2837 | * @psalm-return static<TKey,T> |
||
2838 | * @psalm-mutation-free |
||
2839 | */ |
||
2840 | 4 | public function group($grouper, bool $saveKeys = false): self |
|
2881 | |||
2882 | /** |
||
2883 | * Check if an array has a given key. |
||
2884 | * |
||
2885 | * @param mixed $key |
||
2886 | * |
||
2887 | * @return bool |
||
2888 | */ |
||
2889 | 30 | public function has($key): bool |
|
2915 | |||
2916 | /** |
||
2917 | * Check if an array has a given value. |
||
2918 | * |
||
2919 | * INFO: if you need to search recursive please use ```contains()``` |
||
2920 | * |
||
2921 | * @param mixed $value |
||
2922 | * |
||
2923 | * @return bool |
||
2924 | */ |
||
2925 | 1 | public function hasValue($value): bool |
|
2929 | |||
2930 | /** |
||
2931 | * Implodes the values of this array. |
||
2932 | * |
||
2933 | * @param string $glue |
||
2934 | * |
||
2935 | * @return string |
||
2936 | * @psalm-mutation-free |
||
2937 | */ |
||
2938 | 28 | public function implode(string $glue = ''): string |
|
2942 | |||
2943 | /** |
||
2944 | * Implodes the keys of this array. |
||
2945 | * |
||
2946 | * @param string $glue |
||
2947 | * |
||
2948 | * @return string |
||
2949 | * @psalm-mutation-free |
||
2950 | */ |
||
2951 | 8 | public function implodeKeys(string $glue = ''): string |
|
2955 | |||
2956 | /** |
||
2957 | * Given a list and an iterate-function that returns |
||
2958 | * a key for each element in the list (or a property name), |
||
2959 | * returns an object with an index of each item. |
||
2960 | * |
||
2961 | * @param mixed $key |
||
2962 | * |
||
2963 | * @return static |
||
2964 | * <p>(Immutable)</p> |
||
2965 | * |
||
2966 | * @psalm-return static<TKey,T> |
||
2967 | * @psalm-mutation-free |
||
2968 | */ |
||
2969 | 4 | public function indexBy($key): self |
|
2986 | |||
2987 | /** |
||
2988 | * alias: for "Arrayy->searchIndex()" |
||
2989 | * |
||
2990 | * @param mixed $value <p>The value to search for.</p> |
||
2991 | * |
||
2992 | * @return false|mixed |
||
2993 | * |
||
2994 | * @see Arrayy::searchIndex() |
||
2995 | */ |
||
2996 | 4 | public function indexOf($value) |
|
3000 | |||
3001 | /** |
||
3002 | * Get everything but the last..$to items. |
||
3003 | * |
||
3004 | * @param int $to |
||
3005 | * |
||
3006 | * @return static |
||
3007 | * <p>(Immutable)</p> |
||
3008 | * |
||
3009 | * @psalm-return static<TKey,T> |
||
3010 | * @psalm-mutation-free |
||
3011 | */ |
||
3012 | 12 | public function initial(int $to = 1): self |
|
3016 | |||
3017 | /** |
||
3018 | * Return an array with all elements found in input array. |
||
3019 | * |
||
3020 | * @param array $search |
||
3021 | * @param bool $keepKeys |
||
3022 | * |
||
3023 | * @return static |
||
3024 | * <p>(Immutable)</p> |
||
3025 | * |
||
3026 | * @psalm-param array<mixed,mixed>|array<TKey,T> $search |
||
3027 | * @psalm-return static<TKey,T> |
||
3028 | * @psalm-mutation-free |
||
3029 | */ |
||
3030 | 4 | public function intersection(array $search, bool $keepKeys = false): self |
|
3056 | |||
3057 | /** |
||
3058 | * Return an array with all elements found in input array. |
||
3059 | * |
||
3060 | * @param array ...$array |
||
3061 | * |
||
3062 | * @return static |
||
3063 | * <p>(Immutable)</p> |
||
3064 | * |
||
3065 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
3066 | * @psalm-return static<TKey,T> |
||
3067 | * @psalm-mutation-free |
||
3068 | */ |
||
3069 | 1 | public function intersectionMulti(...$array): self |
|
3077 | |||
3078 | /** |
||
3079 | * Return a boolean flag which indicates whether the two input arrays have any common elements. |
||
3080 | * |
||
3081 | * @param array $search |
||
3082 | * |
||
3083 | * @return bool |
||
3084 | * |
||
3085 | * @psalm-param array<mixed,mixed>|array<TKey,T> $search |
||
3086 | */ |
||
3087 | 1 | public function intersects(array $search): bool |
|
3091 | |||
3092 | /** |
||
3093 | * Invoke a function on all of an array's values. |
||
3094 | * |
||
3095 | * @param callable $callable |
||
3096 | * @param mixed $arguments |
||
3097 | * |
||
3098 | * @return static |
||
3099 | * <p>(Immutable)</p> |
||
3100 | * |
||
3101 | * @psalm-param callable(T=,mixed):mixed $callable |
||
3102 | * @psalm-return static<TKey,T> |
||
3103 | * @psalm-mutation-free |
||
3104 | */ |
||
3105 | 1 | View Code Duplication | public function invoke($callable, $arguments = []): self |
3129 | |||
3130 | /** |
||
3131 | * Check whether array is associative or not. |
||
3132 | * |
||
3133 | * @param bool $recursive |
||
3134 | * |
||
3135 | * @return bool |
||
3136 | * <p>Returns true if associative, false otherwise.</p> |
||
3137 | */ |
||
3138 | 15 | View Code Duplication | public function isAssoc(bool $recursive = false): bool |
3152 | |||
3153 | /** |
||
3154 | * Check if a given key or keys are empty. |
||
3155 | * |
||
3156 | * @param int|int[]|string|string[]|null $keys |
||
3157 | * |
||
3158 | * @return bool |
||
3159 | * <p>Returns true if empty, false otherwise.</p> |
||
3160 | * @psalm-mutation-free |
||
3161 | */ |
||
3162 | 45 | public function isEmpty($keys = null): bool |
|
3180 | |||
3181 | /** |
||
3182 | * Check if the current array is equal to the given "$array" or not. |
||
3183 | * |
||
3184 | * @param array $array |
||
3185 | * |
||
3186 | * @return bool |
||
3187 | * |
||
3188 | * @psalm-param array<mixed,mixed> $array |
||
3189 | */ |
||
3190 | 1 | public function isEqual(array $array): bool |
|
3194 | |||
3195 | /** |
||
3196 | * Check if the current array is a multi-array. |
||
3197 | * |
||
3198 | * @return bool |
||
3199 | */ |
||
3200 | 22 | public function isMultiArray(): bool |
|
3208 | |||
3209 | /** |
||
3210 | * Check whether array is numeric or not. |
||
3211 | * |
||
3212 | * @return bool |
||
3213 | * <p>Returns true if numeric, false otherwise.</p> |
||
3214 | */ |
||
3215 | 5 | View Code Duplication | public function isNumeric(): bool |
3229 | |||
3230 | /** |
||
3231 | * Check if the current array is sequential [0, 1, 2, 3, 4, 5 ...] or not. |
||
3232 | * |
||
3233 | * @param bool $recursive |
||
3234 | * |
||
3235 | * @return bool |
||
3236 | * @psalm-mutation-free |
||
3237 | */ |
||
3238 | 9 | public function isSequential(bool $recursive = false): bool |
|
3255 | |||
3256 | /** |
||
3257 | * @return array |
||
3258 | * |
||
3259 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
3260 | */ |
||
3261 | 2 | public function jsonSerialize(): array |
|
3265 | |||
3266 | /** |
||
3267 | * Gets the key/index of the element at the current internal iterator position. |
||
3268 | * |
||
3269 | * @return int|string|null |
||
3270 | */ |
||
3271 | public function key() |
||
3275 | |||
3276 | /** |
||
3277 | * Checks if the given key exists in the provided array. |
||
3278 | * |
||
3279 | * INFO: This method only use "array_key_exists()" if you want to use "dot"-notation, |
||
3280 | * then you need to use "Arrayy->offsetExists()". |
||
3281 | * |
||
3282 | * @param int|string $key the key to look for |
||
3283 | * |
||
3284 | * @return bool |
||
3285 | * @psalm-mutation-free |
||
3286 | */ |
||
3287 | 162 | public function keyExists($key): bool |
|
3291 | |||
3292 | /** |
||
3293 | * Get all keys from the current array. |
||
3294 | * |
||
3295 | * @param bool $recursive [optional] <p> |
||
3296 | * Get all keys, also from all sub-arrays from an multi-dimensional array. |
||
3297 | * </p> |
||
3298 | * @param mixed|null $search_values [optional] <p> |
||
3299 | * If specified, then only keys containing these values are returned. |
||
3300 | * </p> |
||
3301 | * @param bool $strict [optional] <p> |
||
3302 | * Determines if strict comparison (===) should be used during the search. |
||
3303 | * </p> |
||
3304 | * |
||
3305 | * @return static |
||
3306 | * <p>(Immutable) An array of all the keys in input.</p> |
||
3307 | * |
||
3308 | * @psalm-return static<array-key,TKey> |
||
3309 | * @psalm-mutation-free |
||
3310 | */ |
||
3311 | 29 | public function keys( |
|
3381 | |||
3382 | /** |
||
3383 | * Sort an array by key in reverse order. |
||
3384 | * |
||
3385 | * @param int $sort_flags [optional] <p> |
||
3386 | * You may modify the behavior of the sort using the optional |
||
3387 | * parameter sort_flags, for details |
||
3388 | * see sort. |
||
3389 | * </p> |
||
3390 | * |
||
3391 | * @return $this |
||
3392 | * <p>(Mutable) Return this Arrayy object.</p> |
||
3393 | * |
||
3394 | * @psalm-return static<TKey,T> |
||
3395 | */ |
||
3396 | 4 | public function krsort(int $sort_flags = 0): self |
|
3404 | |||
3405 | /** |
||
3406 | * Sort an array by key in reverse order. |
||
3407 | * |
||
3408 | * @param int $sort_flags [optional] <p> |
||
3409 | * You may modify the behavior of the sort using the optional |
||
3410 | * parameter sort_flags, for details |
||
3411 | * see sort. |
||
3412 | * </p> |
||
3413 | * |
||
3414 | * @return $this |
||
3415 | * <p>(Immutable) Return this Arrayy object.</p> |
||
3416 | * |
||
3417 | * @psalm-return static<TKey,T> |
||
3418 | * @psalm-mutation-free |
||
3419 | */ |
||
3420 | 4 | public function krsortImmutable(int $sort_flags = 0): self |
|
3431 | |||
3432 | /** |
||
3433 | * Get the last value from the current array. |
||
3434 | * |
||
3435 | * @return mixed|null |
||
3436 | * <p>Return null if there wasn't a element.</p> |
||
3437 | * @psalm-mutation-free |
||
3438 | */ |
||
3439 | 17 | public function last() |
|
3448 | |||
3449 | /** |
||
3450 | * Get the last key from the current array. |
||
3451 | * |
||
3452 | * @return mixed|null |
||
3453 | * <p>Return null if there wasn't a element.</p> |
||
3454 | * @psalm-mutation-free |
||
3455 | */ |
||
3456 | 21 | public function lastKey() |
|
3462 | |||
3463 | /** |
||
3464 | * Get the last value(s) from the current array. |
||
3465 | * |
||
3466 | * @param int|null $number |
||
3467 | * |
||
3468 | * @return static |
||
3469 | * <p>(Immutable)</p> |
||
3470 | * |
||
3471 | * @psalm-return static<TKey,T> |
||
3472 | * @psalm-mutation-free |
||
3473 | */ |
||
3474 | 13 | public function lastsImmutable(int $number = null): self |
|
3505 | |||
3506 | /** |
||
3507 | * Get the last value(s) from the current array. |
||
3508 | * |
||
3509 | * @param int|null $number |
||
3510 | * |
||
3511 | * @return $this |
||
3512 | * <p>(Mutable)</p> |
||
3513 | * |
||
3514 | * @psalm-return static<TKey,T> |
||
3515 | */ |
||
3516 | 13 | public function lastsMutable(int $number = null): self |
|
3545 | |||
3546 | /** |
||
3547 | * Count the values from the current array. |
||
3548 | * |
||
3549 | * alias: for "Arrayy->count()" |
||
3550 | * |
||
3551 | * @param int $mode |
||
3552 | * |
||
3553 | * @return int |
||
3554 | * |
||
3555 | * @see Arrayy::count() |
||
3556 | */ |
||
3557 | 20 | public function length(int $mode = \COUNT_NORMAL): int |
|
3561 | |||
3562 | /** |
||
3563 | * Apply the given function to the every element of the array, |
||
3564 | * collecting the results. |
||
3565 | * |
||
3566 | * @param callable $callable |
||
3567 | * @param bool $useKeyAsSecondParameter |
||
3568 | * @param mixed ...$arguments |
||
3569 | * |
||
3570 | * @return static |
||
3571 | * <p>(Immutable) Arrayy object with modified elements.</p> |
||
3572 | * |
||
3573 | * @psalm-param callable(T,TKey=,mixed=):mixed $callable |
||
3574 | * @psalm-return static<TKey,T> |
||
3575 | * @psalm-mutation-free |
||
3576 | */ |
||
3577 | 5 | public function map( |
|
3610 | |||
3611 | /** |
||
3612 | * Check if all items in current array match a truth test. |
||
3613 | * |
||
3614 | * @param \Closure $closure |
||
3615 | * |
||
3616 | * @return bool |
||
3617 | */ |
||
3618 | 15 | View Code Duplication | public function matches(\Closure $closure): bool |
3634 | |||
3635 | /** |
||
3636 | * Check if any item in the current array matches a truth test. |
||
3637 | * |
||
3638 | * @param \Closure $closure |
||
3639 | * |
||
3640 | * @return bool |
||
3641 | */ |
||
3642 | 14 | View Code Duplication | public function matchesAny(\Closure $closure): bool |
3658 | |||
3659 | /** |
||
3660 | * Get the max value from an array. |
||
3661 | * |
||
3662 | * @return false|mixed |
||
3663 | * <p>Will return false if there are no values.</p> |
||
3664 | */ |
||
3665 | 10 | View Code Duplication | public function max() |
3684 | |||
3685 | /** |
||
3686 | * Merge the new $array into the current array. |
||
3687 | * |
||
3688 | * - keep key,value from the current array, also if the index is in the new $array |
||
3689 | * |
||
3690 | * @param array $array |
||
3691 | * @param bool $recursive |
||
3692 | * |
||
3693 | * @return static |
||
3694 | * <p>(Immutable)</p> |
||
3695 | * |
||
3696 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3697 | * @psalm-return static<int|TKey,T> |
||
3698 | * @psalm-mutation-free |
||
3699 | */ |
||
3700 | 32 | View Code Duplication | public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self |
3715 | |||
3716 | /** |
||
3717 | * Merge the new $array into the current array. |
||
3718 | * |
||
3719 | * - replace duplicate assoc-keys from the current array with the key,values from the new $array |
||
3720 | * - create new indexes |
||
3721 | * |
||
3722 | * @param array $array |
||
3723 | * @param bool $recursive |
||
3724 | * |
||
3725 | * @return static |
||
3726 | * <p>(Immutable)</p> |
||
3727 | * |
||
3728 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3729 | * @psalm-return static<TKey,T> |
||
3730 | * @psalm-mutation-free |
||
3731 | */ |
||
3732 | 19 | View Code Duplication | public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self |
3747 | |||
3748 | /** |
||
3749 | * Merge the the current array into the $array. |
||
3750 | * |
||
3751 | * - use key,value from the new $array, also if the index is in the current array |
||
3752 | * |
||
3753 | * @param array $array |
||
3754 | * @param bool $recursive |
||
3755 | * |
||
3756 | * @return static |
||
3757 | * <p>(Immutable)</p> |
||
3758 | * |
||
3759 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3760 | * @psalm-return static<TKey,T> |
||
3761 | * @psalm-mutation-free |
||
3762 | */ |
||
3763 | 16 | View Code Duplication | public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self |
3778 | |||
3779 | /** |
||
3780 | * Merge the current array into the new $array. |
||
3781 | * |
||
3782 | * - replace duplicate assoc-keys from new $array with the key,values from the current array |
||
3783 | * - create new indexes |
||
3784 | * |
||
3785 | * @param array $array |
||
3786 | * @param bool $recursive |
||
3787 | * |
||
3788 | * @return static |
||
3789 | * <p>(Immutable)</p> |
||
3790 | * |
||
3791 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3792 | * @psalm-return static<TKey,T> |
||
3793 | * @psalm-mutation-free |
||
3794 | */ |
||
3795 | 20 | View Code Duplication | public function mergePrependNewIndex(array $array = [], bool $recursive = false): self |
3810 | |||
3811 | /** |
||
3812 | * @return ArrayyMeta|static |
||
3813 | */ |
||
3814 | 16 | public static function meta() |
|
3818 | |||
3819 | /** |
||
3820 | * Get the min value from an array. |
||
3821 | * |
||
3822 | * @return false|mixed |
||
3823 | * <p>Will return false if there are no values.</p> |
||
3824 | */ |
||
3825 | 10 | View Code Duplication | public function min() |
3844 | |||
3845 | /** |
||
3846 | * Get the most used value from the array. |
||
3847 | * |
||
3848 | * @return mixed|null |
||
3849 | * <p>(Immutable) Return null if there wasn't a element.</p> |
||
3850 | * @psalm-mutation-free |
||
3851 | */ |
||
3852 | 3 | public function mostUsedValue() |
|
3856 | |||
3857 | /** |
||
3858 | * Get the most used value from the array. |
||
3859 | * |
||
3860 | * @param int|null $number <p>How many values you will take?</p> |
||
3861 | * |
||
3862 | * @return static |
||
3863 | * <p>(Immutable)</p> |
||
3864 | * |
||
3865 | * @psalm-return static<TKey,T> |
||
3866 | * @psalm-mutation-free |
||
3867 | */ |
||
3868 | 3 | public function mostUsedValues(int $number = null): self |
|
3872 | |||
3873 | /** |
||
3874 | * Move an array element to a new index. |
||
3875 | * |
||
3876 | * cherry-picked from: http://stackoverflow.com/questions/12624153/move-an-array-element-to-a-new-index-in-php |
||
3877 | * |
||
3878 | * @param int|string $from |
||
3879 | * @param int $to |
||
3880 | * |
||
3881 | * @return static |
||
3882 | * <p>(Immutable)</p> |
||
3883 | * |
||
3884 | * @psalm-return static<TKey,T> |
||
3885 | * @psalm-mutation-free |
||
3886 | */ |
||
3887 | 1 | public function moveElement($from, $to): self |
|
3920 | |||
3921 | /** |
||
3922 | * Move an array element to the first place. |
||
3923 | * |
||
3924 | * INFO: Instead of "Arrayy->moveElement()" this method will NOT |
||
3925 | * loss the keys of an indexed array. |
||
3926 | * |
||
3927 | * @param int|string $key |
||
3928 | * |
||
3929 | * @return static |
||
3930 | * <p>(Immutable)</p> |
||
3931 | * |
||
3932 | * @psalm-return static<TKey,T> |
||
3933 | * @psalm-mutation-free |
||
3934 | */ |
||
3935 | 1 | View Code Duplication | public function moveElementToFirstPlace($key): self |
3951 | |||
3952 | /** |
||
3953 | * Move an array element to the last place. |
||
3954 | * |
||
3955 | * INFO: Instead of "Arrayy->moveElement()" this method will NOT |
||
3956 | * loss the keys of an indexed array. |
||
3957 | * |
||
3958 | * @param int|string $key |
||
3959 | * |
||
3960 | * @return static |
||
3961 | * <p>(Immutable)</p> |
||
3962 | * |
||
3963 | * @psalm-return static<TKey,T> |
||
3964 | * @psalm-mutation-free |
||
3965 | */ |
||
3966 | 1 | View Code Duplication | public function moveElementToLastPlace($key): self |
3982 | |||
3983 | /** |
||
3984 | * Moves the internal iterator position to the next element and returns this element. |
||
3985 | * |
||
3986 | * @return false|mixed |
||
3987 | * <p>(Mutable) Will return false if there are no values.</p> |
||
3988 | */ |
||
3989 | public function next() |
||
3993 | |||
3994 | /** |
||
3995 | * Get the next nth keys and values from the array. |
||
3996 | * |
||
3997 | * @param int $step |
||
3998 | * @param int $offset |
||
3999 | * |
||
4000 | * @return static |
||
4001 | * <p>(Immutable)</p> |
||
4002 | * |
||
4003 | * @psalm-return static<TKey,T> |
||
4004 | * @psalm-mutation-free |
||
4005 | */ |
||
4006 | 1 | public function nth(int $step, int $offset = 0): self |
|
4025 | |||
4026 | /** |
||
4027 | * Get a subset of the items from the given array. |
||
4028 | * |
||
4029 | * @param mixed[] $keys |
||
4030 | * |
||
4031 | * @return static |
||
4032 | * <p>(Immutable)</p> |
||
4033 | * |
||
4034 | * @psalm-return static<TKey,T> |
||
4035 | * @psalm-mutation-free |
||
4036 | */ |
||
4037 | 1 | public function only(array $keys): self |
|
4047 | |||
4048 | /** |
||
4049 | * Pad array to the specified size with a given value. |
||
4050 | * |
||
4051 | * @param int $size <p>Size of the result array.</p> |
||
4052 | * @param mixed $value <p>Empty value by default.</p> |
||
4053 | * |
||
4054 | * @return static |
||
4055 | * <p>(Immutable) Arrayy object padded to $size with $value.</p> |
||
4056 | * |
||
4057 | * @psalm-return static<TKey,T> |
||
4058 | * @psalm-mutation-free |
||
4059 | */ |
||
4060 | 5 | public function pad(int $size, $value): self |
|
4068 | |||
4069 | /** |
||
4070 | * Partitions this array in two array according to a predicate. |
||
4071 | * Keys are preserved in the resulting array. |
||
4072 | * |
||
4073 | * @param \Closure $closure |
||
4074 | * <p>The predicate on which to partition.</p> |
||
4075 | * |
||
4076 | * @return array<int, static> |
||
4077 | * <p>An array with two elements. The first element contains the array |
||
4078 | * of elements where the predicate returned TRUE, the second element |
||
4079 | * contains the array of elements where the predicate returned FALSE.</p> |
||
4080 | * |
||
4081 | * @psalm-return array<int, static<TKey,T>> |
||
4082 | */ |
||
4083 | 1 | public function partition(\Closure $closure): array |
|
4099 | |||
4100 | /** |
||
4101 | * Pop a specified value off the end of the current array. |
||
4102 | * |
||
4103 | * @return mixed|null |
||
4104 | * <p>(Mutable) The popped element from the current array or null if the array is e.g. empty.</p> |
||
4105 | */ |
||
4106 | 5 | public function pop() |
|
4112 | |||
4113 | /** |
||
4114 | * Prepend a (key) + value to the current array. |
||
4115 | * |
||
4116 | * @param mixed $value |
||
4117 | * @param mixed $key |
||
4118 | * |
||
4119 | * @return $this |
||
4120 | * <p>(Mutable) Return this Arrayy object, with the prepended value.</p> |
||
4121 | * |
||
4122 | * @psalm-return static<TKey,T> |
||
4123 | */ |
||
4124 | 11 | public function prepend($value, $key = null) |
|
4144 | |||
4145 | /** |
||
4146 | * Add a suffix to each key. |
||
4147 | * |
||
4148 | * @param mixed $suffix |
||
4149 | * |
||
4150 | * @return static |
||
4151 | * <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> |
||
4152 | * |
||
4153 | * @psalm-return static<TKey,T> |
||
4154 | * @psalm-mutation-free |
||
4155 | */ |
||
4156 | 10 | View Code Duplication | public function prependToEachKey($suffix): self |
4182 | |||
4183 | /** |
||
4184 | * Add a suffix to each value. |
||
4185 | * |
||
4186 | * @param mixed $suffix |
||
4187 | * |
||
4188 | * @return static |
||
4189 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
||
4190 | * |
||
4191 | * @psalm-return static<TKey,T> |
||
4192 | * @psalm-mutation-free |
||
4193 | */ |
||
4194 | 10 | View Code Duplication | public function prependToEachValue($suffix): self |
4222 | |||
4223 | /** |
||
4224 | * Return the value of a given key and |
||
4225 | * delete the key. |
||
4226 | * |
||
4227 | * @param int|int[]|string|string[]|null $keyOrKeys |
||
4228 | * @param mixed $fallback |
||
4229 | * |
||
4230 | * @return mixed |
||
4231 | */ |
||
4232 | 5 | public function pull($keyOrKeys = null, $fallback = null) |
|
4254 | |||
4255 | /** |
||
4256 | * Push one or more values onto the end of array at once. |
||
4257 | * |
||
4258 | * @param array ...$args |
||
4259 | * |
||
4260 | * @return $this |
||
4261 | * <p>(Mutable) Return this Arrayy object, with pushed elements to the end of array.</p> |
||
4262 | * |
||
4263 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
4264 | * |
||
4265 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$args |
||
4266 | * @psalm-return static<TKey,T> |
||
4267 | */ |
||
4268 | 7 | public function push(...$args) |
|
4286 | |||
4287 | /** |
||
4288 | * Get a random value from the current array. |
||
4289 | * |
||
4290 | * @param int|null $number <p>How many values you will take?</p> |
||
4291 | * |
||
4292 | * @return static |
||
4293 | * <p>(Immutable)</p> |
||
4294 | * |
||
4295 | * @psalm-return static<int|array-key,T> |
||
4296 | */ |
||
4297 | 19 | public function randomImmutable(int $number = null): self |
|
4330 | |||
4331 | /** |
||
4332 | * Pick a random key/index from the keys of this array. |
||
4333 | * |
||
4334 | * @throws \RangeException If array is empty |
||
4335 | * |
||
4336 | * @return mixed |
||
4337 | * <p>Get a key/index or null if there wasn't a key/index.</p> |
||
4338 | */ |
||
4339 | 4 | public function randomKey() |
|
4349 | |||
4350 | /** |
||
4351 | * Pick a given number of random keys/indexes out of this array. |
||
4352 | * |
||
4353 | * @param int $number <p>The number of keys/indexes (should be <= \count($this->array))</p> |
||
4354 | * |
||
4355 | * @throws \RangeException If array is empty |
||
4356 | * |
||
4357 | * @return static |
||
4358 | * <p>(Immutable)</p> |
||
4359 | * |
||
4360 | * @psalm-return static<TKey,T> |
||
4361 | */ |
||
4362 | 13 | public function randomKeys(int $number): self |
|
4390 | |||
4391 | /** |
||
4392 | * Get a random value from the current array. |
||
4393 | * |
||
4394 | * @param int|null $number <p>How many values you will take?</p> |
||
4395 | * |
||
4396 | * @return $this |
||
4397 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4398 | * |
||
4399 | * @psalm-return static<TKey,T> |
||
4400 | */ |
||
4401 | 17 | public function randomMutable(int $number = null): self |
|
4426 | |||
4427 | /** |
||
4428 | * Pick a random value from the values of this array. |
||
4429 | * |
||
4430 | * @return mixed |
||
4431 | * <p>Get a random value or null if there wasn't a value.</p> |
||
4432 | */ |
||
4433 | 4 | public function randomValue() |
|
4443 | |||
4444 | /** |
||
4445 | * Pick a given number of random values out of this array. |
||
4446 | * |
||
4447 | * @param int $number |
||
4448 | * |
||
4449 | * @return static |
||
4450 | * <p>(Mutable)</p> |
||
4451 | * |
||
4452 | * @psalm-return static<TKey,T> |
||
4453 | */ |
||
4454 | 7 | public function randomValues(int $number): self |
|
4458 | |||
4459 | /** |
||
4460 | * Get a random value from an array, with the ability to skew the results. |
||
4461 | * |
||
4462 | * Example: randomWeighted(['foo' => 1, 'bar' => 2]) has a 66% chance of returning bar. |
||
4463 | * |
||
4464 | * @param array $array |
||
4465 | * @param int|null $number <p>How many values you will take?</p> |
||
4466 | * |
||
4467 | * @return static<int,mixed> |
||
4468 | * <p>(Immutable)</p> |
||
4469 | * |
||
4470 | * @psalm-param array<mixed,mixed> $array |
||
4471 | * @psalm-return static<int|array-key,T> |
||
4472 | */ |
||
4473 | 9 | public function randomWeighted(array $array, int $number = null): self |
|
4488 | |||
4489 | /** |
||
4490 | * Reduce the current array via callable e.g. anonymous-function. |
||
4491 | * |
||
4492 | * @param callable $callable |
||
4493 | * @param mixed $init |
||
4494 | * |
||
4495 | * @return static |
||
4496 | * <p>(Immutable)</p> |
||
4497 | * |
||
4498 | * @psalm-return static<TKey,T> |
||
4499 | * @psalm-mutation-free |
||
4500 | */ |
||
4501 | 18 | public function reduce($callable, $init = []): self |
|
4531 | |||
4532 | /** |
||
4533 | * @param bool $unique |
||
4534 | * |
||
4535 | * @return static |
||
4536 | * <p>(Immutable)</p> |
||
4537 | * |
||
4538 | * @psalm-return static<TKey,T> |
||
4539 | * @psalm-mutation-free |
||
4540 | */ |
||
4541 | 14 | public function reduce_dimension(bool $unique = true): self |
|
4564 | |||
4565 | /** |
||
4566 | * Create a numerically re-indexed Arrayy object. |
||
4567 | * |
||
4568 | * @return $this |
||
4569 | * <p>(Mutable) Return this Arrayy object, with re-indexed array-elements.</p> |
||
4570 | * |
||
4571 | * @psalm-return static<TKey,T> |
||
4572 | */ |
||
4573 | 9 | public function reindex(): self |
|
4581 | |||
4582 | /** |
||
4583 | * Return all items that fail the truth test. |
||
4584 | * |
||
4585 | * @param \Closure $closure |
||
4586 | * |
||
4587 | * @return static |
||
4588 | * <p>(Immutable)</p> |
||
4589 | * |
||
4590 | * @psalm-return static<TKey,T> |
||
4591 | * @psalm-mutation-free |
||
4592 | */ |
||
4593 | 1 | View Code Duplication | public function reject(\Closure $closure): self |
4610 | |||
4611 | /** |
||
4612 | * Remove a value from the current array (optional using dot-notation). |
||
4613 | * |
||
4614 | * @param mixed $key |
||
4615 | * |
||
4616 | * @return static |
||
4617 | * <p>(Mutable)</p> |
||
4618 | * |
||
4619 | * @psalm-param TKey $key |
||
4620 | * @psalm-return static<TKey,T> |
||
4621 | */ |
||
4622 | 21 | public function remove($key) |
|
4645 | |||
4646 | /** |
||
4647 | * alias: for "Arrayy->removeValue()" |
||
4648 | * |
||
4649 | * @param mixed $element |
||
4650 | * |
||
4651 | * @return static |
||
4652 | * <p>(Immutable)</p> |
||
4653 | * |
||
4654 | * @psalm-param T $element |
||
4655 | * @psalm-return static<TKey,T> |
||
4656 | * @psalm-mutation-free |
||
4657 | */ |
||
4658 | 8 | public function removeElement($element) |
|
4662 | |||
4663 | /** |
||
4664 | * Remove the first value from the current array. |
||
4665 | * |
||
4666 | * @return static |
||
4667 | * <p>(Immutable)</p> |
||
4668 | * |
||
4669 | * @psalm-return static<TKey,T> |
||
4670 | * @psalm-mutation-free |
||
4671 | */ |
||
4672 | 7 | View Code Duplication | public function removeFirst(): self |
4684 | |||
4685 | /** |
||
4686 | * Remove the last value from the current array. |
||
4687 | * |
||
4688 | * @return static |
||
4689 | * <p>(Immutable)</p> |
||
4690 | * |
||
4691 | * @psalm-return static<TKey,T> |
||
4692 | * @psalm-mutation-free |
||
4693 | */ |
||
4694 | 7 | View Code Duplication | public function removeLast(): self |
4706 | |||
4707 | /** |
||
4708 | * Removes a particular value from an array (numeric or associative). |
||
4709 | * |
||
4710 | * @param mixed $value |
||
4711 | * |
||
4712 | * @return static |
||
4713 | * <p>(Immutable)</p> |
||
4714 | * |
||
4715 | * @psalm-param T $value |
||
4716 | * @psalm-return static<TKey,T> |
||
4717 | * @psalm-mutation-free |
||
4718 | */ |
||
4719 | 8 | public function removeValue($value): self |
|
4742 | |||
4743 | /** |
||
4744 | * Generate array of repeated arrays. |
||
4745 | * |
||
4746 | * @param int $times <p>How many times has to be repeated.</p> |
||
4747 | * |
||
4748 | * @return static |
||
4749 | * <p>(Immutable)</p> |
||
4750 | * |
||
4751 | * @psalm-return static<TKey,T> |
||
4752 | * @psalm-mutation-free |
||
4753 | */ |
||
4754 | 1 | public function repeat($times): self |
|
4766 | |||
4767 | /** |
||
4768 | * Replace a key with a new key/value pair. |
||
4769 | * |
||
4770 | * @param mixed $oldKey |
||
4771 | * @param mixed $newKey |
||
4772 | * @param mixed $newValue |
||
4773 | * |
||
4774 | * @return static |
||
4775 | * <p>(Immutable)</p> |
||
4776 | * |
||
4777 | * @psalm-return static<TKey,T> |
||
4778 | * @psalm-mutation-free |
||
4779 | */ |
||
4780 | 5 | public function replace($oldKey, $newKey, $newValue): self |
|
4790 | |||
4791 | /** |
||
4792 | * Create an array using the current array as values and the other array as keys. |
||
4793 | * |
||
4794 | * @param array $keys <p>An array of keys.</p> |
||
4795 | * |
||
4796 | * @return static |
||
4797 | * <p>(Immutable) Arrayy object with keys from the other array.</p> |
||
4798 | * |
||
4799 | * @psalm-param array<mixed,mixed>|array<mixed,TKey> $keys |
||
4800 | * @psalm-return static<TKey,T> |
||
4801 | * @psalm-mutation-free |
||
4802 | */ |
||
4803 | 2 | public function replaceAllKeys(array $keys): self |
|
4811 | |||
4812 | /** |
||
4813 | * Create an array using the current array as keys and the other array as values. |
||
4814 | * |
||
4815 | * @param array $array <p>An array o values.</p> |
||
4816 | * |
||
4817 | * @return static |
||
4818 | * <p>(Immutable) Arrayy object with values from the other array.</p> |
||
4819 | * |
||
4820 | * @psalm-param array<mixed,T> $array |
||
4821 | * @psalm-return static<TKey,T> |
||
4822 | * @psalm-mutation-free |
||
4823 | */ |
||
4824 | 2 | public function replaceAllValues(array $array): self |
|
4832 | |||
4833 | /** |
||
4834 | * Replace the keys in an array with another set. |
||
4835 | * |
||
4836 | * @param array $keys <p>An array of keys matching the array's size</p> |
||
4837 | * |
||
4838 | * @return static |
||
4839 | * <p>(Immutable)</p> |
||
4840 | * |
||
4841 | * @psalm-param array<mixed,mixed>|array<mixed,TKey> $keys |
||
4842 | * @psalm-return static<TKey,T> |
||
4843 | * @psalm-mutation-free |
||
4844 | */ |
||
4845 | 1 | public function replaceKeys(array $keys): self |
|
4856 | |||
4857 | /** |
||
4858 | * Replace the first matched value in an array. |
||
4859 | * |
||
4860 | * @param mixed $search <p>The value to replace.</p> |
||
4861 | * @param mixed $replacement <p>The value to replace.</p> |
||
4862 | * |
||
4863 | * @return static |
||
4864 | * <p>(Immutable)</p> |
||
4865 | * |
||
4866 | * @psalm-return static<TKey,T> |
||
4867 | * @psalm-mutation-free |
||
4868 | */ |
||
4869 | 3 | public function replaceOneValue($search, $replacement = ''): self |
|
4884 | |||
4885 | /** |
||
4886 | * Replace values in the current array. |
||
4887 | * |
||
4888 | * @param mixed $search <p>The value to replace.</p> |
||
4889 | * @param mixed $replacement <p>What to replace it with.</p> |
||
4890 | * |
||
4891 | * @return static |
||
4892 | * <p>(Immutable)</p> |
||
4893 | * |
||
4894 | * @psalm-return static<TKey,T> |
||
4895 | * @psalm-mutation-free |
||
4896 | */ |
||
4897 | 1 | public function replaceValues($search, $replacement = ''): self |
|
4909 | |||
4910 | /** |
||
4911 | * Get the last elements from index $from until the end of this array. |
||
4912 | * |
||
4913 | * @param int $from |
||
4914 | * |
||
4915 | * @return static |
||
4916 | * <p>(Immutable)</p> |
||
4917 | * |
||
4918 | * @psalm-return static<TKey,T> |
||
4919 | * @psalm-mutation-free |
||
4920 | */ |
||
4921 | 15 | View Code Duplication | public function rest(int $from = 1): self |
4931 | |||
4932 | /** |
||
4933 | * Return the array in the reverse order. |
||
4934 | * |
||
4935 | * @return $this |
||
4936 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4937 | * |
||
4938 | * @psalm-return static<TKey,T> |
||
4939 | */ |
||
4940 | 9 | public function reverse(): self |
|
4948 | |||
4949 | /** |
||
4950 | * Sort an array in reverse order. |
||
4951 | * |
||
4952 | * @param int $sort_flags [optional] <p> |
||
4953 | * You may modify the behavior of the sort using the optional |
||
4954 | * parameter sort_flags, for details |
||
4955 | * see sort. |
||
4956 | * </p> |
||
4957 | * |
||
4958 | * @return $this |
||
4959 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4960 | * |
||
4961 | * @psalm-return static<TKey,T> |
||
4962 | */ |
||
4963 | 4 | public function rsort(int $sort_flags = 0): self |
|
4971 | |||
4972 | /** |
||
4973 | * Sort an array in reverse order. |
||
4974 | * |
||
4975 | * @param int $sort_flags [optional] <p> |
||
4976 | * You may modify the behavior of the sort using the optional |
||
4977 | * parameter sort_flags, for details |
||
4978 | * see sort. |
||
4979 | * </p> |
||
4980 | * |
||
4981 | * @return $this |
||
4982 | * <p>(Immutable) Return this Arrayy object.</p> |
||
4983 | * |
||
4984 | * @psalm-return static<TKey,T> |
||
4985 | * @psalm-mutation-free |
||
4986 | */ |
||
4987 | 4 | public function rsortImmutable(int $sort_flags = 0): self |
|
4998 | |||
4999 | /** |
||
5000 | * Search for the first index of the current array via $value. |
||
5001 | * |
||
5002 | * @param mixed $value |
||
5003 | * |
||
5004 | * @return false|float|int|string |
||
5005 | * <p>Will return <b>FALSE</b> if the value can't be found.</p> |
||
5006 | * @psalm-mutation-free |
||
5007 | */ |
||
5008 | 21 | public function searchIndex($value) |
|
5018 | |||
5019 | /** |
||
5020 | * Search for the value of the current array via $index. |
||
5021 | * |
||
5022 | * @param mixed $index |
||
5023 | * |
||
5024 | * @return static |
||
5025 | * <p>(Immutable) Will return a empty Arrayy if the value wasn't found.</p> |
||
5026 | * |
||
5027 | * @psalm-return static<TKey,T> |
||
5028 | * @psalm-mutation-free |
||
5029 | */ |
||
5030 | 9 | public function searchValue($index): self |
|
5060 | |||
5061 | /** |
||
5062 | * Set a value for the current array (optional using dot-notation). |
||
5063 | * |
||
5064 | * @param string $key <p>The key to set.</p> |
||
5065 | * @param mixed $value <p>Its value.</p> |
||
5066 | * |
||
5067 | * @return $this |
||
5068 | * <p>(Mutable) Return this Arrayy object.</p> |
||
5069 | * |
||
5070 | * @psalm-param TKey $key |
||
5071 | * @psalm-param T $value |
||
5072 | * @psalm-return static<TKey,T> |
||
5073 | */ |
||
5074 | 28 | public function set($key, $value): self |
|
5080 | |||
5081 | /** |
||
5082 | * Get a value from a array and set it if it was not. |
||
5083 | * |
||
5084 | * WARNING: this method only set the value, if the $key is not already set |
||
5085 | * |
||
5086 | * @param mixed $key <p>The key</p> |
||
5087 | * @param mixed $fallback <p>The default value to set if it isn't.</p> |
||
5088 | * |
||
5089 | * @return mixed |
||
5090 | * <p>(Mutable)</p> |
||
5091 | */ |
||
5092 | 11 | public function setAndGet($key, $fallback = null) |
|
5103 | |||
5104 | /** |
||
5105 | * Shifts a specified value off the beginning of array. |
||
5106 | * |
||
5107 | * @return mixed |
||
5108 | * <p>(Mutable) A shifted element from the current array.</p> |
||
5109 | */ |
||
5110 | 5 | public function shift() |
|
5116 | |||
5117 | /** |
||
5118 | * Shuffle the current array. |
||
5119 | * |
||
5120 | * @param bool $secure <p>using a CSPRNG | @link https://paragonie.com/b/JvICXzh_jhLyt4y3</p> |
||
5121 | * @param array $array [optional] |
||
5122 | * |
||
5123 | * @return static |
||
5124 | * <p>(Immutable)</p> |
||
5125 | * |
||
5126 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
5127 | * @psalm-return static<TKey,T> |
||
5128 | * |
||
5129 | * @noinspection BadExceptionsProcessingInspection |
||
5130 | * @noinspection RandomApiMigrationInspection |
||
5131 | * @noinspection NonSecureShuffleUsageInspection |
||
5132 | */ |
||
5133 | 2 | public function shuffle(bool $secure = false, array $array = null): self |
|
5171 | |||
5172 | /** |
||
5173 | * Count the values from the current array. |
||
5174 | * |
||
5175 | * alias: for "Arrayy->count()" |
||
5176 | * |
||
5177 | * @param int $mode |
||
5178 | * |
||
5179 | * @return int |
||
5180 | */ |
||
5181 | 20 | public function size(int $mode = \COUNT_NORMAL): int |
|
5185 | |||
5186 | /** |
||
5187 | * Checks whether array has exactly $size items. |
||
5188 | * |
||
5189 | * @param int $size |
||
5190 | * |
||
5191 | * @return bool |
||
5192 | */ |
||
5193 | 1 | public function sizeIs(int $size): bool |
|
5208 | |||
5209 | /** |
||
5210 | * Checks whether array has between $fromSize to $toSize items. $toSize can be |
||
5211 | * smaller than $fromSize. |
||
5212 | * |
||
5213 | * @param int $fromSize |
||
5214 | * @param int $toSize |
||
5215 | * |
||
5216 | * @return bool |
||
5217 | */ |
||
5218 | 1 | public function sizeIsBetween(int $fromSize, int $toSize): bool |
|
5238 | |||
5239 | /** |
||
5240 | * Checks whether array has more than $size items. |
||
5241 | * |
||
5242 | * @param int $size |
||
5243 | * |
||
5244 | * @return bool |
||
5245 | */ |
||
5246 | 1 | View Code Duplication | public function sizeIsGreaterThan(int $size): bool |
5260 | |||
5261 | /** |
||
5262 | * Checks whether array has less than $size items. |
||
5263 | * |
||
5264 | * @param int $size |
||
5265 | * |
||
5266 | * @return bool |
||
5267 | */ |
||
5268 | 1 | View Code Duplication | public function sizeIsLessThan(int $size): bool |
5282 | |||
5283 | /** |
||
5284 | * Counts all elements in an array, or something in an object. |
||
5285 | * |
||
5286 | * <p> |
||
5287 | * For objects, if you have SPL installed, you can hook into count() by implementing interface {@see Countable}. |
||
5288 | * The interface has exactly one method, {@see Countable::count()}, which returns the return value for the count() |
||
5289 | * function. Please see the {@see Array} section of the manual for a detailed explanation of how arrays are |
||
5290 | * implemented and used in PHP. |
||
5291 | * </p> |
||
5292 | * |
||
5293 | * @return int |
||
5294 | * <p> |
||
5295 | * The number of elements in var, which is |
||
5296 | * typically an array, since anything else will have one |
||
5297 | * element. |
||
5298 | * </p> |
||
5299 | * <p> |
||
5300 | * If var is not an array or an object with |
||
5301 | * implemented Countable interface, |
||
5302 | * 1 will be returned. |
||
5303 | * There is one exception, if var is &null;, |
||
5304 | * 0 will be returned. |
||
5305 | * </p> |
||
5306 | * <p> |
||
5307 | * Caution: count may return 0 for a variable that isn't set, |
||
5308 | * but it may also return 0 for a variable that has been initialized with an |
||
5309 | * empty array. Use isset to test if a variable is set. |
||
5310 | * </p> |
||
5311 | */ |
||
5312 | 10 | public function sizeRecursive(): int |
|
5316 | |||
5317 | /** |
||
5318 | * Extract a slice of the array. |
||
5319 | * |
||
5320 | * @param int $offset <p>Slice begin index.</p> |
||
5321 | * @param int|null $length <p>Length of the slice.</p> |
||
5322 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
5323 | * |
||
5324 | * @return static |
||
5325 | * <p>(Immutable) A slice of the original array with length $length.</p> |
||
5326 | * |
||
5327 | * @psalm-return static<TKey,T> |
||
5328 | * @psalm-mutation-free |
||
5329 | */ |
||
5330 | 5 | public function slice(int $offset, int $length = null, bool $preserveKeys = false) |
|
5343 | |||
5344 | /** |
||
5345 | * Sort the current array and optional you can keep the keys. |
||
5346 | * |
||
5347 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5348 | * @param int $strategy <p>sort_flags => use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5349 | * <strong>SORT_NATURAL</strong></p> |
||
5350 | * @param bool $keepKeys |
||
5351 | * |
||
5352 | * @return static |
||
5353 | * <p>(Mutable) Return this Arrayy object.</p> |
||
5354 | * |
||
5355 | * @psalm-return static<TKey,T> |
||
5356 | */ |
||
5357 | 20 | public function sort( |
|
5371 | |||
5372 | /** |
||
5373 | * Sort the current array and optional you can keep the keys. |
||
5374 | * |
||
5375 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5376 | * @param int $strategy <p>sort_flags => use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5377 | * <strong>SORT_NATURAL</strong></p> |
||
5378 | * @param bool $keepKeys |
||
5379 | * |
||
5380 | * @return static |
||
5381 | * <p>(Immutable) Return this Arrayy object.</p> |
||
5382 | * |
||
5383 | * @psalm-return static<TKey,T> |
||
5384 | */ |
||
5385 | 12 | public function sortImmutable( |
|
5401 | |||
5402 | /** |
||
5403 | * Sort the current array by key. |
||
5404 | * |
||
5405 | * @see http://php.net/manual/en/function.ksort.php |
||
5406 | * @see http://php.net/manual/en/function.krsort.php |
||
5407 | * |
||
5408 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5409 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5410 | * <strong>SORT_NATURAL</strong></p> |
||
5411 | * |
||
5412 | * @return $this |
||
5413 | * <p>(Mutable) Return this Arrayy object.</p> |
||
5414 | * |
||
5415 | * @psalm-return static<TKey,T> |
||
5416 | */ |
||
5417 | 18 | public function sortKeys( |
|
5427 | |||
5428 | /** |
||
5429 | * Sort the current array by key. |
||
5430 | * |
||
5431 | * @see http://php.net/manual/en/function.ksort.php |
||
5432 | * @see http://php.net/manual/en/function.krsort.php |
||
5433 | * |
||
5434 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5435 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5436 | * <strong>SORT_NATURAL</strong></p> |
||
5437 | * |
||
5438 | * @return $this |
||
5439 | * <p>(Immutable) Return this Arrayy object.</p> |
||
5440 | * |
||
5441 | * @psalm-return static<TKey,T> |
||
5442 | * @psalm-mutation-free |
||
5443 | */ |
||
5444 | 8 | public function sortKeysImmutable( |
|
5457 | |||
5458 | /** |
||
5459 | * Sort the current array by value. |
||
5460 | * |
||
5461 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5462 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5463 | * <strong>SORT_NATURAL</strong></p> |
||
5464 | * |
||
5465 | * @return static |
||
5466 | * <p>(Mutable)</p> |
||
5467 | * |
||
5468 | * @psalm-return static<TKey,T> |
||
5469 | */ |
||
5470 | 1 | public function sortValueKeepIndex( |
|
5476 | |||
5477 | /** |
||
5478 | * Sort the current array by value. |
||
5479 | * |
||
5480 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5481 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5482 | * <strong>SORT_NATURAL</strong></p> |
||
5483 | * |
||
5484 | * @return static |
||
5485 | * <p>(Mutable)</p> |
||
5486 | * |
||
5487 | * @psalm-return static<TKey,T> |
||
5488 | */ |
||
5489 | 1 | public function sortValueNewIndex($direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
5493 | |||
5494 | /** |
||
5495 | * Sort a array by value, by a closure or by a property. |
||
5496 | * |
||
5497 | * - If the sorter is null, the array is sorted naturally. |
||
5498 | * - Associative (string) keys will be maintained, but numeric keys will be re-indexed. |
||
5499 | * |
||
5500 | * @param callable|string|null $sorter |
||
5501 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or |
||
5502 | * <strong>SORT_DESC</strong></p> |
||
5503 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5504 | * <strong>SORT_NATURAL</strong></p> |
||
5505 | * |
||
5506 | * @return static |
||
5507 | * <p>(Immutable)</p> |
||
5508 | * |
||
5509 | * @psalm-return static<TKey,T> |
||
5510 | * @psalm-mutation-free |
||
5511 | */ |
||
5512 | 1 | public function sorter($sorter = null, $direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
5553 | |||
5554 | /** |
||
5555 | * @param int $offset |
||
5556 | * @param int|null $length |
||
5557 | * @param array $replacement |
||
5558 | * |
||
5559 | * @return static |
||
5560 | * <p>(Immutable)</p> |
||
5561 | * |
||
5562 | * @psalm-param array<mixed,mixed>|array<mixed,T> $replacement |
||
5563 | * @psalm-return static<TKey,T> |
||
5564 | * @psalm-mutation-free |
||
5565 | */ |
||
5566 | 1 | public function splice(int $offset, int $length = null, $replacement = []): self |
|
5583 | |||
5584 | /** |
||
5585 | * Split an array in the given amount of pieces. |
||
5586 | * |
||
5587 | * @param int $numberOfPieces |
||
5588 | * @param bool $keepKeys |
||
5589 | * |
||
5590 | * @return static |
||
5591 | * <p>(Immutable)</p> |
||
5592 | * |
||
5593 | * @psalm-return static<TKey,T> |
||
5594 | * @psalm-mutation-free |
||
5595 | */ |
||
5596 | 1 | public function split(int $numberOfPieces = 2, bool $keepKeys = false): self |
|
5615 | |||
5616 | /** |
||
5617 | * Stripe all empty items. |
||
5618 | * |
||
5619 | * @return static |
||
5620 | * <p>(Immutable)</p> |
||
5621 | * |
||
5622 | * @psalm-return static<TKey,T> |
||
5623 | * @psalm-mutation-free |
||
5624 | */ |
||
5625 | 1 | public function stripEmpty(): self |
|
5637 | |||
5638 | /** |
||
5639 | * Swap two values between positions by key. |
||
5640 | * |
||
5641 | * @param int|string $swapA <p>a key in the array</p> |
||
5642 | * @param int|string $swapB <p>a key in the array</p> |
||
5643 | * |
||
5644 | * @return static |
||
5645 | * <p>(Immutable)</p> |
||
5646 | * |
||
5647 | * @psalm-return static<TKey,T> |
||
5648 | * @psalm-mutation-free |
||
5649 | */ |
||
5650 | 1 | public function swap($swapA, $swapB): self |
|
5662 | |||
5663 | /** |
||
5664 | * Get the current array from the "Arrayy"-object. |
||
5665 | * alias for "getArray()" |
||
5666 | * |
||
5667 | * @param bool $convertAllArrayyElements <p> |
||
5668 | * Convert all Child-"Arrayy" objects also to arrays. |
||
5669 | * </p> |
||
5670 | * @param bool $preserveKeys <p> |
||
5671 | * e.g.: A generator maybe return the same key more then once, |
||
5672 | * so maybe you will ignore the keys. |
||
5673 | * </p> |
||
5674 | * |
||
5675 | * @return array |
||
5676 | * |
||
5677 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
5678 | * @psalm-mutation-free |
||
5679 | */ |
||
5680 | 943 | public function toArray( |
|
5705 | |||
5706 | /** |
||
5707 | * Get the current array from the "Arrayy"-object as list. |
||
5708 | * |
||
5709 | * @param bool $convertAllArrayyElements <p> |
||
5710 | * Convert all Child-"Arrayy" objects also to arrays. |
||
5711 | * </p> |
||
5712 | * |
||
5713 | * @return array |
||
5714 | * |
||
5715 | * @psalm-return list<array<TKey,T>> |
||
5716 | * @psalm-mutation-free |
||
5717 | */ |
||
5718 | 1 | public function toList(bool $convertAllArrayyElements = false): array |
|
5725 | |||
5726 | /** |
||
5727 | * Convert the current array to JSON. |
||
5728 | * |
||
5729 | * @param int $options [optional] <p>e.g. JSON_PRETTY_PRINT</p> |
||
5730 | * @param int $depth [optional] <p>Set the maximum depth. Must be greater than zero.</p> |
||
5731 | * |
||
5732 | * @return string |
||
5733 | */ |
||
5734 | 12 | public function toJson(int $options = 0, int $depth = 512): string |
|
5743 | |||
5744 | /** |
||
5745 | * @param string[]|null $items [optional] |
||
5746 | * @param string[] $helper [optional] |
||
5747 | * |
||
5748 | * @return static|static[] |
||
5749 | * |
||
5750 | * @psalm-return static<int, static<TKey,T>> |
||
5751 | */ |
||
5752 | 1 | public function toPermutation(array $items = null, array $helper = []): self |
|
5786 | |||
5787 | /** |
||
5788 | * Implodes array to a string with specified separator. |
||
5789 | * |
||
5790 | * @param string $separator [optional] <p>The element's separator.</p> |
||
5791 | * |
||
5792 | * @return string |
||
5793 | * <p>The string representation of array, separated by ",".</p> |
||
5794 | */ |
||
5795 | 19 | public function toString(string $separator = ','): string |
|
5799 | |||
5800 | /** |
||
5801 | * Return a duplicate free copy of the current array. |
||
5802 | * |
||
5803 | * @return $this |
||
5804 | * <p>(Mutable)</p> |
||
5805 | * |
||
5806 | * @psalm-return static<TKey,T> |
||
5807 | */ |
||
5808 | 13 | public function unique(): self |
|
5830 | |||
5831 | /** |
||
5832 | * Return a duplicate free copy of the current array. (with the old keys) |
||
5833 | * |
||
5834 | * @return $this |
||
5835 | * <p>(Mutable)</p> |
||
5836 | * |
||
5837 | * @psalm-return static<TKey,T> |
||
5838 | */ |
||
5839 | 11 | public function uniqueKeepIndex(): self |
|
5865 | |||
5866 | /** |
||
5867 | * alias: for "Arrayy->unique()" |
||
5868 | * |
||
5869 | * @return static |
||
5870 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
5871 | * |
||
5872 | * @see Arrayy::unique() |
||
5873 | * |
||
5874 | * @psalm-return static<TKey,T> |
||
5875 | */ |
||
5876 | 10 | public function uniqueNewIndex(): self |
|
5880 | |||
5881 | /** |
||
5882 | * Prepends one or more values to the beginning of array at once. |
||
5883 | * |
||
5884 | * @param array ...$args |
||
5885 | * |
||
5886 | * @return $this |
||
5887 | * <p>(Mutable) Return this Arrayy object, with prepended elements to the beginning of array.</p> |
||
5888 | * |
||
5889 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$args |
||
5890 | * @psalm-return static<TKey,T> |
||
5891 | */ |
||
5892 | 4 | public function unshift(...$args): self |
|
5900 | |||
5901 | /** |
||
5902 | * Tests whether the given closure return something valid for all elements of this array. |
||
5903 | * |
||
5904 | * @param \Closure $closure the predicate |
||
5905 | * |
||
5906 | * @return bool |
||
5907 | * <p>TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.</p> |
||
5908 | */ |
||
5909 | 1 | View Code Duplication | public function validate(\Closure $closure): bool |
5919 | |||
5920 | /** |
||
5921 | * Get all values from a array. |
||
5922 | * |
||
5923 | * @return static |
||
5924 | * <p>(Immutable)</p> |
||
5925 | * |
||
5926 | * @psalm-return static<TKey,T> |
||
5927 | * @psalm-mutation-free |
||
5928 | */ |
||
5929 | 2 | public function values(): self |
|
5942 | |||
5943 | /** |
||
5944 | * Apply the given function to every element in the array, discarding the results. |
||
5945 | * |
||
5946 | * @param callable $callable |
||
5947 | * @param bool $recursive <p>Whether array will be walked recursively or no</p> |
||
5948 | * |
||
5949 | * @return $this |
||
5950 | * <p>(Mutable) Return this Arrayy object, with modified elements.</p> |
||
5951 | * |
||
5952 | * @psalm-return static<TKey,T> |
||
5953 | */ |
||
5954 | 12 | public function walk($callable, bool $recursive = false): self |
|
5968 | |||
5969 | /** |
||
5970 | * Returns a collection of matching items. |
||
5971 | * |
||
5972 | * @param string $keyOrPropertyOrMethod the property or method to evaluate |
||
5973 | * @param mixed $value the value to match |
||
5974 | * |
||
5975 | * @throws \InvalidArgumentException if property or method is not defined |
||
5976 | * |
||
5977 | * @return static |
||
5978 | * |
||
5979 | * @psalm-param T $value |
||
5980 | * @psalm-return static<TKey,T> |
||
5981 | */ |
||
5982 | 1 | public function where(string $keyOrPropertyOrMethod, $value): self |
|
5995 | |||
5996 | /** |
||
5997 | * Convert an array into a object. |
||
5998 | * |
||
5999 | * @param array $array |
||
6000 | * |
||
6001 | * @return \stdClass |
||
6002 | * |
||
6003 | * @psalm-param array<mixed,mixed> $array |
||
6004 | */ |
||
6005 | 4 | final protected static function arrayToObject(array $array = []): \stdClass |
|
6024 | |||
6025 | /** |
||
6026 | * @param array|\Generator|null $input <p> |
||
6027 | * An array containing keys to return. |
||
6028 | * </p> |
||
6029 | * @param mixed|null $search_values [optional] <p> |
||
6030 | * If specified, then only keys containing these values are returned. |
||
6031 | * </p> |
||
6032 | * @param bool $strict [optional] <p> |
||
6033 | * Determines if strict comparison (===) should be used during the |
||
6034 | * search. |
||
6035 | * </p> |
||
6036 | * |
||
6037 | * @return array |
||
6038 | * <p>an array of all the keys in input</p> |
||
6039 | * |
||
6040 | * @psalm-param array<mixed,mixed>|\Generator<TKey,T>|null $input |
||
6041 | * @psalm-return array<TKey|mixed> |
||
6042 | * @psalm-mutation-free |
||
6043 | */ |
||
6044 | 11 | protected function array_keys_recursive( |
|
6105 | |||
6106 | /** |
||
6107 | * @param mixed $path |
||
6108 | * @param callable $callable |
||
6109 | * @param array|null $currentOffset |
||
6110 | * |
||
6111 | * @return void |
||
6112 | * |
||
6113 | * @psalm-param array<mixed,mixed>|array<TKey,T>|null $currentOffset |
||
6114 | * @psalm-mutation-free |
||
6115 | */ |
||
6116 | 11 | protected function callAtPath($path, $callable, &$currentOffset = null) |
|
6145 | |||
6146 | /** |
||
6147 | * Extracts the value of the given property or method from the object. |
||
6148 | * |
||
6149 | * @param static $object <p>The object to extract the value from.</p> |
||
6150 | * @param string $keyOrPropertyOrMethod <p>The property or method for which the |
||
6151 | * value should be extracted.</p> |
||
6152 | * |
||
6153 | * @throws \InvalidArgumentException if the method or property is not defined |
||
6154 | * |
||
6155 | * @return mixed |
||
6156 | * <p>The value extracted from the specified property or method.</p> |
||
6157 | * |
||
6158 | * @psalm-param self<TKey,T> $object |
||
6159 | */ |
||
6160 | 2 | final protected function extractValue(self $object, string $keyOrPropertyOrMethod) |
|
6182 | |||
6183 | /** |
||
6184 | * create a fallback for array |
||
6185 | * |
||
6186 | * 1. use the current array, if it's a array |
||
6187 | * 2. fallback to empty array, if there is nothing |
||
6188 | * 3. call "getArray()" on object, if there is a "Arrayy"-object |
||
6189 | * 4. call "createFromObject()" on object, if there is a "\Traversable"-object |
||
6190 | * 5. call "__toArray()" on object, if the method exists |
||
6191 | * 6. cast a string or object with "__toString()" into an array |
||
6192 | * 7. throw a "InvalidArgumentException"-Exception |
||
6193 | * |
||
6194 | * @param mixed $data |
||
6195 | * |
||
6196 | * @throws \InvalidArgumentException |
||
6197 | * |
||
6198 | * @return array |
||
6199 | * |
||
6200 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
6201 | */ |
||
6202 | 1196 | protected function fallbackForArray(&$data): array |
|
6212 | |||
6213 | /** |
||
6214 | * @param bool $preserveKeys <p> |
||
6215 | * e.g.: A generator maybe return the same key more then once, |
||
6216 | * so maybe you will ignore the keys. |
||
6217 | * </p> |
||
6218 | * |
||
6219 | * @return bool |
||
6220 | * |
||
6221 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
6222 | * @psalm-mutation-free :/ |
||
6223 | */ |
||
6224 | 1108 | protected function generatorToArray(bool $preserveKeys = true) |
|
6235 | |||
6236 | /** |
||
6237 | * Get correct PHP constant for direction. |
||
6238 | * |
||
6239 | * @param int|string $direction |
||
6240 | * |
||
6241 | * @return int |
||
6242 | * @psalm-mutation-free |
||
6243 | */ |
||
6244 | 43 | protected function getDirection($direction): int |
|
6266 | |||
6267 | /** |
||
6268 | * @return TypeCheckInterface[] |
||
6269 | * |
||
6270 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
6271 | */ |
||
6272 | 22 | protected function getPropertiesFromPhpDoc() |
|
6303 | |||
6304 | /** |
||
6305 | * @param mixed $glue |
||
6306 | * @param mixed $pieces |
||
6307 | * @param bool $useKeys |
||
6308 | * |
||
6309 | * @return string |
||
6310 | * @psalm-mutation-free |
||
6311 | */ |
||
6312 | 36 | protected function implode_recursive( |
|
6345 | |||
6346 | /** |
||
6347 | * @param mixed $needle <p> |
||
6348 | * The searched value. |
||
6349 | * </p> |
||
6350 | * <p> |
||
6351 | * If needle is a string, the comparison is done |
||
6352 | * in a case-sensitive manner. |
||
6353 | * </p> |
||
6354 | * @param array|\Generator|null $haystack <p> |
||
6355 | * The array. |
||
6356 | * </p> |
||
6357 | * @param bool $strict [optional] <p> |
||
6358 | * If the third parameter strict is set to true |
||
6359 | * then the in_array function will also check the |
||
6360 | * types of the |
||
6361 | * needle in the haystack. |
||
6362 | * </p> |
||
6363 | * |
||
6364 | * @return bool |
||
6365 | * <p>true if needle is found in the array, false otherwise</p> |
||
6366 | * |
||
6367 | * @psalm-param array<mixed,mixed>|\Generator<TKey,T>|null $haystack |
||
6368 | * @psalm-mutation-free |
||
6369 | */ |
||
6370 | 18 | protected function in_array_recursive($needle, $haystack = null, $strict = true): bool |
|
6395 | |||
6396 | /** |
||
6397 | * @param mixed $data |
||
6398 | * |
||
6399 | * @return array|null |
||
6400 | * |
||
6401 | * @psalm-return array<mixed,mixed>|array<TKey,T>|null |
||
6402 | */ |
||
6403 | 1196 | protected function internalGetArray(&$data) |
|
6454 | |||
6455 | /** |
||
6456 | * Internal mechanics of remove method. |
||
6457 | * |
||
6458 | * @param mixed $key |
||
6459 | * |
||
6460 | * @return bool |
||
6461 | */ |
||
6462 | 21 | protected function internalRemove($key): bool |
|
6495 | |||
6496 | /** |
||
6497 | * Internal mechanic of set method. |
||
6498 | * |
||
6499 | * @param int|string|null $key |
||
6500 | * @param mixed $value |
||
6501 | * @param bool $checkProperties |
||
6502 | * |
||
6503 | * @return bool |
||
6504 | */ |
||
6505 | 1047 | protected function internalSet( |
|
6564 | |||
6565 | /** |
||
6566 | * Convert a object into an array. |
||
6567 | * |
||
6568 | * @param mixed|object $object |
||
6569 | * |
||
6570 | * @return array|mixed |
||
6571 | * |
||
6572 | * @psalm-mutation-free |
||
6573 | */ |
||
6574 | 5 | protected static function objectToArray($object) |
|
6587 | |||
6588 | /** |
||
6589 | * @param array $data |
||
6590 | * @param bool $checkPropertiesInConstructor |
||
6591 | * |
||
6592 | * @return void |
||
6593 | * |
||
6594 | * @psalm-param array<mixed,T> $data |
||
6595 | */ |
||
6596 | 1194 | protected function setInitialValuesAndProperties(array &$data, bool $checkPropertiesInConstructor) |
|
6645 | |||
6646 | /** |
||
6647 | * sorting keys |
||
6648 | * |
||
6649 | * @param array $elements |
||
6650 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
6651 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
6652 | * <strong>SORT_NATURAL</strong></p> |
||
6653 | * |
||
6654 | * @return $this |
||
6655 | * <p>(Mutable) Return this Arrayy object.</p> |
||
6656 | * |
||
6657 | * @psalm-param array<mixed,mixed>|array<mixed|TKey,T> $elements |
||
6658 | * @psalm-return static<TKey,T> |
||
6659 | */ |
||
6660 | 18 | protected function sorterKeys( |
|
6681 | |||
6682 | /** |
||
6683 | * @param array $elements <p>Warning: used as reference</p> |
||
6684 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
6685 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
6686 | * <strong>SORT_NATURAL</strong></p> |
||
6687 | * @param bool $keepKeys |
||
6688 | * |
||
6689 | * @return $this |
||
6690 | * <p>(Mutable) Return this Arrayy object.</p> |
||
6691 | * |
||
6692 | * @psalm-param array<mixed,mixed>|array<mixed|TKey,T> $elements |
||
6693 | * @psalm-return static<TKey,T> |
||
6694 | */ |
||
6695 | 24 | protected function sorting(array &$elements, $direction = \SORT_ASC, int $strategy = \SORT_REGULAR, bool $keepKeys = false): self |
|
6725 | |||
6726 | /** |
||
6727 | * @param array $array |
||
6728 | * |
||
6729 | * @return array |
||
6730 | * |
||
6731 | * @psalm-mutation-free |
||
6732 | */ |
||
6733 | 25 | private function getArrayRecursiveHelperArrayy(array $array) |
|
6755 | |||
6756 | /** |
||
6757 | * @param int|string|null $key |
||
6758 | * @param mixed $value |
||
6759 | * |
||
6760 | * @return void |
||
6761 | */ |
||
6762 | 109 | private function checkType($key, $value) |
|
6780 | } |
||
6781 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..