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>|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 | 1173 | 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 | 2 | 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 | 4 | 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 | 6 | 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 | 17 | public function append($value, $key = null): self |
|
283 | |||
284 | /** |
||
285 | * Sort the entries by value. |
||
286 | * |
||
287 | * @param int $sort_flags [optional] <p> |
||
288 | * You may modify the behavior of the sort using the optional |
||
289 | * parameter sort_flags, for details |
||
290 | * see sort. |
||
291 | * </p> |
||
292 | * |
||
293 | * @return $this |
||
294 | * <p>(Mutable) Return this Arrayy object.</p> |
||
295 | * |
||
296 | * @psalm-return static<TKey,T> |
||
297 | */ |
||
298 | 4 | public function asort(int $sort_flags = 0): self |
|
306 | |||
307 | /** |
||
308 | * Sort the entries by value. |
||
309 | * |
||
310 | * @param int $sort_flags [optional] <p> |
||
311 | * You may modify the behavior of the sort using the optional |
||
312 | * parameter sort_flags, for details |
||
313 | * see sort. |
||
314 | * </p> |
||
315 | * |
||
316 | * @return $this |
||
317 | * <p>(Immutable) Return this Arrayy object.</p> |
||
318 | * |
||
319 | * @psalm-return static<TKey,T> |
||
320 | * @psalm-mutation-free |
||
321 | */ |
||
322 | 4 | public function asortImmutable(int $sort_flags = 0): self |
|
333 | |||
334 | /** |
||
335 | * Counts all elements in an array, or something in an object. |
||
336 | * |
||
337 | * <p> |
||
338 | * For objects, if you have SPL installed, you can hook into count() by implementing interface {@see Countable}. |
||
339 | * The interface has exactly one method, {@see Countable::count()}, which returns the return value for the count() |
||
340 | * function. Please see the {@see Array} section of the manual for a detailed explanation of how arrays are |
||
341 | * implemented and used in PHP. |
||
342 | * </p> |
||
343 | * |
||
344 | * @see http://php.net/manual/en/function.count.php |
||
345 | * |
||
346 | * @param int $mode [optional] If the optional mode parameter is set to |
||
347 | * COUNT_RECURSIVE (or 1), count |
||
348 | * will recursively count the array. This is particularly useful for |
||
349 | * counting all the elements of a multidimensional array. count does not detect infinite recursion. |
||
350 | * |
||
351 | * @return int |
||
352 | * <p> |
||
353 | * The number of elements in var, which is |
||
354 | * typically an array, since anything else will have one |
||
355 | * element. |
||
356 | * </p> |
||
357 | * <p> |
||
358 | * If var is not an array or an object with |
||
359 | * implemented Countable interface, |
||
360 | * 1 will be returned. |
||
361 | * There is one exception, if var is &null;, |
||
362 | * 0 will be returned. |
||
363 | * </p> |
||
364 | * <p> |
||
365 | * Caution: count may return 0 for a variable that isn't set, |
||
366 | * but it may also return 0 for a variable that has been initialized with an |
||
367 | * empty array. Use isset to test if a variable is set. |
||
368 | * </p> |
||
369 | * @psalm-mutation-free |
||
370 | */ |
||
371 | 147 | public function count(int $mode = \COUNT_NORMAL): int |
|
383 | |||
384 | /** |
||
385 | * Exchange the array for another one. |
||
386 | * |
||
387 | * @param array|static $data |
||
388 | * |
||
389 | * @return array |
||
390 | * |
||
391 | * @psalm-param array<TKey,T>|self<TKey,T> $data |
||
392 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
393 | */ |
||
394 | 1 | public function exchangeArray($data): array |
|
400 | |||
401 | /** |
||
402 | * Creates a copy of the ArrayyObject. |
||
403 | * |
||
404 | * @return array |
||
405 | * |
||
406 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
407 | */ |
||
408 | 6 | public function getArrayCopy(): array |
|
414 | |||
415 | /** |
||
416 | * Returns a new iterator, thus implementing the \Iterator interface. |
||
417 | * |
||
418 | * @return \Iterator<mixed, mixed> |
||
419 | * <p>An iterator for the values in the array.</p> |
||
420 | * @psalm-return \Iterator<array-key|TKey, mixed|T> |
||
421 | */ |
||
422 | 26 | public function getIterator(): \Iterator |
|
439 | |||
440 | /** |
||
441 | * Gets the iterator classname for the ArrayObject. |
||
442 | * |
||
443 | * @return string |
||
444 | * |
||
445 | * @psalm-return class-string |
||
446 | */ |
||
447 | 25 | public function getIteratorClass(): string |
|
451 | |||
452 | /** |
||
453 | * Sort the entries by key. |
||
454 | * |
||
455 | * @param int $sort_flags [optional] <p> |
||
456 | * You may modify the behavior of the sort using the optional |
||
457 | * parameter sort_flags, for details |
||
458 | * see sort. |
||
459 | * </p> |
||
460 | * |
||
461 | * @return $this |
||
462 | * <p>(Mutable) Return this Arrayy object.</p> |
||
463 | * |
||
464 | * @psalm-return static<TKey,T> |
||
465 | */ |
||
466 | 4 | public function ksort(int $sort_flags = 0): self |
|
474 | |||
475 | /** |
||
476 | * Sort the entries by key. |
||
477 | * |
||
478 | * @param int $sort_flags [optional] <p> |
||
479 | * You may modify the behavior of the sort using the optional |
||
480 | * parameter sort_flags, for details |
||
481 | * see sort. |
||
482 | * </p> |
||
483 | * |
||
484 | * @return $this |
||
485 | * <p>(Immutable) Return this Arrayy object.</p> |
||
486 | * |
||
487 | * @psalm-return static<TKey,T> |
||
488 | */ |
||
489 | 4 | public function ksortImmutable(int $sort_flags = 0): self |
|
500 | |||
501 | /** |
||
502 | * Sort an array using a case insensitive "natural order" algorithm. |
||
503 | * |
||
504 | * @return $this |
||
505 | * <p>(Mutable) Return this Arrayy object.</p> |
||
506 | * |
||
507 | * @psalm-return static<TKey,T> |
||
508 | */ |
||
509 | 8 | public function natcasesort(): self |
|
517 | |||
518 | /** |
||
519 | * Sort an array using a case insensitive "natural order" algorithm. |
||
520 | * |
||
521 | * @return $this |
||
522 | * <p>(Immutable) Return this Arrayy object.</p> |
||
523 | * |
||
524 | * @psalm-return static<TKey,T> |
||
525 | * @psalm-mutation-free |
||
526 | */ |
||
527 | 4 | public function natcasesortImmutable(): self |
|
538 | |||
539 | /** |
||
540 | * Sort entries using a "natural order" algorithm. |
||
541 | * |
||
542 | * @return $this |
||
543 | * <p>(Mutable) Return this Arrayy object.</p> |
||
544 | * |
||
545 | * @psalm-return static<TKey,T> |
||
546 | */ |
||
547 | 9 | public function natsort(): self |
|
555 | |||
556 | /** |
||
557 | * Sort entries using a "natural order" algorithm. |
||
558 | * |
||
559 | * @return $this |
||
560 | * <p>(Immutable) Return this Arrayy object.</p> |
||
561 | * |
||
562 | * @psalm-return static<TKey,T> |
||
563 | * @psalm-mutation-free |
||
564 | */ |
||
565 | 4 | public function natsortImmutable(): self |
|
576 | |||
577 | /** |
||
578 | * Whether or not an offset exists. |
||
579 | * |
||
580 | * @param bool|int|string $offset |
||
581 | * |
||
582 | * @return bool |
||
583 | * |
||
584 | * @noinspection PhpSillyAssignmentInspection |
||
585 | * |
||
586 | * @psalm-mutation-free |
||
587 | */ |
||
588 | 137 | public function offsetExists($offset): bool |
|
650 | |||
651 | /** |
||
652 | * Returns the value at specified offset. |
||
653 | * |
||
654 | * @param int|string $offset |
||
655 | * |
||
656 | * @return mixed |
||
657 | * <p>Will return null if the offset did not exists.</p> |
||
658 | */ |
||
659 | 106 | public function offsetGet($offset) |
|
663 | |||
664 | /** |
||
665 | * Assigns a value to the specified offset + check the type. |
||
666 | * |
||
667 | * @param int|string|null $offset |
||
668 | * @param mixed $value |
||
669 | * |
||
670 | * @return void |
||
671 | */ |
||
672 | 20 | public function offsetSet($offset, $value) |
|
690 | |||
691 | /** |
||
692 | * Unset an offset. |
||
693 | * |
||
694 | * @param int|string $offset |
||
695 | * |
||
696 | * @return void |
||
697 | * <p>(Mutable) Return nothing.</p> |
||
698 | */ |
||
699 | 25 | public function offsetUnset($offset) |
|
750 | |||
751 | /** |
||
752 | * Serialize the current "Arrayy"-object. |
||
753 | * |
||
754 | * @return string |
||
755 | */ |
||
756 | 2 | public function serialize(): string |
|
766 | |||
767 | /** |
||
768 | * Sets the iterator classname for the current "Arrayy"-object. |
||
769 | * |
||
770 | * @param string $iteratorClass |
||
771 | * |
||
772 | * @throws \InvalidArgumentException |
||
773 | * |
||
774 | * @return void |
||
775 | * |
||
776 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
777 | */ |
||
778 | 1164 | public function setIteratorClass($iteratorClass) |
|
800 | |||
801 | /** |
||
802 | * Sort the entries with a user-defined comparison function and maintain key association. |
||
803 | * |
||
804 | * @param callable $function |
||
805 | * |
||
806 | * @throws \InvalidArgumentException |
||
807 | * |
||
808 | * @return $this |
||
809 | * <p>(Mutable) Return this Arrayy object.</p> |
||
810 | * |
||
811 | * @psalm-return static<TKey,T> |
||
812 | */ |
||
813 | 8 | View Code Duplication | public function uasort($function): self |
825 | |||
826 | /** |
||
827 | * Sort the entries with a user-defined comparison function and maintain key association. |
||
828 | * |
||
829 | * @param callable $function |
||
830 | * |
||
831 | * @throws \InvalidArgumentException |
||
832 | * |
||
833 | * @return $this |
||
834 | * <p>(Immutable) Return this Arrayy object.</p> |
||
835 | * |
||
836 | * @psalm-return static<TKey,T> |
||
837 | * @psalm-mutation-free |
||
838 | */ |
||
839 | 4 | public function uasortImmutable($function): self |
|
850 | |||
851 | /** |
||
852 | * Sort the entries by keys using a user-defined comparison function. |
||
853 | * |
||
854 | * @param callable $function |
||
855 | * |
||
856 | * @throws \InvalidArgumentException |
||
857 | * |
||
858 | * @return static |
||
859 | * <p>(Mutable) Return this Arrayy object.</p> |
||
860 | * |
||
861 | * @psalm-return static<TKey,T> |
||
862 | */ |
||
863 | 5 | public function uksort($function): self |
|
867 | |||
868 | /** |
||
869 | * Sort the entries by keys using a user-defined comparison function. |
||
870 | * |
||
871 | * @param callable $function |
||
872 | * |
||
873 | * @throws \InvalidArgumentException |
||
874 | * |
||
875 | * @return static |
||
876 | * <p>(Immutable) Return this Arrayy object.</p> |
||
877 | * |
||
878 | * @psalm-return static<TKey,T> |
||
879 | * @psalm-mutation-free |
||
880 | */ |
||
881 | 1 | public function uksortImmutable($function): self |
|
885 | |||
886 | /** |
||
887 | * Unserialize an string and return the instance of the "Arrayy"-class. |
||
888 | * |
||
889 | * @param string $string |
||
890 | * |
||
891 | * @return $this |
||
892 | * |
||
893 | * @psalm-return static<TKey,T> |
||
894 | */ |
||
895 | 2 | public function unserialize($string): self |
|
905 | |||
906 | /** |
||
907 | * Append a (key) + values to the current array. |
||
908 | * |
||
909 | * @param array $values |
||
910 | * @param mixed $key |
||
911 | * |
||
912 | * @return $this |
||
913 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
914 | * |
||
915 | * @psalm-param array<mixed,T> $values |
||
916 | * @psalm-param TKey|null $key |
||
917 | * @psalm-return static<TKey,T> |
||
918 | */ |
||
919 | 1 | public function appendArrayValues(array $values, $key = null) |
|
945 | |||
946 | /** |
||
947 | * Add a suffix to each key. |
||
948 | * |
||
949 | * @param mixed $prefix |
||
950 | * |
||
951 | * @return static |
||
952 | * <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> |
||
953 | * |
||
954 | * @psalm-return static<TKey,T> |
||
955 | * @psalm-mutation-free |
||
956 | */ |
||
957 | 10 | View Code Duplication | public function appendToEachKey($prefix): self |
976 | |||
977 | /** |
||
978 | * Add a prefix to each value. |
||
979 | * |
||
980 | * @param mixed $prefix |
||
981 | * |
||
982 | * @return static |
||
983 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
||
984 | * |
||
985 | * @psalm-return static<TKey,T> |
||
986 | * @psalm-mutation-free |
||
987 | */ |
||
988 | 10 | View Code Duplication | public function appendToEachValue($prefix): self |
1007 | |||
1008 | /** |
||
1009 | * Sort an array in reverse order and maintain index association. |
||
1010 | * |
||
1011 | * @return $this |
||
1012 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1013 | * |
||
1014 | * @psalm-return static<TKey,T> |
||
1015 | */ |
||
1016 | 4 | public function arsort(): self |
|
1024 | |||
1025 | /** |
||
1026 | * Sort an array in reverse order and maintain index association. |
||
1027 | * |
||
1028 | * @return $this |
||
1029 | * <p>(Immutable) Return this Arrayy object.</p> |
||
1030 | * |
||
1031 | * @psalm-return static<TKey,T> |
||
1032 | * @psalm-mutation-free |
||
1033 | */ |
||
1034 | 10 | public function arsortImmutable(): self |
|
1044 | |||
1045 | /** |
||
1046 | * Iterate over the current array and execute a callback for each loop. |
||
1047 | * |
||
1048 | * @param \Closure $closure |
||
1049 | * |
||
1050 | * @return static |
||
1051 | * <p>(Immutable)</p> |
||
1052 | * |
||
1053 | * @psalm-return static<TKey,T> |
||
1054 | * @psalm-mutation-free |
||
1055 | */ |
||
1056 | 2 | public function at(\Closure $closure): self |
|
1070 | |||
1071 | /** |
||
1072 | * Returns the average value of the current array. |
||
1073 | * |
||
1074 | * @param int $decimals <p>The number of decimal-numbers to return.</p> |
||
1075 | * |
||
1076 | * @return float|int |
||
1077 | * <p>The average value.</p> |
||
1078 | * @psalm-mutation-free |
||
1079 | */ |
||
1080 | 10 | public function average($decimals = 0) |
|
1094 | |||
1095 | /** |
||
1096 | * Changes all keys in an array. |
||
1097 | * |
||
1098 | * @param int $case [optional] <p> Either <strong>CASE_UPPER</strong><br /> |
||
1099 | * or <strong>CASE_LOWER</strong> (default)</p> |
||
1100 | * |
||
1101 | * @return static |
||
1102 | * <p>(Immutable)</p> |
||
1103 | * |
||
1104 | * @psalm-return static<TKey,T> |
||
1105 | * @psalm-mutation-free |
||
1106 | */ |
||
1107 | 1 | public function changeKeyCase(int $case = \CASE_LOWER): self |
|
1134 | |||
1135 | /** |
||
1136 | * Change the path separator of the array wrapper. |
||
1137 | * |
||
1138 | * By default, the separator is: "." |
||
1139 | * |
||
1140 | * @param string $separator <p>Separator to set.</p> |
||
1141 | * |
||
1142 | * @return $this |
||
1143 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1144 | * |
||
1145 | * @psalm-return static<TKey,T> |
||
1146 | */ |
||
1147 | 11 | public function changeSeparator($separator): self |
|
1153 | |||
1154 | /** |
||
1155 | * Create a chunked version of the current array. |
||
1156 | * |
||
1157 | * @param int $size <p>Size of each chunk.</p> |
||
1158 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
1159 | * |
||
1160 | * @return static |
||
1161 | * <p>(Immutable) A new array of chunks from the original array.</p> |
||
1162 | * |
||
1163 | * @psalm-return static<TKey,T> |
||
1164 | * @psalm-mutation-free |
||
1165 | */ |
||
1166 | 5 | public function chunk($size, $preserveKeys = false): self |
|
1174 | |||
1175 | /** |
||
1176 | * Clean all falsy values from the current array. |
||
1177 | * |
||
1178 | * @return static |
||
1179 | * <p>(Immutable)</p> |
||
1180 | * |
||
1181 | * @psalm-return static<TKey,T> |
||
1182 | * @psalm-mutation-free |
||
1183 | */ |
||
1184 | 8 | public function clean(): self |
|
1192 | |||
1193 | /** |
||
1194 | * WARNING!!! -> Clear the current full array or a $key of it. |
||
1195 | * |
||
1196 | * @param int|int[]|string|string[]|null $key |
||
1197 | * |
||
1198 | * @return $this |
||
1199 | * <p>(Mutable) Return this Arrayy object, with an empty array.</p> |
||
1200 | * |
||
1201 | * @psalm-return static<TKey,T> |
||
1202 | */ |
||
1203 | 10 | public function clear($key = null): self |
|
1222 | |||
1223 | /** |
||
1224 | * Check if an item is in the current array. |
||
1225 | * |
||
1226 | * @param float|int|string $value |
||
1227 | * @param bool $recursive |
||
1228 | * @param bool $strict |
||
1229 | * |
||
1230 | * @return bool |
||
1231 | * @psalm-mutation-free |
||
1232 | */ |
||
1233 | 23 | public function contains($value, bool $recursive = false, bool $strict = true): bool |
|
1254 | |||
1255 | /** |
||
1256 | * Check if an (case-insensitive) string is in the current array. |
||
1257 | * |
||
1258 | * @param mixed $value |
||
1259 | * @param bool $recursive |
||
1260 | * |
||
1261 | * @return bool |
||
1262 | * @psalm-mutation-free |
||
1263 | * |
||
1264 | * @psalm-suppress InvalidCast - hack for int|float|bool support |
||
1265 | */ |
||
1266 | 26 | public function containsCaseInsensitive($value, $recursive = false): bool |
|
1295 | |||
1296 | /** |
||
1297 | * Check if the given key/index exists in the array. |
||
1298 | * |
||
1299 | * @param int|string $key <p>key/index to search for</p> |
||
1300 | * |
||
1301 | * @return bool |
||
1302 | * <p>Returns true if the given key/index exists in the array, false otherwise.</p> |
||
1303 | * |
||
1304 | * @psalm-mutation-free |
||
1305 | */ |
||
1306 | 4 | public function containsKey($key): bool |
|
1310 | |||
1311 | /** |
||
1312 | * Check if all given needles are present in the array as key/index. |
||
1313 | * |
||
1314 | * @param array $needles <p>The keys you are searching for.</p> |
||
1315 | * @param bool $recursive |
||
1316 | * |
||
1317 | * @return bool |
||
1318 | * <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p> |
||
1319 | * |
||
1320 | * @psalm-param array<mixed,mixed>|array<TKey> $needles |
||
1321 | * @psalm-mutation-free |
||
1322 | */ |
||
1323 | 2 | public function containsKeys(array $needles, $recursive = false): bool |
|
1351 | |||
1352 | /** |
||
1353 | * Check if all given needles are present in the array as key/index. |
||
1354 | * |
||
1355 | * @param array $needles <p>The keys you are searching for.</p> |
||
1356 | * |
||
1357 | * @return bool |
||
1358 | * <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p> |
||
1359 | * |
||
1360 | * @psalm-param array<mixed,mixed>|array<TKey> $needles |
||
1361 | * @psalm-mutation-free |
||
1362 | */ |
||
1363 | 1 | public function containsKeysRecursive(array $needles): bool |
|
1367 | |||
1368 | /** |
||
1369 | * alias: for "Arrayy->contains()" |
||
1370 | * |
||
1371 | * @param float|int|string $value |
||
1372 | * |
||
1373 | * @return bool |
||
1374 | * |
||
1375 | * @see Arrayy::contains() |
||
1376 | * @psalm-mutation-free |
||
1377 | */ |
||
1378 | 9 | public function containsValue($value): bool |
|
1382 | |||
1383 | /** |
||
1384 | * alias: for "Arrayy->contains($value, true)" |
||
1385 | * |
||
1386 | * @param float|int|string $value |
||
1387 | * |
||
1388 | * @return bool |
||
1389 | * |
||
1390 | * @see Arrayy::contains() |
||
1391 | * @psalm-mutation-free |
||
1392 | */ |
||
1393 | 18 | public function containsValueRecursive($value): bool |
|
1397 | |||
1398 | /** |
||
1399 | * Check if all given needles are present in the array. |
||
1400 | * |
||
1401 | * @param array $needles |
||
1402 | * |
||
1403 | * @return bool |
||
1404 | * <p>Returns true if all the given values exists in the array, false otherwise.</p> |
||
1405 | * |
||
1406 | * @psalm-param array<mixed>|array<T> $needles |
||
1407 | * @psalm-mutation-free |
||
1408 | */ |
||
1409 | 1 | public function containsValues(array $needles): bool |
|
1415 | |||
1416 | /** |
||
1417 | * Counts all the values of an array |
||
1418 | * |
||
1419 | * @see http://php.net/manual/en/function.array-count-values.php |
||
1420 | * |
||
1421 | * @return static |
||
1422 | * <p> |
||
1423 | * (Immutable) |
||
1424 | * An associative Arrayy-object of values from input as |
||
1425 | * keys and their count as value. |
||
1426 | * </p> |
||
1427 | * |
||
1428 | * @psalm-return static<TKey,T> |
||
1429 | * @psalm-mutation-free |
||
1430 | */ |
||
1431 | 7 | public function countValues(): self |
|
1435 | |||
1436 | /** |
||
1437 | * Creates an Arrayy object. |
||
1438 | * |
||
1439 | * @param mixed $data |
||
1440 | * @param string $iteratorClass |
||
1441 | * @param bool $checkPropertiesInConstructor |
||
1442 | * |
||
1443 | * @return static |
||
1444 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1445 | * |
||
1446 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
1447 | * |
||
1448 | * @psalm-mutation-free |
||
1449 | */ |
||
1450 | 692 | public static function create( |
|
1461 | |||
1462 | /** |
||
1463 | * Flatten an array with the given character as a key delimiter |
||
1464 | * |
||
1465 | * @param string $delimiter |
||
1466 | * @param string $prepend |
||
1467 | * @param array|null $items |
||
1468 | * |
||
1469 | * @return array |
||
1470 | */ |
||
1471 | 2 | public function flatten($delimiter = '.', $prepend = '', $items = null) |
|
1494 | |||
1495 | /** |
||
1496 | * WARNING: Creates an Arrayy object by reference. |
||
1497 | * |
||
1498 | * @param array $array |
||
1499 | * |
||
1500 | * @return $this |
||
1501 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1502 | * |
||
1503 | * @psalm-param array<mixed,mixed>|array<array-key,mixed> $array |
||
1504 | */ |
||
1505 | 2 | public function createByReference(array &$array = []): self |
|
1513 | |||
1514 | /** |
||
1515 | * Create an new instance from a callable function which will return an Generator. |
||
1516 | * |
||
1517 | * @param callable $generatorFunction |
||
1518 | * |
||
1519 | * @return static |
||
1520 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1521 | * |
||
1522 | * @psalm-param callable():\Generator<array-key,mixed> $generatorFunction |
||
1523 | * |
||
1524 | * @psalm-mutation-free |
||
1525 | */ |
||
1526 | 7 | public static function createFromGeneratorFunction(callable $generatorFunction): self |
|
1530 | |||
1531 | /** |
||
1532 | * Create an new instance filled with a copy of values from a "Generator"-object. |
||
1533 | * |
||
1534 | * @param \Generator $generator |
||
1535 | * |
||
1536 | * @return static |
||
1537 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1538 | * |
||
1539 | * @psalm-param \Generator<array-key,mixed> $generator |
||
1540 | * |
||
1541 | * @psalm-mutation-free |
||
1542 | */ |
||
1543 | 4 | public static function createFromGeneratorImmutable(\Generator $generator): self |
|
1547 | |||
1548 | /** |
||
1549 | * Create an new Arrayy object via JSON. |
||
1550 | * |
||
1551 | * @param string $json |
||
1552 | * |
||
1553 | * @return static |
||
1554 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1555 | * |
||
1556 | * @psalm-mutation-free |
||
1557 | */ |
||
1558 | 5 | public static function createFromJson(string $json): self |
|
1562 | |||
1563 | /** |
||
1564 | * Create an new Arrayy object via JSON. |
||
1565 | * |
||
1566 | * @param array $array |
||
1567 | * |
||
1568 | * @return static |
||
1569 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1570 | * |
||
1571 | * @psalm-mutation-free |
||
1572 | */ |
||
1573 | 1 | public static function createFromArray(array $array): self |
|
1577 | |||
1578 | /** |
||
1579 | * Create an new instance filled with values from an object that is iterable. |
||
1580 | * |
||
1581 | * @param \Traversable $object <p>iterable object</p> |
||
1582 | * |
||
1583 | * @return static |
||
1584 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1585 | * |
||
1586 | * @psalm-param \Traversable<array-key,mixed> $object |
||
1587 | * |
||
1588 | * @psalm-mutation-free |
||
1589 | */ |
||
1590 | 4 | public static function createFromObject(\Traversable $object): self |
|
1610 | |||
1611 | /** |
||
1612 | * Create an new instance filled with values from an object. |
||
1613 | * |
||
1614 | * @param object $object |
||
1615 | * |
||
1616 | * @return static |
||
1617 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1618 | * |
||
1619 | * @psalm-mutation-free |
||
1620 | */ |
||
1621 | 5 | public static function createFromObjectVars($object): self |
|
1625 | |||
1626 | /** |
||
1627 | * Create an new Arrayy object via string. |
||
1628 | * |
||
1629 | * @param string $str <p>The input string.</p> |
||
1630 | * @param string|null $delimiter <p>The boundary string.</p> |
||
1631 | * @param string|null $regEx <p>Use the $delimiter or the $regEx, so if $pattern is null, $delimiter will be |
||
1632 | * used.</p> |
||
1633 | * |
||
1634 | * @return static |
||
1635 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1636 | * |
||
1637 | * @psalm-mutation-free |
||
1638 | */ |
||
1639 | 10 | public static function createFromString(string $str, string $delimiter = null, string $regEx = null): self |
|
1671 | |||
1672 | /** |
||
1673 | * Create an new instance filled with a copy of values from a "Traversable"-object. |
||
1674 | * |
||
1675 | * @param \Traversable $traversable |
||
1676 | * |
||
1677 | * @return static |
||
1678 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1679 | * |
||
1680 | * @psalm-param \Traversable<array-key,mixed> $traversable |
||
1681 | * |
||
1682 | * @psalm-mutation-free |
||
1683 | */ |
||
1684 | 1 | public static function createFromTraversableImmutable(\Traversable $traversable): self |
|
1688 | |||
1689 | /** |
||
1690 | * Create an new instance containing a range of elements. |
||
1691 | * |
||
1692 | * @param float|int|string $low <p>First value of the sequence.</p> |
||
1693 | * @param float|int|string $high <p>The sequence is ended upon reaching the end value.</p> |
||
1694 | * @param float|int $step <p>Used as the increment between elements in the sequence.</p> |
||
1695 | * |
||
1696 | * @return static |
||
1697 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1698 | * |
||
1699 | * @psalm-mutation-free |
||
1700 | */ |
||
1701 | 2 | public static function createWithRange($low, $high, $step = 1): self |
|
1705 | |||
1706 | /** |
||
1707 | * Gets the element of the array at the current internal iterator position. |
||
1708 | * |
||
1709 | * @return false|mixed |
||
1710 | */ |
||
1711 | public function current() |
||
1715 | |||
1716 | /** |
||
1717 | * Custom sort by index via "uksort". |
||
1718 | * |
||
1719 | * @see http://php.net/manual/en/function.uksort.php |
||
1720 | * |
||
1721 | * @param callable $function |
||
1722 | * |
||
1723 | * @throws \InvalidArgumentException |
||
1724 | * |
||
1725 | * @return $this |
||
1726 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1727 | * |
||
1728 | * @psalm-return static<TKey,T> |
||
1729 | */ |
||
1730 | 5 | public function customSortKeys(callable $function): self |
|
1738 | |||
1739 | /** |
||
1740 | * Custom sort by index via "uksort". |
||
1741 | * |
||
1742 | * @see http://php.net/manual/en/function.uksort.php |
||
1743 | * |
||
1744 | * @param callable $function |
||
1745 | * |
||
1746 | * @throws \InvalidArgumentException |
||
1747 | * |
||
1748 | * @return $this |
||
1749 | * <p>(Immutable) Return this Arrayy object.</p> |
||
1750 | * |
||
1751 | * @psalm-return static<TKey,T> |
||
1752 | * @psalm-mutation-free |
||
1753 | */ |
||
1754 | 1 | public function customSortKeysImmutable(callable $function): self |
|
1767 | |||
1768 | /** |
||
1769 | * Custom sort by value via "usort". |
||
1770 | * |
||
1771 | * @see http://php.net/manual/en/function.usort.php |
||
1772 | * |
||
1773 | * @param callable $function |
||
1774 | * |
||
1775 | * @throws \InvalidArgumentException |
||
1776 | * |
||
1777 | * @return $this |
||
1778 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1779 | * |
||
1780 | * @psalm-return static<TKey,T> |
||
1781 | */ |
||
1782 | 10 | View Code Duplication | public function customSortValues($function): self |
1794 | |||
1795 | /** |
||
1796 | * Custom sort by value via "usort". |
||
1797 | * |
||
1798 | * @see http://php.net/manual/en/function.usort.php |
||
1799 | * |
||
1800 | * @param callable $function |
||
1801 | * |
||
1802 | * @throws \InvalidArgumentException |
||
1803 | * |
||
1804 | * @return $this |
||
1805 | * <p>(Immutable) Return this Arrayy object.</p> |
||
1806 | * |
||
1807 | * @psalm-return static<TKey,T> |
||
1808 | * @psalm-mutation-free |
||
1809 | */ |
||
1810 | 4 | public function customSortValuesImmutable($function): self |
|
1821 | |||
1822 | /** |
||
1823 | * Delete the given key or keys. |
||
1824 | * |
||
1825 | * @param int|int[]|string|string[] $keyOrKeys |
||
1826 | * |
||
1827 | * @return void |
||
1828 | */ |
||
1829 | 9 | public function delete($keyOrKeys) |
|
1837 | |||
1838 | /** |
||
1839 | * Return values that are only in the current array. |
||
1840 | * |
||
1841 | * @param array ...$array |
||
1842 | * |
||
1843 | * @return static |
||
1844 | * <p>(Immutable)</p> |
||
1845 | * |
||
1846 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
1847 | * @psalm-return static<TKey,T> |
||
1848 | * @psalm-mutation-free |
||
1849 | */ |
||
1850 | 13 | public function diff(...$array): self |
|
1858 | |||
1859 | /** |
||
1860 | * Return values that are only in the current array. |
||
1861 | * |
||
1862 | * @param array ...$array |
||
1863 | * |
||
1864 | * @return static |
||
1865 | * <p>(Immutable)</p> |
||
1866 | * |
||
1867 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
1868 | * @psalm-return static<TKey,T> |
||
1869 | * @psalm-mutation-free |
||
1870 | */ |
||
1871 | 8 | public function diffKey(...$array): self |
|
1879 | |||
1880 | /** |
||
1881 | * Return values and Keys that are only in the current array. |
||
1882 | * |
||
1883 | * @param array $array |
||
1884 | * |
||
1885 | * @return static |
||
1886 | * <p>(Immutable)</p> |
||
1887 | * |
||
1888 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1889 | * @psalm-return static<TKey,T> |
||
1890 | * @psalm-mutation-free |
||
1891 | */ |
||
1892 | 8 | public function diffKeyAndValue(array $array = []): self |
|
1900 | |||
1901 | /** |
||
1902 | * Return values that are only in the current multi-dimensional array. |
||
1903 | * |
||
1904 | * @param array $array |
||
1905 | * @param array|\Generator|null $helperVariableForRecursion <p>(only for internal usage)</p> |
||
1906 | * |
||
1907 | * @return static |
||
1908 | * <p>(Immutable)</p> |
||
1909 | * |
||
1910 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1911 | * @psalm-param null|array<TKey,T>|\Generator<TKey,T> $helperVariableForRecursion |
||
1912 | * @psalm-return static<TKey,T> |
||
1913 | * @psalm-mutation-free |
||
1914 | */ |
||
1915 | 1 | public function diffRecursive(array $array = [], $helperVariableForRecursion = null): self |
|
1950 | |||
1951 | /** |
||
1952 | * Return values that are only in the new $array. |
||
1953 | * |
||
1954 | * @param array $array |
||
1955 | * |
||
1956 | * @return static |
||
1957 | * <p>(Immutable)</p> |
||
1958 | * |
||
1959 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1960 | * @psalm-return static<TKey,T> |
||
1961 | * @psalm-mutation-free |
||
1962 | */ |
||
1963 | 8 | public function diffReverse(array $array = []): self |
|
1971 | |||
1972 | /** |
||
1973 | * Divide an array into two arrays. One with keys and the other with values. |
||
1974 | * |
||
1975 | * @return static |
||
1976 | * <p>(Immutable)</p> |
||
1977 | * |
||
1978 | * @psalm-return static<TKey,T> |
||
1979 | * @psalm-mutation-free |
||
1980 | */ |
||
1981 | 1 | public function divide(): self |
|
1992 | |||
1993 | /** |
||
1994 | * Iterate over the current array and modify the array's value. |
||
1995 | * |
||
1996 | * @param \Closure $closure |
||
1997 | * |
||
1998 | * @return static |
||
1999 | * <p>(Immutable)</p> |
||
2000 | * |
||
2001 | * @psalm-return static<TKey,T> |
||
2002 | * @psalm-mutation-free |
||
2003 | */ |
||
2004 | 5 | View Code Duplication | public function each(\Closure $closure): self |
2019 | |||
2020 | /** |
||
2021 | * Sets the internal iterator to the last element in the array and returns this element. |
||
2022 | * |
||
2023 | * @return mixed |
||
2024 | */ |
||
2025 | public function end() |
||
2029 | |||
2030 | /** |
||
2031 | * Check if a value is in the current array using a closure. |
||
2032 | * |
||
2033 | * @param \Closure $closure |
||
2034 | * |
||
2035 | * @return bool |
||
2036 | * <p>Returns true if the given value is found, false otherwise.</p> |
||
2037 | */ |
||
2038 | 4 | public function exists(\Closure $closure): bool |
|
2053 | |||
2054 | /** |
||
2055 | * Fill the array until "$num" with "$default" values. |
||
2056 | * |
||
2057 | * @param int $num |
||
2058 | * @param mixed $default |
||
2059 | * |
||
2060 | * @return static |
||
2061 | * <p>(Immutable)</p> |
||
2062 | * |
||
2063 | * @psalm-return static<TKey,T> |
||
2064 | * @psalm-mutation-free |
||
2065 | */ |
||
2066 | 8 | public function fillWithDefaults(int $num, $default = null): self |
|
2089 | |||
2090 | /** |
||
2091 | * Find all items in an array that pass the truth test. |
||
2092 | * |
||
2093 | * @param \Closure|null $closure [optional] <p> |
||
2094 | * The callback function to use |
||
2095 | * </p> |
||
2096 | * <p> |
||
2097 | * If no callback is supplied, all entries of |
||
2098 | * input equal to false (see |
||
2099 | * converting to |
||
2100 | * boolean) will be removed. |
||
2101 | * </p> |
||
2102 | * @param int $flag [optional] <p> |
||
2103 | * Flag determining what arguments are sent to <i>callback</i>: |
||
2104 | * </p><ul> |
||
2105 | * <li> |
||
2106 | * <b>ARRAY_FILTER_USE_KEY</b> [1] - pass key as the only argument |
||
2107 | * to <i>callback</i> instead of the value</span> |
||
2108 | * </li> |
||
2109 | * <li> |
||
2110 | * <b>ARRAY_FILTER_USE_BOTH</b> [2] - pass both value and key as |
||
2111 | * arguments to <i>callback</i> instead of the value</span> |
||
2112 | * </li> |
||
2113 | * </ul> |
||
2114 | * |
||
2115 | * @return static |
||
2116 | * <p>(Immutable)</p> |
||
2117 | * |
||
2118 | * @psalm-param \Closure(T=,TKey=):bool|\Closure(T=):bool $closure |
||
2119 | * @psalm-return static<TKey,T> |
||
2120 | * @psalm-mutation-free |
||
2121 | */ |
||
2122 | 12 | public function filter($closure = null, int $flag = \ARRAY_FILTER_USE_BOTH) |
|
2134 | |||
2135 | /** |
||
2136 | * Filters an array of objects (or a numeric array of associative arrays) based on the value of a particular |
||
2137 | * property within that. |
||
2138 | * |
||
2139 | * @param string $property |
||
2140 | * @param string|string[] $value |
||
2141 | * @param string $comparisonOp |
||
2142 | * <p> |
||
2143 | * 'eq' (equals),<br /> |
||
2144 | * 'gt' (greater),<br /> |
||
2145 | * 'gte' || 'ge' (greater or equals),<br /> |
||
2146 | * 'lt' (less),<br /> |
||
2147 | * 'lte' || 'le' (less or equals),<br /> |
||
2148 | * 'ne' (not equals),<br /> |
||
2149 | * 'contains',<br /> |
||
2150 | * 'notContains',<br /> |
||
2151 | * 'newer' (via strtotime),<br /> |
||
2152 | * 'older' (via strtotime),<br /> |
||
2153 | * </p> |
||
2154 | * |
||
2155 | * @return static |
||
2156 | * <p>(Immutable)</p> |
||
2157 | * |
||
2158 | * @psalm-return static<TKey,T> |
||
2159 | * @psalm-mutation-free |
||
2160 | * |
||
2161 | * @psalm-suppress MissingClosureReturnType |
||
2162 | * @psalm-suppress MissingClosureParamType |
||
2163 | */ |
||
2164 | 1 | public function filterBy( |
|
2236 | |||
2237 | /** |
||
2238 | * Find the first item in an array that passes the truth test, |
||
2239 | * otherwise return false |
||
2240 | * |
||
2241 | * @param \Closure $closure |
||
2242 | * |
||
2243 | * @return false|mixed |
||
2244 | * <p>Return false if we did not find the value.</p> |
||
2245 | */ |
||
2246 | 8 | View Code Duplication | public function find(\Closure $closure) |
2256 | |||
2257 | /** |
||
2258 | * find by ... |
||
2259 | * |
||
2260 | * @param string $property |
||
2261 | * @param string|string[] $value |
||
2262 | * @param string $comparisonOp |
||
2263 | * |
||
2264 | * @return static |
||
2265 | * <p>(Immutable)</p> |
||
2266 | * |
||
2267 | * @psalm-return static<TKey,T> |
||
2268 | * @psalm-mutation-free |
||
2269 | */ |
||
2270 | 1 | public function findBy(string $property, $value, string $comparisonOp = 'eq'): self |
|
2274 | |||
2275 | /** |
||
2276 | * Get the first value from the current array. |
||
2277 | * |
||
2278 | * @return mixed |
||
2279 | * <p>Return null if there wasn't a element.</p> |
||
2280 | */ |
||
2281 | 21 | public function first() |
|
2290 | |||
2291 | /** |
||
2292 | * Get the first key from the current array. |
||
2293 | * |
||
2294 | * @return mixed |
||
2295 | * <p>Return null if there wasn't a element.</p> |
||
2296 | * @psalm-mutation-free |
||
2297 | */ |
||
2298 | 28 | public function firstKey() |
|
2304 | |||
2305 | /** |
||
2306 | * Get the first value(s) from the current array. |
||
2307 | * And will return an empty array if there was no first entry. |
||
2308 | * |
||
2309 | * @param int|null $number <p>How many values you will take?</p> |
||
2310 | * |
||
2311 | * @return static |
||
2312 | * <p>(Immutable)</p> |
||
2313 | * |
||
2314 | * @psalm-return static<TKey,T> |
||
2315 | * @psalm-mutation-free |
||
2316 | */ |
||
2317 | 37 | View Code Duplication | public function firstsImmutable(int $number = null): self |
2334 | |||
2335 | /** |
||
2336 | * Get the first value(s) from the current array. |
||
2337 | * And will return an empty array if there was no first entry. |
||
2338 | * |
||
2339 | * @param int|null $number <p>How many values you will take?</p> |
||
2340 | * |
||
2341 | * @return static |
||
2342 | * <p>(Immutable)</p> |
||
2343 | * |
||
2344 | * @psalm-return static<TKey,T> |
||
2345 | * @psalm-mutation-free |
||
2346 | */ |
||
2347 | 3 | View Code Duplication | public function firstsKeys(int $number = null): self |
2364 | |||
2365 | /** |
||
2366 | * Get and rmove the first value(s) from the current array. |
||
2367 | * And will return an empty array if there was no first entry. |
||
2368 | * |
||
2369 | * @param int|null $number <p>How many values you will take?</p> |
||
2370 | * |
||
2371 | * @return $this |
||
2372 | * <p>(Mutable)</p> |
||
2373 | * |
||
2374 | * @psalm-return static<TKey,T> |
||
2375 | */ |
||
2376 | 34 | public function firstsMutable(int $number = null): self |
|
2389 | |||
2390 | /** |
||
2391 | * Exchanges all keys with their associated values in an array. |
||
2392 | * |
||
2393 | * @return static |
||
2394 | * <p>(Immutable)</p> |
||
2395 | * |
||
2396 | * @psalm-return static<TKey,T> |
||
2397 | * @psalm-mutation-free |
||
2398 | */ |
||
2399 | 1 | public function flip(): self |
|
2407 | |||
2408 | /** |
||
2409 | * Get a value from an array (optional using dot-notation). |
||
2410 | * |
||
2411 | * @param mixed $key <p>The key to look for.</p> |
||
2412 | * @param mixed $fallback <p>Value to fallback to.</p> |
||
2413 | * @param array $array <p>The array to get from, if it's set to "null" we use the current array from the |
||
2414 | * class.</p> |
||
2415 | * |
||
2416 | * @return mixed|static |
||
2417 | * |
||
2418 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
2419 | * @psalm-mutation-free |
||
2420 | */ |
||
2421 | 219 | public function get($key, $fallback = null, array $array = null) |
|
2513 | |||
2514 | /** |
||
2515 | * alias: for "Arrayy->toArray()" |
||
2516 | * |
||
2517 | * @return array |
||
2518 | * |
||
2519 | * @see Arrayy::getArray() |
||
2520 | * |
||
2521 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
2522 | */ |
||
2523 | 12 | public function getAll(): array |
|
2527 | |||
2528 | /** |
||
2529 | * Get the current array from the "Arrayy"-object. |
||
2530 | * |
||
2531 | * alias for "toArray()" |
||
2532 | * |
||
2533 | * @param bool $convertAllArrayyElements <p> |
||
2534 | * Convert all Child-"Arrayy" objects also to arrays. |
||
2535 | * </p> |
||
2536 | * @param bool $preserveKeys <p> |
||
2537 | * e.g.: A generator maybe return the same key more then once, |
||
2538 | * so maybe you will ignore the keys. |
||
2539 | * </p> |
||
2540 | * |
||
2541 | * @return array |
||
2542 | * |
||
2543 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
2544 | * @psalm-mutation-free |
||
2545 | * |
||
2546 | * @see Arrayy::toArray() |
||
2547 | */ |
||
2548 | 494 | public function getArray( |
|
2557 | |||
2558 | /** |
||
2559 | * Get the current array from the "Arrayy"-object as list. |
||
2560 | * |
||
2561 | * alias for "toList()" |
||
2562 | * |
||
2563 | * @param bool $convertAllArrayyElements <p> |
||
2564 | * Convert all Child-"Arrayy" objects also to arrays. |
||
2565 | * </p> |
||
2566 | * |
||
2567 | * @return array |
||
2568 | * |
||
2569 | * @psalm-return array<int,mixed>|array<int,T> |
||
2570 | * @psalm-mutation-free |
||
2571 | * |
||
2572 | * @see Arrayy::toList() |
||
2573 | */ |
||
2574 | 1 | public function getList(bool $convertAllArrayyElements = false): array |
|
2578 | |||
2579 | /** |
||
2580 | * Returns the values from a single column of the input array, identified by |
||
2581 | * the $columnKey, can be used to extract data-columns from multi-arrays. |
||
2582 | * |
||
2583 | * Info: Optionally, you may provide an $indexKey to index the values in the returned |
||
2584 | * array by the values from the $indexKey column in the input array. |
||
2585 | * |
||
2586 | * @param mixed $columnKey |
||
2587 | * @param mixed $indexKey |
||
2588 | * |
||
2589 | * @return static |
||
2590 | * <p>(Immutable)</p> |
||
2591 | * |
||
2592 | * @psalm-return static<TKey,T> |
||
2593 | * @psalm-mutation-free |
||
2594 | */ |
||
2595 | 1 | public function getColumn($columnKey = null, $indexKey = null): self |
|
2603 | |||
2604 | /** |
||
2605 | * Get the current array from the "Arrayy"-object as generator. |
||
2606 | * |
||
2607 | * @return \Generator |
||
2608 | * |
||
2609 | * @psalm-return \Generator<mixed,T>|\Generator<TKey,T> |
||
2610 | * @psalm-mutation-free |
||
2611 | */ |
||
2612 | 1012 | public function getGenerator(): \Generator |
|
2620 | |||
2621 | /** |
||
2622 | * alias: for "Arrayy->keys()" |
||
2623 | * |
||
2624 | * @return static |
||
2625 | * <p>(Immutable)</p> |
||
2626 | * |
||
2627 | * @see Arrayy::keys() |
||
2628 | * |
||
2629 | * @psalm-return static<array-key,TKey> |
||
2630 | * @psalm-mutation-free |
||
2631 | */ |
||
2632 | 2 | public function getKeys() |
|
2636 | |||
2637 | /** |
||
2638 | * Get the current array from the "Arrayy"-object as object. |
||
2639 | * |
||
2640 | * @return \stdClass |
||
2641 | */ |
||
2642 | 4 | public function getObject(): \stdClass |
|
2646 | |||
2647 | /** |
||
2648 | * alias: for "Arrayy->randomImmutable()" |
||
2649 | * |
||
2650 | * @return static |
||
2651 | * <p>(Immutable)</p> |
||
2652 | * |
||
2653 | * @see Arrayy::randomImmutable() |
||
2654 | * |
||
2655 | * @psalm-return static<int|array-key,T> |
||
2656 | */ |
||
2657 | 4 | public function getRandom(): self |
|
2661 | |||
2662 | /** |
||
2663 | * alias: for "Arrayy->randomKey()" |
||
2664 | * |
||
2665 | * @return mixed |
||
2666 | * <p>Get a key/index or null if there wasn't a key/index.</p> |
||
2667 | * |
||
2668 | * @see Arrayy::randomKey() |
||
2669 | */ |
||
2670 | 3 | public function getRandomKey() |
|
2674 | |||
2675 | /** |
||
2676 | * alias: for "Arrayy->randomKeys()" |
||
2677 | * |
||
2678 | * @param int $number |
||
2679 | * |
||
2680 | * @return static |
||
2681 | * <p>(Immutable)</p> |
||
2682 | * |
||
2683 | * @see Arrayy::randomKeys() |
||
2684 | * |
||
2685 | * @psalm-return static<TKey,T> |
||
2686 | */ |
||
2687 | 8 | public function getRandomKeys(int $number): self |
|
2691 | |||
2692 | /** |
||
2693 | * alias: for "Arrayy->randomValue()" |
||
2694 | * |
||
2695 | * @return mixed |
||
2696 | * <p>Get a random value or null if there wasn't a value.</p> |
||
2697 | * |
||
2698 | * @see Arrayy::randomValue() |
||
2699 | */ |
||
2700 | 3 | public function getRandomValue() |
|
2704 | |||
2705 | /** |
||
2706 | * alias: for "Arrayy->randomValues()" |
||
2707 | * |
||
2708 | * @param int $number |
||
2709 | * |
||
2710 | * @return static |
||
2711 | * <p>(Immutable)</p> |
||
2712 | * |
||
2713 | * @see Arrayy::randomValues() |
||
2714 | * |
||
2715 | * @psalm-return static<TKey,T> |
||
2716 | */ |
||
2717 | 6 | public function getRandomValues(int $number): self |
|
2721 | |||
2722 | /** |
||
2723 | * Gets all values. |
||
2724 | * |
||
2725 | * @return static |
||
2726 | * <p>The values of all elements in this array, in the order they |
||
2727 | * appear in the array.</p> |
||
2728 | * |
||
2729 | * @psalm-return static<TKey,T> |
||
2730 | */ |
||
2731 | 4 | public function getValues() |
|
2741 | |||
2742 | /** |
||
2743 | * Gets all values via Generator. |
||
2744 | * |
||
2745 | * @return \Generator |
||
2746 | * <p>The values of all elements in this array, in the order they |
||
2747 | * appear in the array as Generator.</p> |
||
2748 | * |
||
2749 | * @psalm-return \Generator<TKey,T> |
||
2750 | */ |
||
2751 | 4 | public function getValuesYield(): \Generator |
|
2755 | |||
2756 | /** |
||
2757 | * Group values from a array according to the results of a closure. |
||
2758 | * |
||
2759 | * @param callable|string $grouper <p>A callable function name.</p> |
||
2760 | * @param bool $saveKeys |
||
2761 | * |
||
2762 | * @return static |
||
2763 | * <p>(Immutable)</p> |
||
2764 | * |
||
2765 | * @psalm-return static<TKey,T> |
||
2766 | * @psalm-mutation-free |
||
2767 | */ |
||
2768 | 4 | public function group($grouper, bool $saveKeys = false): self |
|
2809 | |||
2810 | /** |
||
2811 | * Check if an array has a given key. |
||
2812 | * |
||
2813 | * @param mixed $key |
||
2814 | * |
||
2815 | * @return bool |
||
2816 | */ |
||
2817 | 30 | public function has($key): bool |
|
2843 | |||
2844 | /** |
||
2845 | * Check if an array has a given value. |
||
2846 | * |
||
2847 | * INFO: if you need to search recursive please use ```contains()``` |
||
2848 | * |
||
2849 | * @param mixed $value |
||
2850 | * |
||
2851 | * @return bool |
||
2852 | */ |
||
2853 | 1 | public function hasValue($value): bool |
|
2857 | |||
2858 | /** |
||
2859 | * Implodes the values of this array. |
||
2860 | * |
||
2861 | * @param string $glue |
||
2862 | * |
||
2863 | * @return string |
||
2864 | * @psalm-mutation-free |
||
2865 | */ |
||
2866 | 28 | public function implode(string $glue = ''): string |
|
2870 | |||
2871 | /** |
||
2872 | * Implodes the keys of this array. |
||
2873 | * |
||
2874 | * @param string $glue |
||
2875 | * |
||
2876 | * @return string |
||
2877 | * @psalm-mutation-free |
||
2878 | */ |
||
2879 | 8 | public function implodeKeys(string $glue = ''): string |
|
2883 | |||
2884 | /** |
||
2885 | * Given a list and an iterate-function that returns |
||
2886 | * a key for each element in the list (or a property name), |
||
2887 | * returns an object with an index of each item. |
||
2888 | * |
||
2889 | * @param mixed $key |
||
2890 | * |
||
2891 | * @return static |
||
2892 | * <p>(Immutable)</p> |
||
2893 | * |
||
2894 | * @psalm-return static<TKey,T> |
||
2895 | * @psalm-mutation-free |
||
2896 | */ |
||
2897 | 4 | public function indexBy($key): self |
|
2914 | |||
2915 | /** |
||
2916 | * alias: for "Arrayy->searchIndex()" |
||
2917 | * |
||
2918 | * @param mixed $value <p>The value to search for.</p> |
||
2919 | * |
||
2920 | * @return false|mixed |
||
2921 | * |
||
2922 | * @see Arrayy::searchIndex() |
||
2923 | */ |
||
2924 | 4 | public function indexOf($value) |
|
2928 | |||
2929 | /** |
||
2930 | * Get everything but the last..$to items. |
||
2931 | * |
||
2932 | * @param int $to |
||
2933 | * |
||
2934 | * @return static |
||
2935 | * <p>(Immutable)</p> |
||
2936 | * |
||
2937 | * @psalm-return static<TKey,T> |
||
2938 | * @psalm-mutation-free |
||
2939 | */ |
||
2940 | 12 | public function initial(int $to = 1): self |
|
2944 | |||
2945 | /** |
||
2946 | * Return an array with all elements found in input array. |
||
2947 | * |
||
2948 | * @param array $search |
||
2949 | * @param bool $keepKeys |
||
2950 | * |
||
2951 | * @return static |
||
2952 | * <p>(Immutable)</p> |
||
2953 | * |
||
2954 | * @psalm-param array<mixed,mixed>|array<TKey,T> $search |
||
2955 | * @psalm-return static<TKey,T> |
||
2956 | * @psalm-mutation-free |
||
2957 | */ |
||
2958 | 4 | public function intersection(array $search, bool $keepKeys = false): self |
|
2984 | |||
2985 | /** |
||
2986 | * Return an array with all elements found in input array. |
||
2987 | * |
||
2988 | * @param array ...$array |
||
2989 | * |
||
2990 | * @return static |
||
2991 | * <p>(Immutable)</p> |
||
2992 | * |
||
2993 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
2994 | * @psalm-return static<TKey,T> |
||
2995 | * @psalm-mutation-free |
||
2996 | */ |
||
2997 | 1 | public function intersectionMulti(...$array): self |
|
3005 | |||
3006 | /** |
||
3007 | * Return a boolean flag which indicates whether the two input arrays have any common elements. |
||
3008 | * |
||
3009 | * @param array $search |
||
3010 | * |
||
3011 | * @return bool |
||
3012 | * |
||
3013 | * @psalm-param array<mixed,mixed>|array<TKey,T> $search |
||
3014 | */ |
||
3015 | 1 | public function intersects(array $search): bool |
|
3019 | |||
3020 | /** |
||
3021 | * Invoke a function on all of an array's values. |
||
3022 | * |
||
3023 | * @param callable $callable |
||
3024 | * @param mixed $arguments |
||
3025 | * |
||
3026 | * @return static |
||
3027 | * <p>(Immutable)</p> |
||
3028 | * |
||
3029 | * @psalm-param callable(T=,mixed):mixed $callable |
||
3030 | * @psalm-return static<TKey,T> |
||
3031 | * @psalm-mutation-free |
||
3032 | */ |
||
3033 | 1 | View Code Duplication | public function invoke($callable, $arguments = []): self |
3057 | |||
3058 | /** |
||
3059 | * Check whether array is associative or not. |
||
3060 | * |
||
3061 | * @param bool $recursive |
||
3062 | * |
||
3063 | * @return bool |
||
3064 | * <p>Returns true if associative, false otherwise.</p> |
||
3065 | */ |
||
3066 | 15 | View Code Duplication | public function isAssoc(bool $recursive = false): bool |
3080 | |||
3081 | /** |
||
3082 | * Check if a given key or keys are empty. |
||
3083 | * |
||
3084 | * @param int|int[]|string|string[]|null $keys |
||
3085 | * |
||
3086 | * @return bool |
||
3087 | * <p>Returns true if empty, false otherwise.</p> |
||
3088 | * @psalm-mutation-free |
||
3089 | */ |
||
3090 | 45 | public function isEmpty($keys = null): bool |
|
3108 | |||
3109 | /** |
||
3110 | * Check if the current array is equal to the given "$array" or not. |
||
3111 | * |
||
3112 | * @param array $array |
||
3113 | * |
||
3114 | * @return bool |
||
3115 | * |
||
3116 | * @psalm-param array<mixed,mixed> $array |
||
3117 | */ |
||
3118 | 1 | public function isEqual(array $array): bool |
|
3122 | |||
3123 | /** |
||
3124 | * Check if the current array is a multi-array. |
||
3125 | * |
||
3126 | * @return bool |
||
3127 | */ |
||
3128 | 22 | public function isMultiArray(): bool |
|
3136 | |||
3137 | /** |
||
3138 | * Check whether array is numeric or not. |
||
3139 | * |
||
3140 | * @return bool |
||
3141 | * <p>Returns true if numeric, false otherwise.</p> |
||
3142 | */ |
||
3143 | 5 | View Code Duplication | public function isNumeric(): bool |
3157 | |||
3158 | /** |
||
3159 | * Check if the current array is sequential [0, 1, 2, 3, 4, 5 ...] or not. |
||
3160 | * |
||
3161 | * @param bool $recursive |
||
3162 | * |
||
3163 | * @return bool |
||
3164 | * @psalm-mutation-free |
||
3165 | */ |
||
3166 | 9 | public function isSequential(bool $recursive = false): bool |
|
3183 | |||
3184 | /** |
||
3185 | * @return array |
||
3186 | * |
||
3187 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
3188 | */ |
||
3189 | 1 | public function jsonSerialize(): array |
|
3193 | |||
3194 | /** |
||
3195 | * Gets the key/index of the element at the current internal iterator position. |
||
3196 | * |
||
3197 | * @return int|string|null |
||
3198 | */ |
||
3199 | public function key() |
||
3203 | |||
3204 | /** |
||
3205 | * Checks if the given key exists in the provided array. |
||
3206 | * |
||
3207 | * INFO: This method only use "array_key_exists()" if you want to use "dot"-notation, |
||
3208 | * then you need to use "Arrayy->offsetExists()". |
||
3209 | * |
||
3210 | * @param int|string $key the key to look for |
||
3211 | * |
||
3212 | * @return bool |
||
3213 | * @psalm-mutation-free |
||
3214 | */ |
||
3215 | 142 | public function keyExists($key): bool |
|
3219 | |||
3220 | /** |
||
3221 | * Get all keys from the current array. |
||
3222 | * |
||
3223 | * @param bool $recursive [optional] <p> |
||
3224 | * Get all keys, also from all sub-arrays from an multi-dimensional array. |
||
3225 | * </p> |
||
3226 | * @param mixed|null $search_values [optional] <p> |
||
3227 | * If specified, then only keys containing these values are returned. |
||
3228 | * </p> |
||
3229 | * @param bool $strict [optional] <p> |
||
3230 | * Determines if strict comparison (===) should be used during the search. |
||
3231 | * </p> |
||
3232 | * |
||
3233 | * @return static |
||
3234 | * <p>(Immutable) An array of all the keys in input.</p> |
||
3235 | * |
||
3236 | * @psalm-return static<array-key,TKey> |
||
3237 | * @psalm-mutation-free |
||
3238 | */ |
||
3239 | 29 | public function keys( |
|
3309 | |||
3310 | /** |
||
3311 | * Sort an array by key in reverse order. |
||
3312 | * |
||
3313 | * @param int $sort_flags [optional] <p> |
||
3314 | * You may modify the behavior of the sort using the optional |
||
3315 | * parameter sort_flags, for details |
||
3316 | * see sort. |
||
3317 | * </p> |
||
3318 | * |
||
3319 | * @return $this |
||
3320 | * <p>(Mutable) Return this Arrayy object.</p> |
||
3321 | * |
||
3322 | * @psalm-return static<TKey,T> |
||
3323 | */ |
||
3324 | 4 | public function krsort(int $sort_flags = 0): self |
|
3332 | |||
3333 | /** |
||
3334 | * Sort an array by key in reverse order. |
||
3335 | * |
||
3336 | * @param int $sort_flags [optional] <p> |
||
3337 | * You may modify the behavior of the sort using the optional |
||
3338 | * parameter sort_flags, for details |
||
3339 | * see sort. |
||
3340 | * </p> |
||
3341 | * |
||
3342 | * @return $this |
||
3343 | * <p>(Immutable) Return this Arrayy object.</p> |
||
3344 | * |
||
3345 | * @psalm-return static<TKey,T> |
||
3346 | * @psalm-mutation-free |
||
3347 | */ |
||
3348 | 4 | public function krsortImmutable(int $sort_flags = 0): self |
|
3359 | |||
3360 | /** |
||
3361 | * Get the last value from the current array. |
||
3362 | * |
||
3363 | * @return mixed|null |
||
3364 | * <p>Return null if there wasn't a element.</p> |
||
3365 | * @psalm-mutation-free |
||
3366 | */ |
||
3367 | 17 | public function last() |
|
3376 | |||
3377 | /** |
||
3378 | * Get the last key from the current array. |
||
3379 | * |
||
3380 | * @return mixed|null |
||
3381 | * <p>Return null if there wasn't a element.</p> |
||
3382 | * @psalm-mutation-free |
||
3383 | */ |
||
3384 | 21 | public function lastKey() |
|
3390 | |||
3391 | /** |
||
3392 | * Get the last value(s) from the current array. |
||
3393 | * |
||
3394 | * @param int|null $number |
||
3395 | * |
||
3396 | * @return static |
||
3397 | * <p>(Immutable)</p> |
||
3398 | * |
||
3399 | * @psalm-return static<TKey,T> |
||
3400 | * @psalm-mutation-free |
||
3401 | */ |
||
3402 | 13 | public function lastsImmutable(int $number = null): self |
|
3433 | |||
3434 | /** |
||
3435 | * Get the last value(s) from the current array. |
||
3436 | * |
||
3437 | * @param int|null $number |
||
3438 | * |
||
3439 | * @return $this |
||
3440 | * <p>(Mutable)</p> |
||
3441 | * |
||
3442 | * @psalm-return static<TKey,T> |
||
3443 | */ |
||
3444 | 13 | public function lastsMutable(int $number = null): self |
|
3473 | |||
3474 | /** |
||
3475 | * Count the values from the current array. |
||
3476 | * |
||
3477 | * alias: for "Arrayy->count()" |
||
3478 | * |
||
3479 | * @param int $mode |
||
3480 | * |
||
3481 | * @return int |
||
3482 | * |
||
3483 | * @see Arrayy::count() |
||
3484 | */ |
||
3485 | 20 | public function length(int $mode = \COUNT_NORMAL): int |
|
3489 | |||
3490 | /** |
||
3491 | * Apply the given function to the every element of the array, |
||
3492 | * collecting the results. |
||
3493 | * |
||
3494 | * @param callable $callable |
||
3495 | * @param bool $useKeyAsSecondParameter |
||
3496 | * @param mixed ...$arguments |
||
3497 | * |
||
3498 | * @return static |
||
3499 | * <p>(Immutable) Arrayy object with modified elements.</p> |
||
3500 | * |
||
3501 | * @psalm-param callable(T,TKey=,mixed=):mixed $callable |
||
3502 | * @psalm-return static<TKey,T> |
||
3503 | * @psalm-mutation-free |
||
3504 | */ |
||
3505 | 5 | public function map( |
|
3538 | |||
3539 | /** |
||
3540 | * Check if all items in current array match a truth test. |
||
3541 | * |
||
3542 | * @param \Closure $closure |
||
3543 | * |
||
3544 | * @return bool |
||
3545 | */ |
||
3546 | 15 | View Code Duplication | public function matches(\Closure $closure): bool |
3562 | |||
3563 | /** |
||
3564 | * Check if any item in the current array matches a truth test. |
||
3565 | * |
||
3566 | * @param \Closure $closure |
||
3567 | * |
||
3568 | * @return bool |
||
3569 | */ |
||
3570 | 14 | View Code Duplication | public function matchesAny(\Closure $closure): bool |
3586 | |||
3587 | /** |
||
3588 | * Get the max value from an array. |
||
3589 | * |
||
3590 | * @return false|mixed |
||
3591 | * <p>Will return false if there are no values.</p> |
||
3592 | */ |
||
3593 | 10 | View Code Duplication | public function max() |
3612 | |||
3613 | /** |
||
3614 | * Merge the new $array into the current array. |
||
3615 | * |
||
3616 | * - keep key,value from the current array, also if the index is in the new $array |
||
3617 | * |
||
3618 | * @param array $array |
||
3619 | * @param bool $recursive |
||
3620 | * |
||
3621 | * @return static |
||
3622 | * <p>(Immutable)</p> |
||
3623 | * |
||
3624 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3625 | * @psalm-return static<int|TKey,T> |
||
3626 | * @psalm-mutation-free |
||
3627 | */ |
||
3628 | 32 | View Code Duplication | public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self |
3643 | |||
3644 | /** |
||
3645 | * Merge the new $array into the current array. |
||
3646 | * |
||
3647 | * - replace duplicate assoc-keys from the current array with the key,values from the new $array |
||
3648 | * - create new indexes |
||
3649 | * |
||
3650 | * @param array $array |
||
3651 | * @param bool $recursive |
||
3652 | * |
||
3653 | * @return static |
||
3654 | * <p>(Immutable)</p> |
||
3655 | * |
||
3656 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3657 | * @psalm-return static<TKey,T> |
||
3658 | * @psalm-mutation-free |
||
3659 | */ |
||
3660 | 19 | View Code Duplication | public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self |
3675 | |||
3676 | /** |
||
3677 | * Merge the the current array into the $array. |
||
3678 | * |
||
3679 | * - use key,value from the new $array, also if the index is in the current array |
||
3680 | * |
||
3681 | * @param array $array |
||
3682 | * @param bool $recursive |
||
3683 | * |
||
3684 | * @return static |
||
3685 | * <p>(Immutable)</p> |
||
3686 | * |
||
3687 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3688 | * @psalm-return static<TKey,T> |
||
3689 | * @psalm-mutation-free |
||
3690 | */ |
||
3691 | 16 | View Code Duplication | public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self |
3706 | |||
3707 | /** |
||
3708 | * Merge the current array into the new $array. |
||
3709 | * |
||
3710 | * - replace duplicate assoc-keys from new $array with the key,values from the current array |
||
3711 | * - create new indexes |
||
3712 | * |
||
3713 | * @param array $array |
||
3714 | * @param bool $recursive |
||
3715 | * |
||
3716 | * @return static |
||
3717 | * <p>(Immutable)</p> |
||
3718 | * |
||
3719 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3720 | * @psalm-return static<TKey,T> |
||
3721 | * @psalm-mutation-free |
||
3722 | */ |
||
3723 | 20 | View Code Duplication | public function mergePrependNewIndex(array $array = [], bool $recursive = false): self |
3738 | |||
3739 | /** |
||
3740 | * @return ArrayyMeta|static |
||
3741 | */ |
||
3742 | 15 | public static function meta() |
|
3746 | |||
3747 | /** |
||
3748 | * Get the min value from an array. |
||
3749 | * |
||
3750 | * @return false|mixed |
||
3751 | * <p>Will return false if there are no values.</p> |
||
3752 | */ |
||
3753 | 10 | View Code Duplication | public function min() |
3772 | |||
3773 | /** |
||
3774 | * Get the most used value from the array. |
||
3775 | * |
||
3776 | * @return mixed|null |
||
3777 | * <p>(Immutable) Return null if there wasn't a element.</p> |
||
3778 | * @psalm-mutation-free |
||
3779 | */ |
||
3780 | 3 | public function mostUsedValue() |
|
3784 | |||
3785 | /** |
||
3786 | * Get the most used value from the array. |
||
3787 | * |
||
3788 | * @param int|null $number <p>How many values you will take?</p> |
||
3789 | * |
||
3790 | * @return static |
||
3791 | * <p>(Immutable)</p> |
||
3792 | * |
||
3793 | * @psalm-return static<TKey,T> |
||
3794 | * @psalm-mutation-free |
||
3795 | */ |
||
3796 | 3 | public function mostUsedValues(int $number = null): self |
|
3800 | |||
3801 | /** |
||
3802 | * Move an array element to a new index. |
||
3803 | * |
||
3804 | * cherry-picked from: http://stackoverflow.com/questions/12624153/move-an-array-element-to-a-new-index-in-php |
||
3805 | * |
||
3806 | * @param int|string $from |
||
3807 | * @param int $to |
||
3808 | * |
||
3809 | * @return static |
||
3810 | * <p>(Immutable)</p> |
||
3811 | * |
||
3812 | * @psalm-return static<TKey,T> |
||
3813 | * @psalm-mutation-free |
||
3814 | */ |
||
3815 | 1 | public function moveElement($from, $to): self |
|
3848 | |||
3849 | /** |
||
3850 | * Move an array element to the first place. |
||
3851 | * |
||
3852 | * INFO: Instead of "Arrayy->moveElement()" this method will NOT |
||
3853 | * loss the keys of an indexed array. |
||
3854 | * |
||
3855 | * @param int|string $key |
||
3856 | * |
||
3857 | * @return static |
||
3858 | * <p>(Immutable)</p> |
||
3859 | * |
||
3860 | * @psalm-return static<TKey,T> |
||
3861 | * @psalm-mutation-free |
||
3862 | */ |
||
3863 | 1 | View Code Duplication | public function moveElementToFirstPlace($key): self |
3879 | |||
3880 | /** |
||
3881 | * Move an array element to the last place. |
||
3882 | * |
||
3883 | * INFO: Instead of "Arrayy->moveElement()" this method will NOT |
||
3884 | * loss the keys of an indexed array. |
||
3885 | * |
||
3886 | * @param int|string $key |
||
3887 | * |
||
3888 | * @return static |
||
3889 | * <p>(Immutable)</p> |
||
3890 | * |
||
3891 | * @psalm-return static<TKey,T> |
||
3892 | * @psalm-mutation-free |
||
3893 | */ |
||
3894 | 1 | View Code Duplication | public function moveElementToLastPlace($key): self |
3910 | |||
3911 | /** |
||
3912 | * Moves the internal iterator position to the next element and returns this element. |
||
3913 | * |
||
3914 | * @return false|mixed |
||
3915 | * <p>(Mutable) Will return false if there are no values.</p> |
||
3916 | */ |
||
3917 | public function next() |
||
3921 | |||
3922 | /** |
||
3923 | * Get the next nth keys and values from the array. |
||
3924 | * |
||
3925 | * @param int $step |
||
3926 | * @param int $offset |
||
3927 | * |
||
3928 | * @return static |
||
3929 | * <p>(Immutable)</p> |
||
3930 | * |
||
3931 | * @psalm-return static<TKey,T> |
||
3932 | * @psalm-mutation-free |
||
3933 | */ |
||
3934 | 1 | public function nth(int $step, int $offset = 0): self |
|
3953 | |||
3954 | /** |
||
3955 | * Get a subset of the items from the given array. |
||
3956 | * |
||
3957 | * @param mixed[] $keys |
||
3958 | * |
||
3959 | * @return static |
||
3960 | * <p>(Immutable)</p> |
||
3961 | * |
||
3962 | * @psalm-return static<TKey,T> |
||
3963 | * @psalm-mutation-free |
||
3964 | */ |
||
3965 | 1 | public function only(array $keys): self |
|
3975 | |||
3976 | /** |
||
3977 | * Pad array to the specified size with a given value. |
||
3978 | * |
||
3979 | * @param int $size <p>Size of the result array.</p> |
||
3980 | * @param mixed $value <p>Empty value by default.</p> |
||
3981 | * |
||
3982 | * @return static |
||
3983 | * <p>(Immutable) Arrayy object padded to $size with $value.</p> |
||
3984 | * |
||
3985 | * @psalm-return static<TKey,T> |
||
3986 | * @psalm-mutation-free |
||
3987 | */ |
||
3988 | 5 | public function pad(int $size, $value): self |
|
3996 | |||
3997 | /** |
||
3998 | * Partitions this array in two array according to a predicate. |
||
3999 | * Keys are preserved in the resulting array. |
||
4000 | * |
||
4001 | * @param \Closure $closure |
||
4002 | * <p>The predicate on which to partition.</p> |
||
4003 | * |
||
4004 | * @return array<int, static> |
||
4005 | * <p>An array with two elements. The first element contains the array |
||
4006 | * of elements where the predicate returned TRUE, the second element |
||
4007 | * contains the array of elements where the predicate returned FALSE.</p> |
||
4008 | * |
||
4009 | * @psalm-return array<int, static<TKey,T>> |
||
4010 | */ |
||
4011 | 1 | public function partition(\Closure $closure): array |
|
4027 | |||
4028 | /** |
||
4029 | * Pop a specified value off the end of the current array. |
||
4030 | * |
||
4031 | * @return mixed|null |
||
4032 | * <p>(Mutable) The popped element from the current array or null if the array is e.g. empty.</p> |
||
4033 | */ |
||
4034 | 5 | public function pop() |
|
4040 | |||
4041 | /** |
||
4042 | * Prepend a (key) + value to the current array. |
||
4043 | * |
||
4044 | * @param mixed $value |
||
4045 | * @param mixed $key |
||
4046 | * |
||
4047 | * @return $this |
||
4048 | * <p>(Mutable) Return this Arrayy object, with the prepended value.</p> |
||
4049 | * |
||
4050 | * @psalm-return static<TKey,T> |
||
4051 | */ |
||
4052 | 11 | public function prepend($value, $key = null) |
|
4068 | |||
4069 | /** |
||
4070 | * Add a suffix to each key. |
||
4071 | * |
||
4072 | * @param mixed $suffix |
||
4073 | * |
||
4074 | * @return static |
||
4075 | * <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> |
||
4076 | * |
||
4077 | * @psalm-return static<TKey,T> |
||
4078 | * @psalm-mutation-free |
||
4079 | */ |
||
4080 | 10 | View Code Duplication | public function prependToEachKey($suffix): self |
4106 | |||
4107 | /** |
||
4108 | * Add a suffix to each value. |
||
4109 | * |
||
4110 | * @param mixed $suffix |
||
4111 | * |
||
4112 | * @return static |
||
4113 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
||
4114 | * |
||
4115 | * @psalm-return static<TKey,T> |
||
4116 | * @psalm-mutation-free |
||
4117 | */ |
||
4118 | 10 | View Code Duplication | public function prependToEachValue($suffix): self |
4146 | |||
4147 | /** |
||
4148 | * Return the value of a given key and |
||
4149 | * delete the key. |
||
4150 | * |
||
4151 | * @param int|int[]|string|string[]|null $keyOrKeys |
||
4152 | * @param mixed $fallback |
||
4153 | * |
||
4154 | * @return mixed |
||
4155 | */ |
||
4156 | 5 | public function pull($keyOrKeys = null, $fallback = null) |
|
4178 | |||
4179 | /** |
||
4180 | * Push one or more values onto the end of array at once. |
||
4181 | * |
||
4182 | * @param array ...$args |
||
4183 | * |
||
4184 | * @return $this |
||
4185 | * <p>(Mutable) Return this Arrayy object, with pushed elements to the end of array.</p> |
||
4186 | * |
||
4187 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
4188 | * |
||
4189 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$args |
||
4190 | * @psalm-return static<TKey,T> |
||
4191 | */ |
||
4192 | 7 | public function push(...$args) |
|
4210 | |||
4211 | /** |
||
4212 | * Get a random value from the current array. |
||
4213 | * |
||
4214 | * @param int|null $number <p>How many values you will take?</p> |
||
4215 | * |
||
4216 | * @return static |
||
4217 | * <p>(Immutable)</p> |
||
4218 | * |
||
4219 | * @psalm-return static<int|array-key,T> |
||
4220 | */ |
||
4221 | 19 | public function randomImmutable(int $number = null): self |
|
4254 | |||
4255 | /** |
||
4256 | * Pick a random key/index from the keys of this array. |
||
4257 | * |
||
4258 | * @throws \RangeException If array is empty |
||
4259 | * |
||
4260 | * @return mixed |
||
4261 | * <p>Get a key/index or null if there wasn't a key/index.</p> |
||
4262 | */ |
||
4263 | 4 | public function randomKey() |
|
4273 | |||
4274 | /** |
||
4275 | * Pick a given number of random keys/indexes out of this array. |
||
4276 | * |
||
4277 | * @param int $number <p>The number of keys/indexes (should be <= \count($this->array))</p> |
||
4278 | * |
||
4279 | * @throws \RangeException If array is empty |
||
4280 | * |
||
4281 | * @return static |
||
4282 | * <p>(Immutable)</p> |
||
4283 | * |
||
4284 | * @psalm-return static<TKey,T> |
||
4285 | */ |
||
4286 | 13 | public function randomKeys(int $number): self |
|
4314 | |||
4315 | /** |
||
4316 | * Get a random value from the current array. |
||
4317 | * |
||
4318 | * @param int|null $number <p>How many values you will take?</p> |
||
4319 | * |
||
4320 | * @return $this |
||
4321 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4322 | * |
||
4323 | * @psalm-return static<TKey,T> |
||
4324 | */ |
||
4325 | 17 | public function randomMutable(int $number = null): self |
|
4350 | |||
4351 | /** |
||
4352 | * Pick a random value from the values of this array. |
||
4353 | * |
||
4354 | * @return mixed |
||
4355 | * <p>Get a random value or null if there wasn't a value.</p> |
||
4356 | */ |
||
4357 | 4 | public function randomValue() |
|
4367 | |||
4368 | /** |
||
4369 | * Pick a given number of random values out of this array. |
||
4370 | * |
||
4371 | * @param int $number |
||
4372 | * |
||
4373 | * @return static |
||
4374 | * <p>(Mutable)</p> |
||
4375 | * |
||
4376 | * @psalm-return static<TKey,T> |
||
4377 | */ |
||
4378 | 7 | public function randomValues(int $number): self |
|
4382 | |||
4383 | /** |
||
4384 | * Get a random value from an array, with the ability to skew the results. |
||
4385 | * |
||
4386 | * Example: randomWeighted(['foo' => 1, 'bar' => 2]) has a 66% chance of returning bar. |
||
4387 | * |
||
4388 | * @param array $array |
||
4389 | * @param int|null $number <p>How many values you will take?</p> |
||
4390 | * |
||
4391 | * @return static<int,mixed> |
||
4392 | * <p>(Immutable)</p> |
||
4393 | * |
||
4394 | * @psalm-param array<mixed,mixed> $array |
||
4395 | * @psalm-return static<int|array-key,T> |
||
4396 | */ |
||
4397 | 9 | public function randomWeighted(array $array, int $number = null): self |
|
4412 | |||
4413 | /** |
||
4414 | * Reduce the current array via callable e.g. anonymous-function. |
||
4415 | * |
||
4416 | * @param callable $callable |
||
4417 | * @param mixed $init |
||
4418 | * |
||
4419 | * @return static |
||
4420 | * <p>(Immutable)</p> |
||
4421 | * |
||
4422 | * @psalm-return static<TKey,T> |
||
4423 | * @psalm-mutation-free |
||
4424 | */ |
||
4425 | 18 | public function reduce($callable, $init = []): self |
|
4455 | |||
4456 | /** |
||
4457 | * @param bool $unique |
||
4458 | * |
||
4459 | * @return static |
||
4460 | * <p>(Immutable)</p> |
||
4461 | * |
||
4462 | * @psalm-return static<TKey,T> |
||
4463 | * @psalm-mutation-free |
||
4464 | */ |
||
4465 | 14 | public function reduce_dimension(bool $unique = true): self |
|
4488 | |||
4489 | /** |
||
4490 | * Create a numerically re-indexed Arrayy object. |
||
4491 | * |
||
4492 | * @return $this |
||
4493 | * <p>(Mutable) Return this Arrayy object, with re-indexed array-elements.</p> |
||
4494 | * |
||
4495 | * @psalm-return static<TKey,T> |
||
4496 | */ |
||
4497 | 9 | public function reindex(): self |
|
4505 | |||
4506 | /** |
||
4507 | * Return all items that fail the truth test. |
||
4508 | * |
||
4509 | * @param \Closure $closure |
||
4510 | * |
||
4511 | * @return static |
||
4512 | * <p>(Immutable)</p> |
||
4513 | * |
||
4514 | * @psalm-return static<TKey,T> |
||
4515 | * @psalm-mutation-free |
||
4516 | */ |
||
4517 | 1 | View Code Duplication | public function reject(\Closure $closure): self |
4534 | |||
4535 | /** |
||
4536 | * Remove a value from the current array (optional using dot-notation). |
||
4537 | * |
||
4538 | * @param mixed $key |
||
4539 | * |
||
4540 | * @return static |
||
4541 | * <p>(Mutable)</p> |
||
4542 | * |
||
4543 | * @psalm-param TKey $key |
||
4544 | * @psalm-return static<TKey,T> |
||
4545 | */ |
||
4546 | 21 | public function remove($key) |
|
4569 | |||
4570 | /** |
||
4571 | * alias: for "Arrayy->removeValue()" |
||
4572 | * |
||
4573 | * @param mixed $element |
||
4574 | * |
||
4575 | * @return static |
||
4576 | * <p>(Immutable)</p> |
||
4577 | * |
||
4578 | * @psalm-param T $element |
||
4579 | * @psalm-return static<TKey,T> |
||
4580 | * @psalm-mutation-free |
||
4581 | */ |
||
4582 | 8 | public function removeElement($element) |
|
4586 | |||
4587 | /** |
||
4588 | * Remove the first value from the current array. |
||
4589 | * |
||
4590 | * @return static |
||
4591 | * <p>(Immutable)</p> |
||
4592 | * |
||
4593 | * @psalm-return static<TKey,T> |
||
4594 | * @psalm-mutation-free |
||
4595 | */ |
||
4596 | 7 | View Code Duplication | public function removeFirst(): self |
4608 | |||
4609 | /** |
||
4610 | * Remove the last value from the current array. |
||
4611 | * |
||
4612 | * @return static |
||
4613 | * <p>(Immutable)</p> |
||
4614 | * |
||
4615 | * @psalm-return static<TKey,T> |
||
4616 | * @psalm-mutation-free |
||
4617 | */ |
||
4618 | 7 | View Code Duplication | public function removeLast(): self |
4630 | |||
4631 | /** |
||
4632 | * Removes a particular value from an array (numeric or associative). |
||
4633 | * |
||
4634 | * @param mixed $value |
||
4635 | * |
||
4636 | * @return static |
||
4637 | * <p>(Immutable)</p> |
||
4638 | * |
||
4639 | * @psalm-param T $value |
||
4640 | * @psalm-return static<TKey,T> |
||
4641 | * @psalm-mutation-free |
||
4642 | */ |
||
4643 | 8 | public function removeValue($value): self |
|
4666 | |||
4667 | /** |
||
4668 | * Generate array of repeated arrays. |
||
4669 | * |
||
4670 | * @param int $times <p>How many times has to be repeated.</p> |
||
4671 | * |
||
4672 | * @return static |
||
4673 | * <p>(Immutable)</p> |
||
4674 | * |
||
4675 | * @psalm-return static<TKey,T> |
||
4676 | * @psalm-mutation-free |
||
4677 | */ |
||
4678 | 1 | public function repeat($times): self |
|
4690 | |||
4691 | /** |
||
4692 | * Replace a key with a new key/value pair. |
||
4693 | * |
||
4694 | * @param mixed $oldKey |
||
4695 | * @param mixed $newKey |
||
4696 | * @param mixed $newValue |
||
4697 | * |
||
4698 | * @return static |
||
4699 | * <p>(Immutable)</p> |
||
4700 | * |
||
4701 | * @psalm-return static<TKey,T> |
||
4702 | * @psalm-mutation-free |
||
4703 | */ |
||
4704 | 5 | public function replace($oldKey, $newKey, $newValue): self |
|
4714 | |||
4715 | /** |
||
4716 | * Create an array using the current array as values and the other array as keys. |
||
4717 | * |
||
4718 | * @param array $keys <p>An array of keys.</p> |
||
4719 | * |
||
4720 | * @return static |
||
4721 | * <p>(Immutable) Arrayy object with keys from the other array.</p> |
||
4722 | * |
||
4723 | * @psalm-param array<mixed,mixed>|array<mixed,TKey> $keys |
||
4724 | * @psalm-return static<TKey,T> |
||
4725 | * @psalm-mutation-free |
||
4726 | */ |
||
4727 | 2 | public function replaceAllKeys(array $keys): self |
|
4735 | |||
4736 | /** |
||
4737 | * Create an array using the current array as keys and the other array as values. |
||
4738 | * |
||
4739 | * @param array $array <p>An array o values.</p> |
||
4740 | * |
||
4741 | * @return static |
||
4742 | * <p>(Immutable) Arrayy object with values from the other array.</p> |
||
4743 | * |
||
4744 | * @psalm-param array<mixed,T> $array |
||
4745 | * @psalm-return static<TKey,T> |
||
4746 | * @psalm-mutation-free |
||
4747 | */ |
||
4748 | 2 | public function replaceAllValues(array $array): self |
|
4756 | |||
4757 | /** |
||
4758 | * Replace the keys in an array with another set. |
||
4759 | * |
||
4760 | * @param array $keys <p>An array of keys matching the array's size</p> |
||
4761 | * |
||
4762 | * @return static |
||
4763 | * <p>(Immutable)</p> |
||
4764 | * |
||
4765 | * @psalm-param array<mixed,mixed>|array<mixed,TKey> $keys |
||
4766 | * @psalm-return static<TKey,T> |
||
4767 | * @psalm-mutation-free |
||
4768 | */ |
||
4769 | 1 | public function replaceKeys(array $keys): self |
|
4780 | |||
4781 | /** |
||
4782 | * Replace the first matched value in an array. |
||
4783 | * |
||
4784 | * @param mixed $search <p>The value to replace.</p> |
||
4785 | * @param mixed $replacement <p>The value to replace.</p> |
||
4786 | * |
||
4787 | * @return static |
||
4788 | * <p>(Immutable)</p> |
||
4789 | * |
||
4790 | * @psalm-return static<TKey,T> |
||
4791 | * @psalm-mutation-free |
||
4792 | */ |
||
4793 | 3 | public function replaceOneValue($search, $replacement = ''): self |
|
4808 | |||
4809 | /** |
||
4810 | * Replace values in the current array. |
||
4811 | * |
||
4812 | * @param mixed $search <p>The value to replace.</p> |
||
4813 | * @param mixed $replacement <p>What to replace it with.</p> |
||
4814 | * |
||
4815 | * @return static |
||
4816 | * <p>(Immutable)</p> |
||
4817 | * |
||
4818 | * @psalm-return static<TKey,T> |
||
4819 | * @psalm-mutation-free |
||
4820 | */ |
||
4821 | 1 | public function replaceValues($search, $replacement = ''): self |
|
4833 | |||
4834 | /** |
||
4835 | * Get the last elements from index $from until the end of this array. |
||
4836 | * |
||
4837 | * @param int $from |
||
4838 | * |
||
4839 | * @return static |
||
4840 | * <p>(Immutable)</p> |
||
4841 | * |
||
4842 | * @psalm-return static<TKey,T> |
||
4843 | * @psalm-mutation-free |
||
4844 | */ |
||
4845 | 15 | View Code Duplication | public function rest(int $from = 1): self |
4855 | |||
4856 | /** |
||
4857 | * Return the array in the reverse order. |
||
4858 | * |
||
4859 | * @return $this |
||
4860 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4861 | * |
||
4862 | * @psalm-return static<TKey,T> |
||
4863 | */ |
||
4864 | 9 | public function reverse(): self |
|
4872 | |||
4873 | /** |
||
4874 | * Sort an array in reverse order. |
||
4875 | * |
||
4876 | * @param int $sort_flags [optional] <p> |
||
4877 | * You may modify the behavior of the sort using the optional |
||
4878 | * parameter sort_flags, for details |
||
4879 | * see sort. |
||
4880 | * </p> |
||
4881 | * |
||
4882 | * @return $this |
||
4883 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4884 | * |
||
4885 | * @psalm-return static<TKey,T> |
||
4886 | */ |
||
4887 | 4 | public function rsort(int $sort_flags = 0): self |
|
4895 | |||
4896 | /** |
||
4897 | * Sort an array in reverse order. |
||
4898 | * |
||
4899 | * @param int $sort_flags [optional] <p> |
||
4900 | * You may modify the behavior of the sort using the optional |
||
4901 | * parameter sort_flags, for details |
||
4902 | * see sort. |
||
4903 | * </p> |
||
4904 | * |
||
4905 | * @return $this |
||
4906 | * <p>(Immutable) Return this Arrayy object.</p> |
||
4907 | * |
||
4908 | * @psalm-return static<TKey,T> |
||
4909 | * @psalm-mutation-free |
||
4910 | */ |
||
4911 | 4 | public function rsortImmutable(int $sort_flags = 0): self |
|
4922 | |||
4923 | /** |
||
4924 | * Search for the first index of the current array via $value. |
||
4925 | * |
||
4926 | * @param mixed $value |
||
4927 | * |
||
4928 | * @return false|float|int|string |
||
4929 | * <p>Will return <b>FALSE</b> if the value can't be found.</p> |
||
4930 | * @psalm-mutation-free |
||
4931 | */ |
||
4932 | 21 | public function searchIndex($value) |
|
4942 | |||
4943 | /** |
||
4944 | * Search for the value of the current array via $index. |
||
4945 | * |
||
4946 | * @param mixed $index |
||
4947 | * |
||
4948 | * @return static |
||
4949 | * <p>(Immutable) Will return a empty Arrayy if the value wasn't found.</p> |
||
4950 | * |
||
4951 | * @psalm-return static<TKey,T> |
||
4952 | * @psalm-mutation-free |
||
4953 | */ |
||
4954 | 9 | public function searchValue($index): self |
|
4984 | |||
4985 | /** |
||
4986 | * Set a value for the current array (optional using dot-notation). |
||
4987 | * |
||
4988 | * @param string $key <p>The key to set.</p> |
||
4989 | * @param mixed $value <p>Its value.</p> |
||
4990 | * |
||
4991 | * @return $this |
||
4992 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4993 | * |
||
4994 | * @psalm-param TKey $key |
||
4995 | * @psalm-param T $value |
||
4996 | * @psalm-return static<TKey,T> |
||
4997 | */ |
||
4998 | 28 | public function set($key, $value): self |
|
5004 | |||
5005 | /** |
||
5006 | * Get a value from a array and set it if it was not. |
||
5007 | * |
||
5008 | * WARNING: this method only set the value, if the $key is not already set |
||
5009 | * |
||
5010 | * @param mixed $key <p>The key</p> |
||
5011 | * @param mixed $fallback <p>The default value to set if it isn't.</p> |
||
5012 | * |
||
5013 | * @return mixed |
||
5014 | * <p>(Mutable)</p> |
||
5015 | */ |
||
5016 | 11 | public function setAndGet($key, $fallback = null) |
|
5027 | |||
5028 | /** |
||
5029 | * Shifts a specified value off the beginning of array. |
||
5030 | * |
||
5031 | * @return mixed |
||
5032 | * <p>(Mutable) A shifted element from the current array.</p> |
||
5033 | */ |
||
5034 | 5 | public function shift() |
|
5040 | |||
5041 | /** |
||
5042 | * Shuffle the current array. |
||
5043 | * |
||
5044 | * @param bool $secure <p>using a CSPRNG | @link https://paragonie.com/b/JvICXzh_jhLyt4y3</p> |
||
5045 | * @param array $array [optional] |
||
5046 | * |
||
5047 | * @return static |
||
5048 | * <p>(Immutable)</p> |
||
5049 | * |
||
5050 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
5051 | * @psalm-return static<TKey,T> |
||
5052 | * |
||
5053 | * @noinspection BadExceptionsProcessingInspection |
||
5054 | * @noinspection RandomApiMigrationInspection |
||
5055 | * @noinspection NonSecureShuffleUsageInspection |
||
5056 | */ |
||
5057 | 2 | public function shuffle(bool $secure = false, array $array = null): self |
|
5095 | |||
5096 | /** |
||
5097 | * Count the values from the current array. |
||
5098 | * |
||
5099 | * alias: for "Arrayy->count()" |
||
5100 | * |
||
5101 | * @param int $mode |
||
5102 | * |
||
5103 | * @return int |
||
5104 | */ |
||
5105 | 20 | public function size(int $mode = \COUNT_NORMAL): int |
|
5109 | |||
5110 | /** |
||
5111 | * Checks whether array has exactly $size items. |
||
5112 | * |
||
5113 | * @param int $size |
||
5114 | * |
||
5115 | * @return bool |
||
5116 | */ |
||
5117 | 1 | View Code Duplication | public function sizeIs(int $size): bool |
5131 | |||
5132 | /** |
||
5133 | * Checks whether array has between $fromSize to $toSize items. $toSize can be |
||
5134 | * smaller than $fromSize. |
||
5135 | * |
||
5136 | * @param int $fromSize |
||
5137 | * @param int $toSize |
||
5138 | * |
||
5139 | * @return bool |
||
5140 | */ |
||
5141 | 1 | public function sizeIsBetween(int $fromSize, int $toSize): bool |
|
5161 | |||
5162 | /** |
||
5163 | * Checks whether array has more than $size items. |
||
5164 | * |
||
5165 | * @param int $size |
||
5166 | * |
||
5167 | * @return bool |
||
5168 | */ |
||
5169 | 1 | View Code Duplication | public function sizeIsGreaterThan(int $size): bool |
5183 | |||
5184 | /** |
||
5185 | * Checks whether array has less than $size items. |
||
5186 | * |
||
5187 | * @param int $size |
||
5188 | * |
||
5189 | * @return bool |
||
5190 | */ |
||
5191 | 1 | View Code Duplication | public function sizeIsLessThan(int $size): bool |
5205 | |||
5206 | /** |
||
5207 | * Counts all elements in an array, or something in an object. |
||
5208 | * |
||
5209 | * <p> |
||
5210 | * For objects, if you have SPL installed, you can hook into count() by implementing interface {@see Countable}. |
||
5211 | * The interface has exactly one method, {@see Countable::count()}, which returns the return value for the count() |
||
5212 | * function. Please see the {@see Array} section of the manual for a detailed explanation of how arrays are |
||
5213 | * implemented and used in PHP. |
||
5214 | * </p> |
||
5215 | * |
||
5216 | * @return int |
||
5217 | * <p> |
||
5218 | * The number of elements in var, which is |
||
5219 | * typically an array, since anything else will have one |
||
5220 | * element. |
||
5221 | * </p> |
||
5222 | * <p> |
||
5223 | * If var is not an array or an object with |
||
5224 | * implemented Countable interface, |
||
5225 | * 1 will be returned. |
||
5226 | * There is one exception, if var is &null;, |
||
5227 | * 0 will be returned. |
||
5228 | * </p> |
||
5229 | * <p> |
||
5230 | * Caution: count may return 0 for a variable that isn't set, |
||
5231 | * but it may also return 0 for a variable that has been initialized with an |
||
5232 | * empty array. Use isset to test if a variable is set. |
||
5233 | * </p> |
||
5234 | */ |
||
5235 | 10 | public function sizeRecursive(): int |
|
5239 | |||
5240 | /** |
||
5241 | * Extract a slice of the array. |
||
5242 | * |
||
5243 | * @param int $offset <p>Slice begin index.</p> |
||
5244 | * @param int|null $length <p>Length of the slice.</p> |
||
5245 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
5246 | * |
||
5247 | * @return static |
||
5248 | * <p>(Immutable) A slice of the original array with length $length.</p> |
||
5249 | * |
||
5250 | * @psalm-return static<TKey,T> |
||
5251 | * @psalm-mutation-free |
||
5252 | */ |
||
5253 | 5 | public function slice(int $offset, int $length = null, bool $preserveKeys = false) |
|
5266 | |||
5267 | /** |
||
5268 | * Sort the current array and optional you can keep the keys. |
||
5269 | * |
||
5270 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5271 | * @param int $strategy <p>sort_flags => use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5272 | * <strong>SORT_NATURAL</strong></p> |
||
5273 | * @param bool $keepKeys |
||
5274 | * |
||
5275 | * @return static |
||
5276 | * <p>(Mutable) Return this Arrayy object.</p> |
||
5277 | * |
||
5278 | * @psalm-return static<TKey,T> |
||
5279 | */ |
||
5280 | 20 | public function sort( |
|
5294 | |||
5295 | /** |
||
5296 | * Sort the current array and optional you can keep the keys. |
||
5297 | * |
||
5298 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5299 | * @param int $strategy <p>sort_flags => use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5300 | * <strong>SORT_NATURAL</strong></p> |
||
5301 | * @param bool $keepKeys |
||
5302 | * |
||
5303 | * @return static |
||
5304 | * <p>(Immutable) Return this Arrayy object.</p> |
||
5305 | * |
||
5306 | * @psalm-return static<TKey,T> |
||
5307 | */ |
||
5308 | 12 | public function sortImmutable( |
|
5324 | |||
5325 | /** |
||
5326 | * Sort the current array by key. |
||
5327 | * |
||
5328 | * @see http://php.net/manual/en/function.ksort.php |
||
5329 | * @see http://php.net/manual/en/function.krsort.php |
||
5330 | * |
||
5331 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5332 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5333 | * <strong>SORT_NATURAL</strong></p> |
||
5334 | * |
||
5335 | * @return $this |
||
5336 | * <p>(Mutable) Return this Arrayy object.</p> |
||
5337 | * |
||
5338 | * @psalm-return static<TKey,T> |
||
5339 | */ |
||
5340 | 18 | public function sortKeys( |
|
5350 | |||
5351 | /** |
||
5352 | * Sort the current array by key. |
||
5353 | * |
||
5354 | * @see http://php.net/manual/en/function.ksort.php |
||
5355 | * @see http://php.net/manual/en/function.krsort.php |
||
5356 | * |
||
5357 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5358 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5359 | * <strong>SORT_NATURAL</strong></p> |
||
5360 | * |
||
5361 | * @return $this |
||
5362 | * <p>(Immutable) Return this Arrayy object.</p> |
||
5363 | * |
||
5364 | * @psalm-return static<TKey,T> |
||
5365 | * @psalm-mutation-free |
||
5366 | */ |
||
5367 | 8 | public function sortKeysImmutable( |
|
5380 | |||
5381 | /** |
||
5382 | * Sort the current array by value. |
||
5383 | * |
||
5384 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5385 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5386 | * <strong>SORT_NATURAL</strong></p> |
||
5387 | * |
||
5388 | * @return static |
||
5389 | * <p>(Mutable)</p> |
||
5390 | * |
||
5391 | * @psalm-return static<TKey,T> |
||
5392 | */ |
||
5393 | 1 | public function sortValueKeepIndex( |
|
5399 | |||
5400 | /** |
||
5401 | * Sort the current array by value. |
||
5402 | * |
||
5403 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5404 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5405 | * <strong>SORT_NATURAL</strong></p> |
||
5406 | * |
||
5407 | * @return static |
||
5408 | * <p>(Mutable)</p> |
||
5409 | * |
||
5410 | * @psalm-return static<TKey,T> |
||
5411 | */ |
||
5412 | 1 | public function sortValueNewIndex($direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
5416 | |||
5417 | /** |
||
5418 | * Sort a array by value, by a closure or by a property. |
||
5419 | * |
||
5420 | * - If the sorter is null, the array is sorted naturally. |
||
5421 | * - Associative (string) keys will be maintained, but numeric keys will be re-indexed. |
||
5422 | * |
||
5423 | * @param callable|string|null $sorter |
||
5424 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or |
||
5425 | * <strong>SORT_DESC</strong></p> |
||
5426 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5427 | * <strong>SORT_NATURAL</strong></p> |
||
5428 | * |
||
5429 | * @return static |
||
5430 | * <p>(Immutable)</p> |
||
5431 | * |
||
5432 | * @psalm-return static<TKey,T> |
||
5433 | * @psalm-mutation-free |
||
5434 | */ |
||
5435 | 1 | public function sorter($sorter = null, $direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
5476 | |||
5477 | /** |
||
5478 | * @param int $offset |
||
5479 | * @param int|null $length |
||
5480 | * @param array $replacement |
||
5481 | * |
||
5482 | * @return static |
||
5483 | * <p>(Immutable)</p> |
||
5484 | * |
||
5485 | * @psalm-param array<mixed,mixed>|array<mixed,T> $replacement |
||
5486 | * @psalm-return static<TKey,T> |
||
5487 | * @psalm-mutation-free |
||
5488 | */ |
||
5489 | 1 | public function splice(int $offset, int $length = null, $replacement = []): self |
|
5506 | |||
5507 | /** |
||
5508 | * Split an array in the given amount of pieces. |
||
5509 | * |
||
5510 | * @param int $numberOfPieces |
||
5511 | * @param bool $keepKeys |
||
5512 | * |
||
5513 | * @return static |
||
5514 | * <p>(Immutable)</p> |
||
5515 | * |
||
5516 | * @psalm-return static<TKey,T> |
||
5517 | * @psalm-mutation-free |
||
5518 | */ |
||
5519 | 1 | public function split(int $numberOfPieces = 2, bool $keepKeys = false): self |
|
5538 | |||
5539 | /** |
||
5540 | * Stripe all empty items. |
||
5541 | * |
||
5542 | * @return static |
||
5543 | * <p>(Immutable)</p> |
||
5544 | * |
||
5545 | * @psalm-return static<TKey,T> |
||
5546 | * @psalm-mutation-free |
||
5547 | */ |
||
5548 | 1 | public function stripEmpty(): self |
|
5560 | |||
5561 | /** |
||
5562 | * Swap two values between positions by key. |
||
5563 | * |
||
5564 | * @param int|string $swapA <p>a key in the array</p> |
||
5565 | * @param int|string $swapB <p>a key in the array</p> |
||
5566 | * |
||
5567 | * @return static |
||
5568 | * <p>(Immutable)</p> |
||
5569 | * |
||
5570 | * @psalm-return static<TKey,T> |
||
5571 | * @psalm-mutation-free |
||
5572 | */ |
||
5573 | 1 | public function swap($swapA, $swapB): self |
|
5585 | |||
5586 | /** |
||
5587 | * Get the current array from the "Arrayy"-object. |
||
5588 | * alias for "getArray()" |
||
5589 | * |
||
5590 | * @param bool $convertAllArrayyElements <p> |
||
5591 | * Convert all Child-"Arrayy" objects also to arrays. |
||
5592 | * </p> |
||
5593 | * @param bool $preserveKeys <p> |
||
5594 | * e.g.: A generator maybe return the same key more then once, |
||
5595 | * so maybe you will ignore the keys. |
||
5596 | * </p> |
||
5597 | * |
||
5598 | * @return array |
||
5599 | * |
||
5600 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
5601 | * @psalm-mutation-free |
||
5602 | */ |
||
5603 | 931 | public function toArray( |
|
5628 | |||
5629 | /** |
||
5630 | * Get the current array from the "Arrayy"-object as list. |
||
5631 | * |
||
5632 | * @param bool $convertAllArrayyElements <p> |
||
5633 | * Convert all Child-"Arrayy" objects also to arrays. |
||
5634 | * </p> |
||
5635 | * |
||
5636 | * @return array |
||
5637 | * |
||
5638 | * @psalm-return array<int,mixed>|array<int,T> |
||
5639 | * @psalm-mutation-free |
||
5640 | */ |
||
5641 | 1 | public function toList(bool $convertAllArrayyElements = false): array |
|
5648 | |||
5649 | /** |
||
5650 | * Convert the current array to JSON. |
||
5651 | * |
||
5652 | * @param int $options [optional] <p>e.g. JSON_PRETTY_PRINT</p> |
||
5653 | * @param int $depth [optional] <p>Set the maximum depth. Must be greater than zero.</p> |
||
5654 | * |
||
5655 | * @return string |
||
5656 | */ |
||
5657 | 11 | public function toJson(int $options = 0, int $depth = 512): string |
|
5666 | |||
5667 | /** |
||
5668 | * @param string[]|null $items [optional] |
||
5669 | * @param string[] $helper [optional] |
||
5670 | * |
||
5671 | * @return static|static[] |
||
5672 | * |
||
5673 | * @psalm-return static<int, static<TKey,T>> |
||
5674 | */ |
||
5675 | 1 | public function toPermutation(array $items = null, array $helper = []): self |
|
5709 | |||
5710 | /** |
||
5711 | * Implodes array to a string with specified separator. |
||
5712 | * |
||
5713 | * @param string $separator [optional] <p>The element's separator.</p> |
||
5714 | * |
||
5715 | * @return string |
||
5716 | * <p>The string representation of array, separated by ",".</p> |
||
5717 | */ |
||
5718 | 19 | public function toString(string $separator = ','): string |
|
5722 | |||
5723 | /** |
||
5724 | * Return a duplicate free copy of the current array. |
||
5725 | * |
||
5726 | * @return $this |
||
5727 | * <p>(Mutable)</p> |
||
5728 | * |
||
5729 | * @psalm-return static<TKey,T> |
||
5730 | */ |
||
5731 | 13 | public function unique(): self |
|
5753 | |||
5754 | /** |
||
5755 | * Return a duplicate free copy of the current array. (with the old keys) |
||
5756 | * |
||
5757 | * @return $this |
||
5758 | * <p>(Mutable)</p> |
||
5759 | * |
||
5760 | * @psalm-return static<TKey,T> |
||
5761 | */ |
||
5762 | 11 | public function uniqueKeepIndex(): self |
|
5788 | |||
5789 | /** |
||
5790 | * alias: for "Arrayy->unique()" |
||
5791 | * |
||
5792 | * @return static |
||
5793 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
5794 | * |
||
5795 | * @see Arrayy::unique() |
||
5796 | * |
||
5797 | * @psalm-return static<TKey,T> |
||
5798 | */ |
||
5799 | 10 | public function uniqueNewIndex(): self |
|
5803 | |||
5804 | /** |
||
5805 | * Prepends one or more values to the beginning of array at once. |
||
5806 | * |
||
5807 | * @param array ...$args |
||
5808 | * |
||
5809 | * @return $this |
||
5810 | * <p>(Mutable) Return this Arrayy object, with prepended elements to the beginning of array.</p> |
||
5811 | * |
||
5812 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$args |
||
5813 | * @psalm-return static<TKey,T> |
||
5814 | */ |
||
5815 | 4 | public function unshift(...$args): self |
|
5823 | |||
5824 | /** |
||
5825 | * Tests whether the given closure return something valid for all elements of this array. |
||
5826 | * |
||
5827 | * @param \Closure $closure the predicate |
||
5828 | * |
||
5829 | * @return bool |
||
5830 | * <p>TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.</p> |
||
5831 | */ |
||
5832 | 1 | View Code Duplication | public function validate(\Closure $closure): bool |
5842 | |||
5843 | /** |
||
5844 | * Get all values from a array. |
||
5845 | * |
||
5846 | * @return static |
||
5847 | * <p>(Immutable)</p> |
||
5848 | * |
||
5849 | * @psalm-return static<TKey,T> |
||
5850 | * @psalm-mutation-free |
||
5851 | */ |
||
5852 | 2 | public function values(): self |
|
5865 | |||
5866 | /** |
||
5867 | * Apply the given function to every element in the array, discarding the results. |
||
5868 | * |
||
5869 | * @param callable $callable |
||
5870 | * @param bool $recursive <p>Whether array will be walked recursively or no</p> |
||
5871 | * |
||
5872 | * @return $this |
||
5873 | * <p>(Mutable) Return this Arrayy object, with modified elements.</p> |
||
5874 | * |
||
5875 | * @psalm-return static<TKey,T> |
||
5876 | */ |
||
5877 | 12 | public function walk($callable, bool $recursive = false): self |
|
5891 | |||
5892 | /** |
||
5893 | * Returns a collection of matching items. |
||
5894 | * |
||
5895 | * @param string $keyOrPropertyOrMethod the property or method to evaluate |
||
5896 | * @param mixed $value the value to match |
||
5897 | * |
||
5898 | * @throws \InvalidArgumentException if property or method is not defined |
||
5899 | * |
||
5900 | * @return static |
||
5901 | * |
||
5902 | * @psalm-param T $value |
||
5903 | * @psalm-return static<TKey,T> |
||
5904 | */ |
||
5905 | 1 | public function where(string $keyOrPropertyOrMethod, $value): self |
|
5918 | |||
5919 | /** |
||
5920 | * Convert an array into a object. |
||
5921 | * |
||
5922 | * @param array $array |
||
5923 | * |
||
5924 | * @return \stdClass |
||
5925 | * |
||
5926 | * @psalm-param array<mixed,mixed> $array |
||
5927 | */ |
||
5928 | 4 | final protected static function arrayToObject(array $array = []): \stdClass |
|
5947 | |||
5948 | /** |
||
5949 | * @param array|\Generator|null $input <p> |
||
5950 | * An array containing keys to return. |
||
5951 | * </p> |
||
5952 | * @param mixed|null $search_values [optional] <p> |
||
5953 | * If specified, then only keys containing these values are returned. |
||
5954 | * </p> |
||
5955 | * @param bool $strict [optional] <p> |
||
5956 | * Determines if strict comparison (===) should be used during the |
||
5957 | * search. |
||
5958 | * </p> |
||
5959 | * |
||
5960 | * @return array |
||
5961 | * <p>an array of all the keys in input</p> |
||
5962 | * |
||
5963 | * @psalm-param array<mixed,mixed>|\Generator<TKey,T>|null $input |
||
5964 | * @psalm-return array<TKey|mixed> |
||
5965 | * @psalm-mutation-free |
||
5966 | */ |
||
5967 | 11 | protected function array_keys_recursive( |
|
6028 | |||
6029 | /** |
||
6030 | * @param mixed $path |
||
6031 | * @param callable $callable |
||
6032 | * @param array|null $currentOffset |
||
6033 | * |
||
6034 | * @return void |
||
6035 | * |
||
6036 | * @psalm-param array<mixed,mixed>|array<TKey,T>|null $currentOffset |
||
6037 | * @psalm-mutation-free |
||
6038 | */ |
||
6039 | 11 | protected function callAtPath($path, $callable, &$currentOffset = null) |
|
6068 | |||
6069 | /** |
||
6070 | * Extracts the value of the given property or method from the object. |
||
6071 | * |
||
6072 | * @param static $object <p>The object to extract the value from.</p> |
||
6073 | * @param string $keyOrPropertyOrMethod <p>The property or method for which the |
||
6074 | * value should be extracted.</p> |
||
6075 | * |
||
6076 | * @throws \InvalidArgumentException if the method or property is not defined |
||
6077 | * |
||
6078 | * @return mixed |
||
6079 | * <p>The value extracted from the specified property or method.</p> |
||
6080 | * |
||
6081 | * @psalm-param self<TKey,T> $object |
||
6082 | */ |
||
6083 | 2 | final protected function extractValue(self $object, string $keyOrPropertyOrMethod) |
|
6105 | |||
6106 | /** |
||
6107 | * create a fallback for array |
||
6108 | * |
||
6109 | * 1. use the current array, if it's a array |
||
6110 | * 2. fallback to empty array, if there is nothing |
||
6111 | * 3. call "getArray()" on object, if there is a "Arrayy"-object |
||
6112 | * 4. call "createFromObject()" on object, if there is a "\Traversable"-object |
||
6113 | * 5. call "__toArray()" on object, if the method exists |
||
6114 | * 6. cast a string or object with "__toString()" into an array |
||
6115 | * 7. throw a "InvalidArgumentException"-Exception |
||
6116 | * |
||
6117 | * @param mixed $data |
||
6118 | * |
||
6119 | * @throws \InvalidArgumentException |
||
6120 | * |
||
6121 | * @return array |
||
6122 | * |
||
6123 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
6124 | */ |
||
6125 | 1173 | protected function fallbackForArray(&$data): array |
|
6135 | |||
6136 | /** |
||
6137 | * @param bool $preserveKeys <p> |
||
6138 | * e.g.: A generator maybe return the same key more then once, |
||
6139 | * so maybe you will ignore the keys. |
||
6140 | * </p> |
||
6141 | * |
||
6142 | * @return bool |
||
6143 | * |
||
6144 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
6145 | * @psalm-mutation-free :/ |
||
6146 | */ |
||
6147 | 1085 | protected function generatorToArray(bool $preserveKeys = true) |
|
6158 | |||
6159 | /** |
||
6160 | * Get correct PHP constant for direction. |
||
6161 | * |
||
6162 | * @param int|string $direction |
||
6163 | * |
||
6164 | * @return int |
||
6165 | * @psalm-mutation-free |
||
6166 | */ |
||
6167 | 43 | protected function getDirection($direction): int |
|
6189 | |||
6190 | /** |
||
6191 | * @return TypeCheckPhpDoc[] |
||
6192 | * |
||
6193 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
6194 | */ |
||
6195 | 16 | protected function getPropertiesFromPhpDoc() |
|
6220 | |||
6221 | /** |
||
6222 | * @param mixed $glue |
||
6223 | * @param mixed $pieces |
||
6224 | * @param bool $useKeys |
||
6225 | * |
||
6226 | * @return string |
||
6227 | * @psalm-mutation-free |
||
6228 | */ |
||
6229 | 36 | protected function implode_recursive( |
|
6262 | |||
6263 | /** |
||
6264 | * @param mixed $needle <p> |
||
6265 | * The searched value. |
||
6266 | * </p> |
||
6267 | * <p> |
||
6268 | * If needle is a string, the comparison is done |
||
6269 | * in a case-sensitive manner. |
||
6270 | * </p> |
||
6271 | * @param array|\Generator|null $haystack <p> |
||
6272 | * The array. |
||
6273 | * </p> |
||
6274 | * @param bool $strict [optional] <p> |
||
6275 | * If the third parameter strict is set to true |
||
6276 | * then the in_array function will also check the |
||
6277 | * types of the |
||
6278 | * needle in the haystack. |
||
6279 | * </p> |
||
6280 | * |
||
6281 | * @return bool |
||
6282 | * <p>true if needle is found in the array, false otherwise</p> |
||
6283 | * |
||
6284 | * @psalm-param array<mixed,mixed>|\Generator<TKey,T>|null $haystack |
||
6285 | * @psalm-mutation-free |
||
6286 | */ |
||
6287 | 18 | protected function in_array_recursive($needle, $haystack = null, $strict = true): bool |
|
6312 | |||
6313 | /** |
||
6314 | * @param mixed $data |
||
6315 | * |
||
6316 | * @return array|null |
||
6317 | * |
||
6318 | * @psalm-return array<mixed,mixed>|array<TKey,T>|null |
||
6319 | */ |
||
6320 | 1173 | protected function internalGetArray(&$data) |
|
6371 | |||
6372 | /** |
||
6373 | * Internal mechanics of remove method. |
||
6374 | * |
||
6375 | * @param mixed $key |
||
6376 | * |
||
6377 | * @return bool |
||
6378 | */ |
||
6379 | 21 | protected function internalRemove($key): bool |
|
6412 | |||
6413 | /** |
||
6414 | * Internal mechanic of set method. |
||
6415 | * |
||
6416 | * @param int|string|null $key |
||
6417 | * @param mixed $value |
||
6418 | * @param bool $checkProperties |
||
6419 | * |
||
6420 | * @return bool |
||
6421 | */ |
||
6422 | 1024 | protected function internalSet( |
|
6481 | |||
6482 | /** |
||
6483 | * Convert a object into an array. |
||
6484 | * |
||
6485 | * @param mixed|object $object |
||
6486 | * |
||
6487 | * @return array|mixed |
||
6488 | * |
||
6489 | * @psalm-mutation-free |
||
6490 | */ |
||
6491 | 5 | protected static function objectToArray($object) |
|
6504 | |||
6505 | /** |
||
6506 | * @param array $data |
||
6507 | * @param bool $checkPropertiesInConstructor |
||
6508 | * |
||
6509 | * @return void |
||
6510 | * |
||
6511 | * @psalm-param array<mixed,T> $data |
||
6512 | */ |
||
6513 | 1171 | protected function setInitialValuesAndProperties(array &$data, bool $checkPropertiesInConstructor) |
|
6558 | |||
6559 | /** |
||
6560 | * sorting keys |
||
6561 | * |
||
6562 | * @param array $elements |
||
6563 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
6564 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
6565 | * <strong>SORT_NATURAL</strong></p> |
||
6566 | * |
||
6567 | * @return $this |
||
6568 | * <p>(Mutable) Return this Arrayy object.</p> |
||
6569 | * |
||
6570 | * @psalm-param array<mixed,mixed>|array<mixed|TKey,T> $elements |
||
6571 | * @psalm-return static<TKey,T> |
||
6572 | */ |
||
6573 | 18 | protected function sorterKeys( |
|
6594 | |||
6595 | /** |
||
6596 | * @param array $elements <p>Warning: used as reference</p> |
||
6597 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
6598 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
6599 | * <strong>SORT_NATURAL</strong></p> |
||
6600 | * @param bool $keepKeys |
||
6601 | * |
||
6602 | * @return $this |
||
6603 | * <p>(Mutable) Return this Arrayy object.</p> |
||
6604 | * |
||
6605 | * @psalm-param array<mixed,mixed>|array<mixed|TKey,T> $elements |
||
6606 | * @psalm-return static<TKey,T> |
||
6607 | */ |
||
6608 | 24 | protected function sorting(array &$elements, $direction = \SORT_ASC, int $strategy = \SORT_REGULAR, bool $keepKeys = false): self |
|
6638 | |||
6639 | /** |
||
6640 | * @param array $array |
||
6641 | * |
||
6642 | * @return array |
||
6643 | * |
||
6644 | * @psalm-mutation-free |
||
6645 | */ |
||
6646 | 25 | private function getArrayRecursiveHelperArrayy(array $array) |
|
6668 | |||
6669 | /** |
||
6670 | * @param int|string|null $key |
||
6671 | * @param mixed $value |
||
6672 | * |
||
6673 | * @return void |
||
6674 | */ |
||
6675 | 87 | private function checkType($key, $value) |
|
6693 | } |
||
6694 |
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..