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|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 | 1100 | public function __construct( |
|
116 | |||
117 | /** |
||
118 | * @return void |
||
119 | */ |
||
120 | 47 | public function __clone() |
|
130 | |||
131 | /** |
||
132 | * Call object as function. |
||
133 | * |
||
134 | * @param mixed $key |
||
135 | * |
||
136 | * @return mixed |
||
137 | */ |
||
138 | 1 | public function __invoke($key = null) |
|
148 | |||
149 | /** |
||
150 | * Whether or not an element exists by key. |
||
151 | * |
||
152 | * @param mixed $key |
||
153 | * |
||
154 | * @return bool |
||
155 | * <p>True is the key/index exists, otherwise false.</p> |
||
156 | */ |
||
157 | public function __isset($key): bool |
||
161 | |||
162 | /** |
||
163 | * Assigns a value to the specified element. |
||
164 | * |
||
165 | * @param mixed $key |
||
166 | * @param mixed $value |
||
167 | * |
||
168 | * @return void |
||
169 | */ |
||
170 | 2 | public function __set($key, $value) |
|
174 | |||
175 | /** |
||
176 | * magic to string |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | 15 | public function __toString(): string |
|
184 | |||
185 | /** |
||
186 | * Unset element by key. |
||
187 | * |
||
188 | * @param mixed $key |
||
189 | */ |
||
190 | public function __unset($key) |
||
194 | |||
195 | /** |
||
196 | * Get a value by key. |
||
197 | * |
||
198 | * @param mixed $key |
||
199 | * |
||
200 | * @return mixed |
||
201 | * <p>Get a Value from the current array.</p> |
||
202 | */ |
||
203 | 4 | public function &__get($key) |
|
213 | |||
214 | /** |
||
215 | * alias: for "Arrayy->append()" |
||
216 | * |
||
217 | * @param mixed $value |
||
218 | * |
||
219 | * @return static |
||
220 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
221 | * |
||
222 | * @see Arrayy::append() |
||
223 | * |
||
224 | * @psalm-param T $value |
||
225 | * @psalm-return static<TKey,T> |
||
226 | */ |
||
227 | 3 | public function add($value) |
|
231 | |||
232 | /** |
||
233 | * Append a (key) + value to the current array. |
||
234 | * |
||
235 | * @param mixed $value |
||
236 | * @param mixed $key |
||
237 | * |
||
238 | * @return $this |
||
239 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
240 | * |
||
241 | * @psalm-return static<TKey,T> |
||
242 | */ |
||
243 | 13 | public function append($value, $key = null): self |
|
267 | |||
268 | /** |
||
269 | * Sort the entries by value. |
||
270 | * |
||
271 | * @param int $sort_flags [optional] <p> |
||
272 | * You may modify the behavior of the sort using the optional |
||
273 | * parameter sort_flags, for details |
||
274 | * see sort. |
||
275 | * </p> |
||
276 | * |
||
277 | * @return $this |
||
278 | * <p>(Mutable) Return this Arrayy object.</p> |
||
279 | * |
||
280 | * @psalm-return static<TKey,T> |
||
281 | */ |
||
282 | 4 | public function asort(int $sort_flags = 0): self |
|
290 | |||
291 | /** |
||
292 | * Sort the entries by value. |
||
293 | * |
||
294 | * @param int $sort_flags [optional] <p> |
||
295 | * You may modify the behavior of the sort using the optional |
||
296 | * parameter sort_flags, for details |
||
297 | * see sort. |
||
298 | * </p> |
||
299 | * |
||
300 | * @return $this |
||
301 | * <p>(Immutable) Return this Arrayy object.</p> |
||
302 | * |
||
303 | * @psalm-return static<TKey,T> |
||
304 | * @psalm-mutation-free |
||
305 | */ |
||
306 | 4 | public function asortImmutable(int $sort_flags = 0): self |
|
314 | |||
315 | /** |
||
316 | * Counts all elements in an array, or something in an object. |
||
317 | * |
||
318 | * <p> |
||
319 | * For objects, if you have SPL installed, you can hook into count() by implementing interface {@see Countable}. |
||
320 | * The interface has exactly one method, {@see Countable::count()}, which returns the return value for the count() |
||
321 | * function. Please see the {@see Array} section of the manual for a detailed explanation of how arrays are |
||
322 | * implemented and used in PHP. |
||
323 | * </p> |
||
324 | * |
||
325 | * @see http://php.net/manual/en/function.count.php |
||
326 | * |
||
327 | * @param int $mode [optional] If the optional mode parameter is set to |
||
328 | * COUNT_RECURSIVE (or 1), count |
||
329 | * will recursively count the array. This is particularly useful for |
||
330 | * counting all the elements of a multidimensional array. count does not detect infinite recursion. |
||
331 | * |
||
332 | * @return int |
||
333 | * <p> |
||
334 | * The number of elements in var, which is |
||
335 | * typically an array, since anything else will have one |
||
336 | * element. |
||
337 | * </p> |
||
338 | * <p> |
||
339 | * If var is not an array or an object with |
||
340 | * implemented Countable interface, |
||
341 | * 1 will be returned. |
||
342 | * There is one exception, if var is &null;, |
||
343 | * 0 will be returned. |
||
344 | * </p> |
||
345 | * <p> |
||
346 | * Caution: count may return 0 for a variable that isn't set, |
||
347 | * but it may also return 0 for a variable that has been initialized with an |
||
348 | * empty array. Use isset to test if a variable is set. |
||
349 | * </p> |
||
350 | * @psalm-mutation-free |
||
351 | */ |
||
352 | 145 | public function count(int $mode = \COUNT_NORMAL): int |
|
364 | |||
365 | /** |
||
366 | * Exchange the array for another one. |
||
367 | * |
||
368 | * @param array|static $data |
||
369 | * |
||
370 | * @return array |
||
371 | * |
||
372 | * @psalm-param array<TKey,T>|self<TKey,T> $data |
||
373 | * @psalm-return array<TKey,T> |
||
374 | */ |
||
375 | 1 | public function exchangeArray($data): array |
|
381 | |||
382 | /** |
||
383 | * Creates a copy of the ArrayyObject. |
||
384 | * |
||
385 | * @return array |
||
386 | * |
||
387 | * @psalm-return array<TKey,T> |
||
388 | */ |
||
389 | 5 | public function getArrayCopy(): array |
|
395 | |||
396 | /** |
||
397 | * Returns a new iterator, thus implementing the \Iterator interface. |
||
398 | * |
||
399 | * @return \Iterator<mixed, mixed> |
||
400 | * <p>An iterator for the values in the array.</p> |
||
401 | */ |
||
402 | 24 | public function getIterator(): \Iterator |
|
416 | |||
417 | /** |
||
418 | * Gets the iterator classname for the ArrayObject. |
||
419 | * |
||
420 | * @return string |
||
421 | * |
||
422 | * @psalm-return class-string |
||
423 | */ |
||
424 | 23 | public function getIteratorClass(): string |
|
428 | |||
429 | /** |
||
430 | * Sort the entries by key. |
||
431 | * |
||
432 | * @param int $sort_flags [optional] <p> |
||
433 | * You may modify the behavior of the sort using the optional |
||
434 | * parameter sort_flags, for details |
||
435 | * see sort. |
||
436 | * </p> |
||
437 | * |
||
438 | * @return $this |
||
439 | * <p>(Mutable) Return this Arrayy object.</p> |
||
440 | * |
||
441 | * @psalm-return static<TKey,T> |
||
442 | */ |
||
443 | 4 | public function ksort(int $sort_flags = 0): self |
|
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>(Immutable) Return this Arrayy object.</p> |
||
463 | * |
||
464 | * @psalm-return static<TKey,T> |
||
465 | */ |
||
466 | 4 | public function ksortImmutable(int $sort_flags = 0): self |
|
477 | |||
478 | /** |
||
479 | * Sort an array using a case insensitive "natural order" algorithm. |
||
480 | * |
||
481 | * @return $this |
||
482 | * <p>(Mutable) Return this Arrayy object.</p> |
||
483 | * |
||
484 | * @psalm-return static<TKey,T> |
||
485 | */ |
||
486 | 8 | public function natcasesort(): self |
|
494 | |||
495 | /** |
||
496 | * Sort an array using a case insensitive "natural order" algorithm. |
||
497 | * |
||
498 | * @return $this |
||
499 | * <p>(Immutable) Return this Arrayy object.</p> |
||
500 | * |
||
501 | * @psalm-return static<TKey,T> |
||
502 | * @psalm-mutation-free |
||
503 | */ |
||
504 | 4 | public function natcasesortImmutable(): self |
|
512 | |||
513 | /** |
||
514 | * Sort entries using a "natural order" algorithm. |
||
515 | * |
||
516 | * @return $this |
||
517 | * <p>(Mutable) Return this Arrayy object.</p> |
||
518 | * |
||
519 | * @psalm-return static<TKey,T> |
||
520 | */ |
||
521 | 9 | public function natsort(): self |
|
529 | |||
530 | /** |
||
531 | * Sort entries using a "natural order" algorithm. |
||
532 | * |
||
533 | * @return $this |
||
534 | * <p>(Immutable) Return this Arrayy object.</p> |
||
535 | * |
||
536 | * @psalm-return static<TKey,T> |
||
537 | * @psalm-mutation-free |
||
538 | */ |
||
539 | 4 | public function natsortImmutable(): self |
|
547 | |||
548 | /** |
||
549 | * Whether or not an offset exists. |
||
550 | * |
||
551 | * @param bool|int|string $offset |
||
552 | * |
||
553 | * @return bool |
||
554 | * |
||
555 | * @noinspection PhpSillyAssignmentInspection |
||
556 | * |
||
557 | * @psalm-mutation-free |
||
558 | */ |
||
559 | 130 | public function offsetExists($offset): bool |
|
616 | |||
617 | /** |
||
618 | * Returns the value at specified offset. |
||
619 | * |
||
620 | * @param int|string $offset |
||
621 | * |
||
622 | * @return mixed |
||
623 | * <p>Will return null if the offset did not exists.</p> |
||
624 | */ |
||
625 | 101 | public function offsetGet($offset) |
|
629 | |||
630 | /** |
||
631 | * Assigns a value to the specified offset + check the type. |
||
632 | * |
||
633 | * @param int|string|null $offset |
||
634 | * @param mixed $value |
||
635 | * |
||
636 | * @return void |
||
637 | */ |
||
638 | 18 | public function offsetSet($offset, $value) |
|
656 | |||
657 | /** |
||
658 | * Unset an offset. |
||
659 | * |
||
660 | * @param int|string $offset |
||
661 | * |
||
662 | * @return void |
||
663 | */ |
||
664 | 12 | public function offsetUnset($offset) |
|
701 | |||
702 | /** |
||
703 | * Serialize the current "Arrayy"-object. |
||
704 | * |
||
705 | * @return string |
||
706 | */ |
||
707 | 2 | public function serialize(): string |
|
717 | |||
718 | /** |
||
719 | * Sets the iterator classname for the current "Arrayy"-object. |
||
720 | * |
||
721 | * @param string $iteratorClass |
||
722 | * |
||
723 | * @throws \InvalidArgumentException |
||
724 | * |
||
725 | * @return void |
||
726 | * |
||
727 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
728 | */ |
||
729 | 1091 | public function setIteratorClass($iteratorClass) |
|
748 | |||
749 | /** |
||
750 | * Sort the entries with a user-defined comparison function and maintain key association. |
||
751 | * |
||
752 | * @param callable $function |
||
753 | * |
||
754 | * @throws \InvalidArgumentException |
||
755 | * |
||
756 | * @return $this |
||
757 | * <p>(Mutable) Return this Arrayy object.</p> |
||
758 | * |
||
759 | * @psalm-return static<TKey,T> |
||
760 | */ |
||
761 | 8 | View Code Duplication | public function uasort($function): self |
773 | |||
774 | /** |
||
775 | * Sort the entries with a user-defined comparison function and maintain key association. |
||
776 | * |
||
777 | * @param callable $function |
||
778 | * |
||
779 | * @throws \InvalidArgumentException |
||
780 | * |
||
781 | * @return $this |
||
782 | * <p>(Immutable) Return this Arrayy object.</p> |
||
783 | * |
||
784 | * @psalm-return static<TKey,T> |
||
785 | * @psalm-mutation-free |
||
786 | */ |
||
787 | 4 | public function uasortImmutable($function): self |
|
795 | |||
796 | /** |
||
797 | * Sort the entries by keys using a user-defined comparison function. |
||
798 | * |
||
799 | * @param callable $function |
||
800 | * |
||
801 | * @throws \InvalidArgumentException |
||
802 | * |
||
803 | * @return static |
||
804 | * <p>(Mutable) Return this Arrayy object.</p> |
||
805 | * |
||
806 | * @psalm-return static<TKey,T> |
||
807 | */ |
||
808 | 5 | public function uksort($function): self |
|
812 | |||
813 | /** |
||
814 | * Sort the entries by keys using a user-defined comparison function. |
||
815 | * |
||
816 | * @param callable $function |
||
817 | * |
||
818 | * @throws \InvalidArgumentException |
||
819 | * |
||
820 | * @return static |
||
821 | * <p>(Immutable) Return this Arrayy object.</p> |
||
822 | * |
||
823 | * @psalm-return static<TKey,T> |
||
824 | * @psalm-mutation-free |
||
825 | */ |
||
826 | 1 | public function uksortImmutable($function): self |
|
830 | |||
831 | /** |
||
832 | * Unserialize an string and return the instance of the "Arrayy"-class. |
||
833 | * |
||
834 | * @param string $string |
||
835 | * |
||
836 | * @return $this |
||
837 | * |
||
838 | * @psalm-return static<TKey,T> |
||
839 | */ |
||
840 | 2 | public function unserialize($string): self |
|
850 | |||
851 | /** |
||
852 | * Append a (key) + values to the current array. |
||
853 | * |
||
854 | * @param array $values |
||
855 | * @param mixed $key |
||
856 | * |
||
857 | * @return $this |
||
858 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
859 | * |
||
860 | * @psalm-param array<mixed,T> $values |
||
861 | * @psalm-param TKey|null $key |
||
862 | * @psalm-return static<TKey,T> |
||
863 | */ |
||
864 | 1 | public function appendArrayValues(array $values, $key = null) |
|
890 | |||
891 | /** |
||
892 | * Add a suffix to each key. |
||
893 | * |
||
894 | * @param mixed $prefix |
||
895 | * |
||
896 | * @return static |
||
897 | * <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> |
||
898 | * |
||
899 | * @psalm-return static<TKey,T> |
||
900 | * @psalm-mutation-free |
||
901 | */ |
||
902 | 10 | View Code Duplication | public function appendToEachKey($prefix): self |
921 | |||
922 | /** |
||
923 | * Add a prefix to each value. |
||
924 | * |
||
925 | * @param mixed $prefix |
||
926 | * |
||
927 | * @return static |
||
928 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
||
929 | * |
||
930 | * @psalm-return static<TKey,T> |
||
931 | * @psalm-mutation-free |
||
932 | */ |
||
933 | 10 | View Code Duplication | public function appendToEachValue($prefix): self |
952 | |||
953 | /** |
||
954 | * Sort an array in reverse order and maintain index association. |
||
955 | * |
||
956 | * @return $this |
||
957 | * <p>(Mutable) Return this Arrayy object.</p> |
||
958 | * |
||
959 | * @psalm-return static<TKey,T> |
||
960 | */ |
||
961 | 4 | public function arsort(): self |
|
969 | |||
970 | /** |
||
971 | * Sort an array in reverse order and maintain index association. |
||
972 | * |
||
973 | * @return $this |
||
974 | * <p>(Immutable) Return this Arrayy object.</p> |
||
975 | * |
||
976 | * @psalm-return static<TKey,T> |
||
977 | * @psalm-mutation-free |
||
978 | */ |
||
979 | 10 | public function arsortImmutable(): self |
|
989 | |||
990 | /** |
||
991 | * Iterate over the current array and execute a callback for each loop. |
||
992 | * |
||
993 | * @param \Closure $closure |
||
994 | * |
||
995 | * @return static |
||
996 | * <p>(Immutable)</p> |
||
997 | * |
||
998 | * @psalm-return static<TKey,T> |
||
999 | * @psalm-mutation-free |
||
1000 | */ |
||
1001 | 2 | public function at(\Closure $closure): self |
|
1015 | |||
1016 | /** |
||
1017 | * Returns the average value of the current array. |
||
1018 | * |
||
1019 | * @param int $decimals <p>The number of decimal-numbers to return.</p> |
||
1020 | * |
||
1021 | * @return float|int |
||
1022 | * <p>The average value.</p> |
||
1023 | * @psalm-mutation-free |
||
1024 | */ |
||
1025 | 10 | public function average($decimals = 0) |
|
1039 | |||
1040 | /** |
||
1041 | * Changes all keys in an array. |
||
1042 | * |
||
1043 | * @param int $case [optional] <p> Either <strong>CASE_UPPER</strong><br /> |
||
1044 | * or <strong>CASE_LOWER</strong> (default)</p> |
||
1045 | * |
||
1046 | * @return static |
||
1047 | * <p>(Immutable)</p> |
||
1048 | * |
||
1049 | * @psalm-return static<TKey,T> |
||
1050 | * @psalm-mutation-free |
||
1051 | */ |
||
1052 | 1 | public function changeKeyCase(int $case = \CASE_LOWER): self |
|
1079 | |||
1080 | /** |
||
1081 | * Change the path separator of the array wrapper. |
||
1082 | * |
||
1083 | * By default, the separator is: "." |
||
1084 | * |
||
1085 | * @param string $separator <p>Separator to set.</p> |
||
1086 | * |
||
1087 | * @return $this |
||
1088 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1089 | * |
||
1090 | * @psalm-return static<TKey,T> |
||
1091 | */ |
||
1092 | 11 | public function changeSeparator($separator): self |
|
1098 | |||
1099 | /** |
||
1100 | * Create a chunked version of the current array. |
||
1101 | * |
||
1102 | * @param int $size <p>Size of each chunk.</p> |
||
1103 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
1104 | * |
||
1105 | * @return static |
||
1106 | * <p>(Immutable) A new array of chunks from the original array.</p> |
||
1107 | * |
||
1108 | * @psalm-return static<TKey,T> |
||
1109 | * @psalm-mutation-free |
||
1110 | */ |
||
1111 | 5 | public function chunk($size, $preserveKeys = false): self |
|
1119 | |||
1120 | /** |
||
1121 | * Clean all falsy values from the current array. |
||
1122 | * |
||
1123 | * @return static |
||
1124 | * <p>(Immutable)</p> |
||
1125 | * |
||
1126 | * @psalm-return static<TKey,T> |
||
1127 | * @psalm-mutation-free |
||
1128 | */ |
||
1129 | 8 | public function clean(): self |
|
1137 | |||
1138 | /** |
||
1139 | * WARNING!!! -> Clear the current array. |
||
1140 | * |
||
1141 | * @return $this |
||
1142 | * <p>(Mutable) Return this Arrayy object, with an empty array.</p> |
||
1143 | * |
||
1144 | * @psalm-return static<TKey,T> |
||
1145 | */ |
||
1146 | 5 | public function clear(): self |
|
1153 | |||
1154 | /** |
||
1155 | * Check if an item is in the current array. |
||
1156 | * |
||
1157 | * @param float|int|string $value |
||
1158 | * @param bool $recursive |
||
1159 | * @param bool $strict |
||
1160 | * |
||
1161 | * @return bool |
||
1162 | * @psalm-mutation-free |
||
1163 | */ |
||
1164 | 23 | public function contains($value, bool $recursive = false, bool $strict = true): bool |
|
1185 | |||
1186 | /** |
||
1187 | * Check if an (case-insensitive) string is in the current array. |
||
1188 | * |
||
1189 | * @param string $value |
||
1190 | * @param bool $recursive |
||
1191 | * |
||
1192 | * @return bool |
||
1193 | * @psalm-mutation-free |
||
1194 | */ |
||
1195 | 26 | public function containsCaseInsensitive($value, $recursive = false): bool |
|
1220 | |||
1221 | /** |
||
1222 | * Check if the given key/index exists in the array. |
||
1223 | * |
||
1224 | * @param int|string $key <p>key/index to search for</p> |
||
1225 | * |
||
1226 | * @return bool |
||
1227 | * <p>Returns true if the given key/index exists in the array, false otherwise.</p> |
||
1228 | * |
||
1229 | * @psalm-mutation-free |
||
1230 | */ |
||
1231 | 4 | public function containsKey($key): bool |
|
1235 | |||
1236 | /** |
||
1237 | * Check if all given needles are present in the array as key/index. |
||
1238 | * |
||
1239 | * @param array $needles <p>The keys you are searching for.</p> |
||
1240 | * @param bool $recursive |
||
1241 | * |
||
1242 | * @return bool |
||
1243 | * <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p> |
||
1244 | * |
||
1245 | * @psalm-param array<mixed,mixed>|array<TKey> $needles |
||
1246 | * @psalm-mutation-free |
||
1247 | */ |
||
1248 | 2 | public function containsKeys(array $needles, $recursive = false): bool |
|
1276 | |||
1277 | /** |
||
1278 | * Check if all given needles are present in the array as key/index. |
||
1279 | * |
||
1280 | * @param array $needles <p>The keys you are searching for.</p> |
||
1281 | * |
||
1282 | * @return bool |
||
1283 | * <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p> |
||
1284 | * |
||
1285 | * @psalm-param array<mixed,mixed>|array<TKey> $needles |
||
1286 | * @psalm-mutation-free |
||
1287 | */ |
||
1288 | 1 | public function containsKeysRecursive(array $needles): bool |
|
1292 | |||
1293 | /** |
||
1294 | * alias: for "Arrayy->contains()" |
||
1295 | * |
||
1296 | * @param float|int|string $value |
||
1297 | * |
||
1298 | * @return bool |
||
1299 | * |
||
1300 | * @see Arrayy::contains() |
||
1301 | * @psalm-mutation-free |
||
1302 | */ |
||
1303 | 9 | public function containsValue($value): bool |
|
1307 | |||
1308 | /** |
||
1309 | * alias: for "Arrayy->contains($value, true)" |
||
1310 | * |
||
1311 | * @param float|int|string $value |
||
1312 | * |
||
1313 | * @return bool |
||
1314 | * |
||
1315 | * @see Arrayy::contains() |
||
1316 | * @psalm-mutation-free |
||
1317 | */ |
||
1318 | 18 | public function containsValueRecursive($value): bool |
|
1322 | |||
1323 | /** |
||
1324 | * Check if all given needles are present in the array. |
||
1325 | * |
||
1326 | * @param array $needles |
||
1327 | * |
||
1328 | * @return bool |
||
1329 | * <p>Returns true if all the given values exists in the array, false otherwise.</p> |
||
1330 | * |
||
1331 | * @psalm-param array<mixed>|array<T> $needles |
||
1332 | * @psalm-mutation-free |
||
1333 | */ |
||
1334 | 1 | public function containsValues(array $needles): bool |
|
1340 | |||
1341 | /** |
||
1342 | * Counts all the values of an array |
||
1343 | * |
||
1344 | * @see http://php.net/manual/en/function.array-count-values.php |
||
1345 | * |
||
1346 | * @return static |
||
1347 | * <p> |
||
1348 | * (Immutable) |
||
1349 | * An associative Arrayy-object of values from input as |
||
1350 | * keys and their count as value. |
||
1351 | * </p> |
||
1352 | * |
||
1353 | * @psalm-return static<TKey,T> |
||
1354 | * @psalm-mutation-free |
||
1355 | */ |
||
1356 | 7 | public function countValues(): self |
|
1360 | |||
1361 | /** |
||
1362 | * Creates an Arrayy object. |
||
1363 | * |
||
1364 | * @param mixed $data |
||
1365 | * @param string $iteratorClass |
||
1366 | * @param bool $checkPropertiesInConstructor |
||
1367 | * |
||
1368 | * @return static |
||
1369 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1370 | * |
||
1371 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
1372 | * |
||
1373 | * @psalm-mutation-free |
||
1374 | */ |
||
1375 | 672 | public static function create( |
|
1386 | |||
1387 | /** |
||
1388 | * WARNING: Creates an Arrayy object by reference. |
||
1389 | * |
||
1390 | * @param array $array |
||
1391 | * |
||
1392 | * @return $this |
||
1393 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1394 | * |
||
1395 | * @psalm-param array<mixed,mixed>|array<array-key,mixed> $array |
||
1396 | */ |
||
1397 | 1 | public function createByReference(array &$array = []): self |
|
1405 | |||
1406 | /** |
||
1407 | * Create an new instance from a callable function which will return an Generator. |
||
1408 | * |
||
1409 | * @param callable $generatorFunction |
||
1410 | * |
||
1411 | * @return static |
||
1412 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1413 | * |
||
1414 | * @psalm-param callable():\Generator<array-key,mixed> $generatorFunction |
||
1415 | * |
||
1416 | * @psalm-mutation-free |
||
1417 | */ |
||
1418 | 7 | public static function createFromGeneratorFunction(callable $generatorFunction): self |
|
1422 | |||
1423 | /** |
||
1424 | * Create an new instance filled with a copy of values from a "Generator"-object. |
||
1425 | * |
||
1426 | * @param \Generator $generator |
||
1427 | * |
||
1428 | * @return static |
||
1429 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1430 | * |
||
1431 | * @psalm-param \Generator<array-key,mixed> $generator |
||
1432 | * |
||
1433 | * @psalm-mutation-free |
||
1434 | */ |
||
1435 | 4 | public static function createFromGeneratorImmutable(\Generator $generator): self |
|
1439 | |||
1440 | /** |
||
1441 | * Create an new Arrayy object via JSON. |
||
1442 | * |
||
1443 | * @param string $json |
||
1444 | * |
||
1445 | * @return static |
||
1446 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1447 | * |
||
1448 | * @psalm-mutation-free |
||
1449 | */ |
||
1450 | 5 | public static function createFromJson(string $json): self |
|
1454 | |||
1455 | /** |
||
1456 | * Create an new instance filled with values from an object that is iterable. |
||
1457 | * |
||
1458 | * @param \Traversable $object <p>iterable object</p> |
||
1459 | * |
||
1460 | * @return static |
||
1461 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1462 | * |
||
1463 | * @psalm-param \Traversable<array-key,mixed> $object |
||
1464 | * |
||
1465 | * @psalm-mutation-free |
||
1466 | */ |
||
1467 | 4 | public static function createFromObject(\Traversable $object): self |
|
1484 | |||
1485 | /** |
||
1486 | * Create an new instance filled with values from an object. |
||
1487 | * |
||
1488 | * @param object $object |
||
1489 | * |
||
1490 | * @return static |
||
1491 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1492 | * |
||
1493 | * @psalm-mutation-free |
||
1494 | */ |
||
1495 | 5 | public static function createFromObjectVars($object): self |
|
1499 | |||
1500 | /** |
||
1501 | * Create an new Arrayy object via string. |
||
1502 | * |
||
1503 | * @param string $str <p>The input string.</p> |
||
1504 | * @param string|null $delimiter <p>The boundary string.</p> |
||
1505 | * @param string|null $regEx <p>Use the $delimiter or the $regEx, so if $pattern is null, $delimiter will be |
||
1506 | * used.</p> |
||
1507 | * |
||
1508 | * @return static |
||
1509 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1510 | * |
||
1511 | * @psalm-mutation-free |
||
1512 | */ |
||
1513 | 10 | public static function createFromString(string $str, string $delimiter = null, string $regEx = null): self |
|
1545 | |||
1546 | /** |
||
1547 | * Create an new instance filled with a copy of values from a "Traversable"-object. |
||
1548 | * |
||
1549 | * @param \Traversable $traversable |
||
1550 | * |
||
1551 | * @return static |
||
1552 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1553 | * |
||
1554 | * @psalm-param \Traversable<array-key,mixed> $traversable |
||
1555 | * |
||
1556 | * @psalm-mutation-free |
||
1557 | */ |
||
1558 | 1 | public static function createFromTraversableImmutable(\Traversable $traversable): self |
|
1562 | |||
1563 | /** |
||
1564 | * Create an new instance containing a range of elements. |
||
1565 | * |
||
1566 | * @param float|int|string $low <p>First value of the sequence.</p> |
||
1567 | * @param float|int|string $high <p>The sequence is ended upon reaching the end value.</p> |
||
1568 | * @param float|int $step <p>Used as the increment between elements in the sequence.</p> |
||
1569 | * |
||
1570 | * @return static |
||
1571 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1572 | * |
||
1573 | * @psalm-mutation-free |
||
1574 | */ |
||
1575 | 2 | public static function createWithRange($low, $high, $step = 1): self |
|
1579 | |||
1580 | /** |
||
1581 | * Gets the element of the array at the current internal iterator position. |
||
1582 | * |
||
1583 | * @return false|mixed |
||
1584 | */ |
||
1585 | public function current() |
||
1589 | |||
1590 | /** |
||
1591 | * Custom sort by index via "uksort". |
||
1592 | * |
||
1593 | * @see http://php.net/manual/en/function.uksort.php |
||
1594 | * |
||
1595 | * @param callable $function |
||
1596 | * |
||
1597 | * @throws \InvalidArgumentException |
||
1598 | * |
||
1599 | * @return $this |
||
1600 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1601 | * |
||
1602 | * @psalm-return static<TKey,T> |
||
1603 | */ |
||
1604 | 5 | public function customSortKeys(callable $function): self |
|
1612 | |||
1613 | /** |
||
1614 | * Custom sort by index via "uksort". |
||
1615 | * |
||
1616 | * @see http://php.net/manual/en/function.uksort.php |
||
1617 | * |
||
1618 | * @param callable $function |
||
1619 | * |
||
1620 | * @throws \InvalidArgumentException |
||
1621 | * |
||
1622 | * @return $this |
||
1623 | * <p>(Immutable) Return this Arrayy object.</p> |
||
1624 | * |
||
1625 | * @psalm-return static<TKey,T> |
||
1626 | * @psalm-mutation-free |
||
1627 | */ |
||
1628 | 1 | public function customSortKeysImmutable(callable $function): self |
|
1638 | |||
1639 | /** |
||
1640 | * Custom sort by value via "usort". |
||
1641 | * |
||
1642 | * @see http://php.net/manual/en/function.usort.php |
||
1643 | * |
||
1644 | * @param callable $function |
||
1645 | * |
||
1646 | * @throws \InvalidArgumentException |
||
1647 | * |
||
1648 | * @return $this |
||
1649 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1650 | * |
||
1651 | * @psalm-return static<TKey,T> |
||
1652 | */ |
||
1653 | 10 | View Code Duplication | public function customSortValues($function): self |
1665 | |||
1666 | /** |
||
1667 | * Custom sort by value via "usort". |
||
1668 | * |
||
1669 | * @see http://php.net/manual/en/function.usort.php |
||
1670 | * |
||
1671 | * @param callable $function |
||
1672 | * |
||
1673 | * @throws \InvalidArgumentException |
||
1674 | * |
||
1675 | * @return $this |
||
1676 | * <p>(Immutable) Return this Arrayy object.</p> |
||
1677 | * |
||
1678 | * @psalm-return static<TKey,T> |
||
1679 | * @psalm-mutation-free |
||
1680 | */ |
||
1681 | 4 | public function customSortValuesImmutable($function): self |
|
1692 | |||
1693 | /** |
||
1694 | * Delete the given key or keys. |
||
1695 | * |
||
1696 | * @param int|int[]|string|string[] $keyOrKeys |
||
1697 | * |
||
1698 | * @return void |
||
1699 | */ |
||
1700 | 4 | public function delete($keyOrKeys) |
|
1708 | |||
1709 | /** |
||
1710 | * Return values that are only in the current array. |
||
1711 | * |
||
1712 | * @param array ...$array |
||
1713 | * |
||
1714 | * @return static |
||
1715 | * <p>(Immutable)</p> |
||
1716 | * |
||
1717 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
1718 | * @psalm-return static<TKey,T> |
||
1719 | * @psalm-mutation-free |
||
1720 | */ |
||
1721 | 13 | public function diff(...$array): self |
|
1729 | |||
1730 | /** |
||
1731 | * Return values that are only in the current array. |
||
1732 | * |
||
1733 | * @param array ...$array |
||
1734 | * |
||
1735 | * @return static |
||
1736 | * <p>(Immutable)</p> |
||
1737 | * |
||
1738 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
1739 | * @psalm-return static<TKey,T> |
||
1740 | * @psalm-mutation-free |
||
1741 | */ |
||
1742 | 8 | public function diffKey(...$array): self |
|
1750 | |||
1751 | /** |
||
1752 | * Return values and Keys that are only in the current array. |
||
1753 | * |
||
1754 | * @param array $array |
||
1755 | * |
||
1756 | * @return static |
||
1757 | * <p>(Immutable)</p> |
||
1758 | * |
||
1759 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1760 | * @psalm-return static<TKey,T> |
||
1761 | * @psalm-mutation-free |
||
1762 | */ |
||
1763 | 8 | public function diffKeyAndValue(array $array = []): self |
|
1771 | |||
1772 | /** |
||
1773 | * Return values that are only in the current multi-dimensional array. |
||
1774 | * |
||
1775 | * @param array $array |
||
1776 | * @param array|\Generator|null $helperVariableForRecursion <p>(only for internal usage)</p> |
||
1777 | * |
||
1778 | * @return static |
||
1779 | * <p>(Immutable)</p> |
||
1780 | * |
||
1781 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1782 | * @psalm-param null|array<TKey,T>|\Generator<TKey,T> $helperVariableForRecursion |
||
1783 | * @psalm-return static<TKey,T> |
||
1784 | * @psalm-mutation-free |
||
1785 | */ |
||
1786 | 1 | public function diffRecursive(array $array = [], $helperVariableForRecursion = null): self |
|
1821 | |||
1822 | /** |
||
1823 | * Return values that are only in the new $array. |
||
1824 | * |
||
1825 | * @param array $array |
||
1826 | * |
||
1827 | * @return static |
||
1828 | * <p>(Immutable)</p> |
||
1829 | * |
||
1830 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1831 | * @psalm-return static<TKey,T> |
||
1832 | * @psalm-mutation-free |
||
1833 | */ |
||
1834 | 8 | public function diffReverse(array $array = []): self |
|
1842 | |||
1843 | /** |
||
1844 | * Divide an array into two arrays. One with keys and the other with values. |
||
1845 | * |
||
1846 | * @return static |
||
1847 | * <p>(Immutable)</p> |
||
1848 | * |
||
1849 | * @psalm-return static<TKey,T> |
||
1850 | * @psalm-mutation-free |
||
1851 | */ |
||
1852 | 1 | public function divide(): self |
|
1863 | |||
1864 | /** |
||
1865 | * Iterate over the current array and modify the array's value. |
||
1866 | * |
||
1867 | * @param \Closure $closure |
||
1868 | * |
||
1869 | * @return static |
||
1870 | * <p>(Immutable)</p> |
||
1871 | * |
||
1872 | * @psalm-return static<TKey,T> |
||
1873 | * @psalm-mutation-free |
||
1874 | */ |
||
1875 | 5 | View Code Duplication | public function each(\Closure $closure): self |
1890 | |||
1891 | /** |
||
1892 | * Sets the internal iterator to the last element in the array and returns this element. |
||
1893 | * |
||
1894 | * @return mixed |
||
1895 | */ |
||
1896 | public function end() |
||
1900 | |||
1901 | /** |
||
1902 | * Check if a value is in the current array using a closure. |
||
1903 | * |
||
1904 | * @param \Closure $closure |
||
1905 | * |
||
1906 | * @return bool |
||
1907 | * <p>Returns true if the given value is found, false otherwise.</p> |
||
1908 | */ |
||
1909 | 4 | public function exists(\Closure $closure): bool |
|
1924 | |||
1925 | /** |
||
1926 | * Fill the array until "$num" with "$default" values. |
||
1927 | * |
||
1928 | * @param int $num |
||
1929 | * @param mixed $default |
||
1930 | * |
||
1931 | * @return static |
||
1932 | * <p>(Immutable)</p> |
||
1933 | * |
||
1934 | * @psalm-return static<TKey,T> |
||
1935 | * @psalm-mutation-free |
||
1936 | */ |
||
1937 | 8 | public function fillWithDefaults(int $num, $default = null): self |
|
1960 | |||
1961 | /** |
||
1962 | * Find all items in an array that pass the truth test. |
||
1963 | * |
||
1964 | * @param \Closure|null $closure [optional] <p> |
||
1965 | * The callback function to use |
||
1966 | * </p> |
||
1967 | * <p> |
||
1968 | * If no callback is supplied, all entries of |
||
1969 | * input equal to false (see |
||
1970 | * converting to |
||
1971 | * boolean) will be removed. |
||
1972 | * </p> |
||
1973 | * @param int $flag [optional] <p> |
||
1974 | * Flag determining what arguments are sent to <i>callback</i>: |
||
1975 | * </p><ul> |
||
1976 | * <li> |
||
1977 | * <b>ARRAY_FILTER_USE_KEY</b> [1] - pass key as the only argument |
||
1978 | * to <i>callback</i> instead of the value</span> |
||
1979 | * </li> |
||
1980 | * <li> |
||
1981 | * <b>ARRAY_FILTER_USE_BOTH</b> [2] - pass both value and key as |
||
1982 | * arguments to <i>callback</i> instead of the value</span> |
||
1983 | * </li> |
||
1984 | * </ul> |
||
1985 | * |
||
1986 | * @return static |
||
1987 | * <p>(Immutable)</p> |
||
1988 | * |
||
1989 | * @psalm-param \Closure(T=,TKey=):bool|\Closure(T=):bool $closure |
||
1990 | * @psalm-return static<TKey,T> |
||
1991 | * @psalm-mutation-free |
||
1992 | */ |
||
1993 | 12 | public function filter($closure = null, int $flag = \ARRAY_FILTER_USE_BOTH) |
|
2005 | |||
2006 | /** |
||
2007 | * Filters an array of objects (or a numeric array of associative arrays) based on the value of a particular |
||
2008 | * property within that. |
||
2009 | * |
||
2010 | * @param string $property |
||
2011 | * @param string|string[] $value |
||
2012 | * @param string $comparisonOp |
||
2013 | * <p> |
||
2014 | * 'eq' (equals),<br /> |
||
2015 | * 'gt' (greater),<br /> |
||
2016 | * 'gte' || 'ge' (greater or equals),<br /> |
||
2017 | * 'lt' (less),<br /> |
||
2018 | * 'lte' || 'le' (less or equals),<br /> |
||
2019 | * 'ne' (not equals),<br /> |
||
2020 | * 'contains',<br /> |
||
2021 | * 'notContains',<br /> |
||
2022 | * 'newer' (via strtotime),<br /> |
||
2023 | * 'older' (via strtotime),<br /> |
||
2024 | * </p> |
||
2025 | * |
||
2026 | * @return static |
||
2027 | * <p>(Immutable)</p> |
||
2028 | * |
||
2029 | * @psalm-return static<TKey,T> |
||
2030 | * @psalm-mutation-free |
||
2031 | * |
||
2032 | * @psalm-suppress MissingClosureReturnType |
||
2033 | * @psalm-suppress MissingClosureParamType |
||
2034 | */ |
||
2035 | 1 | public function filterBy( |
|
2107 | |||
2108 | /** |
||
2109 | * Find the first item in an array that passes the truth test, |
||
2110 | * otherwise return false |
||
2111 | * |
||
2112 | * @param \Closure $closure |
||
2113 | * |
||
2114 | * @return false|mixed |
||
2115 | * <p>Return false if we did not find the value.</p> |
||
2116 | */ |
||
2117 | 8 | View Code Duplication | public function find(\Closure $closure) |
2127 | |||
2128 | /** |
||
2129 | * find by ... |
||
2130 | * |
||
2131 | * @param string $property |
||
2132 | * @param string|string[] $value |
||
2133 | * @param string $comparisonOp |
||
2134 | * |
||
2135 | * @return static |
||
2136 | * <p>(Immutable)</p> |
||
2137 | * |
||
2138 | * @psalm-return static<TKey,T> |
||
2139 | * @psalm-mutation-free |
||
2140 | */ |
||
2141 | 1 | public function findBy(string $property, $value, string $comparisonOp = 'eq'): self |
|
2145 | |||
2146 | /** |
||
2147 | * Get the first value from the current array. |
||
2148 | * |
||
2149 | * @return mixed |
||
2150 | * <p>Return null if there wasn't a element.</p> |
||
2151 | */ |
||
2152 | 21 | public function first() |
|
2161 | |||
2162 | /** |
||
2163 | * Get the first key from the current array. |
||
2164 | * |
||
2165 | * @return mixed |
||
2166 | * <p>Return null if there wasn't a element.</p> |
||
2167 | * @psalm-mutation-free |
||
2168 | */ |
||
2169 | 28 | public function firstKey() |
|
2175 | |||
2176 | /** |
||
2177 | * Get the first value(s) from the current array. |
||
2178 | * And will return an empty array if there was no first entry. |
||
2179 | * |
||
2180 | * @param int|null $number <p>How many values you will take?</p> |
||
2181 | * |
||
2182 | * @return static |
||
2183 | * <p>(Immutable)</p> |
||
2184 | * |
||
2185 | * @psalm-return static<TKey,T> |
||
2186 | * @psalm-mutation-free |
||
2187 | */ |
||
2188 | 37 | View Code Duplication | public function firstsImmutable(int $number = null): self |
2205 | |||
2206 | /** |
||
2207 | * Get the first value(s) from the current array. |
||
2208 | * And will return an empty array if there was no first entry. |
||
2209 | * |
||
2210 | * @param int|null $number <p>How many values you will take?</p> |
||
2211 | * |
||
2212 | * @return static |
||
2213 | * <p>(Immutable)</p> |
||
2214 | * |
||
2215 | * @psalm-return static<TKey,T> |
||
2216 | * @psalm-mutation-free |
||
2217 | */ |
||
2218 | 3 | View Code Duplication | public function firstsKeys(int $number = null): self |
2235 | |||
2236 | /** |
||
2237 | * Get and rmove the first value(s) from the current array. |
||
2238 | * And will return an empty array if there was no first entry. |
||
2239 | * |
||
2240 | * @param int|null $number <p>How many values you will take?</p> |
||
2241 | * |
||
2242 | * @return $this |
||
2243 | * <p>(Mutable)</p> |
||
2244 | * |
||
2245 | * @psalm-return static<TKey,T> |
||
2246 | */ |
||
2247 | 34 | public function firstsMutable(int $number = null): self |
|
2260 | |||
2261 | /** |
||
2262 | * Exchanges all keys with their associated values in an array. |
||
2263 | * |
||
2264 | * @return static |
||
2265 | * <p>(Immutable)</p> |
||
2266 | * |
||
2267 | * @psalm-return static<TKey,T> |
||
2268 | * @psalm-mutation-free |
||
2269 | */ |
||
2270 | 1 | public function flip(): self |
|
2278 | |||
2279 | /** |
||
2280 | * Get a value from an array (optional using dot-notation). |
||
2281 | * |
||
2282 | * @param mixed $key <p>The key to look for.</p> |
||
2283 | * @param mixed $fallback <p>Value to fallback to.</p> |
||
2284 | * @param array $array <p>The array to get from, if it's set to "null" we use the current array from the |
||
2285 | * class.</p> |
||
2286 | * |
||
2287 | * @return mixed|static |
||
2288 | * |
||
2289 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
2290 | * @psalm-mutation-free |
||
2291 | */ |
||
2292 | 172 | public function get($key, $fallback = null, array $array = null) |
|
2384 | |||
2385 | /** |
||
2386 | * alias: for "Arrayy->toArray()" |
||
2387 | * |
||
2388 | * @return array |
||
2389 | * |
||
2390 | * @see Arrayy::getArray() |
||
2391 | * |
||
2392 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
2393 | */ |
||
2394 | 1 | public function getAll(): array |
|
2398 | |||
2399 | /** |
||
2400 | * Get the current array from the "Arrayy"-object. |
||
2401 | * |
||
2402 | * alias for "toArray()" |
||
2403 | * |
||
2404 | * @param bool $convertAllArrayyElements <p> |
||
2405 | * Convert all Child-"Arrayy" objects also to arrays. |
||
2406 | * </p> |
||
2407 | * @param bool $preserveKeys <p> |
||
2408 | * e.g.: A generator maybe return the same key more then once, |
||
2409 | * so maybe you will ignore the keys. |
||
2410 | * </p> |
||
2411 | * |
||
2412 | * @return array |
||
2413 | * |
||
2414 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
2415 | * @psalm-mutation-free |
||
2416 | * |
||
2417 | * @see Arrayy::toArray() |
||
2418 | */ |
||
2419 | 481 | public function getArray( |
|
2428 | |||
2429 | /** |
||
2430 | * Get the current array from the "Arrayy"-object as list. |
||
2431 | * |
||
2432 | * alias for "toList()" |
||
2433 | * |
||
2434 | * @param bool $convertAllArrayyElements <p> |
||
2435 | * Convert all Child-"Arrayy" objects also to arrays. |
||
2436 | * </p> |
||
2437 | * |
||
2438 | * @return array |
||
2439 | * |
||
2440 | * @psalm-return array<int,mixed>|array<int,T> |
||
2441 | * @psalm-mutation-free |
||
2442 | * |
||
2443 | * @see Arrayy::toList() |
||
2444 | */ |
||
2445 | 1 | public function getList(bool $convertAllArrayyElements = false): array |
|
2449 | |||
2450 | /** |
||
2451 | * Returns the values from a single column of the input array, identified by |
||
2452 | * the $columnKey, can be used to extract data-columns from multi-arrays. |
||
2453 | * |
||
2454 | * Info: Optionally, you may provide an $indexKey to index the values in the returned |
||
2455 | * array by the values from the $indexKey column in the input array. |
||
2456 | * |
||
2457 | * @param mixed $columnKey |
||
2458 | * @param mixed $indexKey |
||
2459 | * |
||
2460 | * @return static |
||
2461 | * <p>(Immutable)</p> |
||
2462 | * |
||
2463 | * @psalm-return static<TKey,T> |
||
2464 | * @psalm-mutation-free |
||
2465 | */ |
||
2466 | 1 | public function getColumn($columnKey = null, $indexKey = null): self |
|
2474 | |||
2475 | /** |
||
2476 | * Get the current array from the "Arrayy"-object as generator. |
||
2477 | * |
||
2478 | * @return \Generator |
||
2479 | * |
||
2480 | * @psalm-return \Generator<mixed,T>|\Generator<TKey,T> |
||
2481 | * @psalm-mutation-free |
||
2482 | */ |
||
2483 | 976 | public function getGenerator(): \Generator |
|
2491 | |||
2492 | /** |
||
2493 | * alias: for "Arrayy->keys()" |
||
2494 | * |
||
2495 | * @return static |
||
2496 | * <p>(Immutable)</p> |
||
2497 | * |
||
2498 | * @see Arrayy::keys() |
||
2499 | * |
||
2500 | * @psalm-return static<array-key,TKey> |
||
2501 | * @psalm-mutation-free |
||
2502 | */ |
||
2503 | 2 | public function getKeys() |
|
2507 | |||
2508 | /** |
||
2509 | * Get the current array from the "Arrayy"-object as object. |
||
2510 | * |
||
2511 | * @return \stdClass |
||
2512 | */ |
||
2513 | 4 | public function getObject(): \stdClass |
|
2517 | |||
2518 | /** |
||
2519 | * alias: for "Arrayy->randomImmutable()" |
||
2520 | * |
||
2521 | * @return static |
||
2522 | * <p>(Immutable)</p> |
||
2523 | * |
||
2524 | * @see Arrayy::randomImmutable() |
||
2525 | * |
||
2526 | * @psalm-return static<int|array-key,T> |
||
2527 | */ |
||
2528 | 4 | public function getRandom(): self |
|
2532 | |||
2533 | /** |
||
2534 | * alias: for "Arrayy->randomKey()" |
||
2535 | * |
||
2536 | * @return mixed |
||
2537 | * <p>Get a key/index or null if there wasn't a key/index.</p> |
||
2538 | * |
||
2539 | * @see Arrayy::randomKey() |
||
2540 | */ |
||
2541 | 3 | public function getRandomKey() |
|
2545 | |||
2546 | /** |
||
2547 | * alias: for "Arrayy->randomKeys()" |
||
2548 | * |
||
2549 | * @param int $number |
||
2550 | * |
||
2551 | * @return static |
||
2552 | * <p>(Immutable)</p> |
||
2553 | * |
||
2554 | * @see Arrayy::randomKeys() |
||
2555 | * |
||
2556 | * @psalm-return static<TKey,T> |
||
2557 | */ |
||
2558 | 8 | public function getRandomKeys(int $number): self |
|
2562 | |||
2563 | /** |
||
2564 | * alias: for "Arrayy->randomValue()" |
||
2565 | * |
||
2566 | * @return mixed |
||
2567 | * <p>Get a random value or null if there wasn't a value.</p> |
||
2568 | * |
||
2569 | * @see Arrayy::randomValue() |
||
2570 | */ |
||
2571 | 3 | public function getRandomValue() |
|
2575 | |||
2576 | /** |
||
2577 | * alias: for "Arrayy->randomValues()" |
||
2578 | * |
||
2579 | * @param int $number |
||
2580 | * |
||
2581 | * @return static |
||
2582 | * <p>(Immutable)</p> |
||
2583 | * |
||
2584 | * @see Arrayy::randomValues() |
||
2585 | * |
||
2586 | * @psalm-return static<TKey,T> |
||
2587 | */ |
||
2588 | 6 | public function getRandomValues(int $number): self |
|
2592 | |||
2593 | /** |
||
2594 | * Gets all values. |
||
2595 | * |
||
2596 | * @return static |
||
2597 | * <p>The values of all elements in this array, in the order they |
||
2598 | * appear in the array.</p> |
||
2599 | * |
||
2600 | * @psalm-return static<TKey,T> |
||
2601 | */ |
||
2602 | 4 | public function getValues() |
|
2612 | |||
2613 | /** |
||
2614 | * Gets all values via Generator. |
||
2615 | * |
||
2616 | * @return \Generator |
||
2617 | * <p>The values of all elements in this array, in the order they |
||
2618 | * appear in the array as Generator.</p> |
||
2619 | * |
||
2620 | * @psalm-return \Generator<TKey,T> |
||
2621 | */ |
||
2622 | 4 | public function getValuesYield(): \Generator |
|
2626 | |||
2627 | /** |
||
2628 | * Group values from a array according to the results of a closure. |
||
2629 | * |
||
2630 | * @param callable|string $grouper <p>A callable function name.</p> |
||
2631 | * @param bool $saveKeys |
||
2632 | * |
||
2633 | * @return static |
||
2634 | * <p>(Immutable)</p> |
||
2635 | * |
||
2636 | * @psalm-return static<TKey,T> |
||
2637 | * @psalm-mutation-free |
||
2638 | */ |
||
2639 | 4 | public function group($grouper, bool $saveKeys = false): self |
|
2680 | |||
2681 | /** |
||
2682 | * Check if an array has a given key. |
||
2683 | * |
||
2684 | * @param mixed $key |
||
2685 | * |
||
2686 | * @return bool |
||
2687 | */ |
||
2688 | 23 | public function has($key): bool |
|
2699 | |||
2700 | /** |
||
2701 | * Check if an array has a given value. |
||
2702 | * |
||
2703 | * INFO: if you need to search recursive please use ```contains()``` |
||
2704 | * |
||
2705 | * @param mixed $value |
||
2706 | * |
||
2707 | * @return bool |
||
2708 | */ |
||
2709 | 1 | public function hasValue($value): bool |
|
2713 | |||
2714 | /** |
||
2715 | * Implodes the values of this array. |
||
2716 | * |
||
2717 | * @param string $glue |
||
2718 | * |
||
2719 | * @return string |
||
2720 | */ |
||
2721 | 28 | public function implode(string $glue = ''): string |
|
2725 | |||
2726 | /** |
||
2727 | * Implodes the keys of this array. |
||
2728 | * |
||
2729 | * @param string $glue |
||
2730 | * |
||
2731 | * @return string |
||
2732 | */ |
||
2733 | 8 | public function implodeKeys(string $glue = ''): string |
|
2737 | |||
2738 | /** |
||
2739 | * Given a list and an iterate-function that returns |
||
2740 | * a key for each element in the list (or a property name), |
||
2741 | * returns an object with an index of each item. |
||
2742 | * |
||
2743 | * @param mixed $key |
||
2744 | * |
||
2745 | * @return static |
||
2746 | * <p>(Immutable)</p> |
||
2747 | * |
||
2748 | * @psalm-return static<TKey,T> |
||
2749 | * @psalm-mutation-free |
||
2750 | */ |
||
2751 | 4 | public function indexBy($key): self |
|
2768 | |||
2769 | /** |
||
2770 | * alias: for "Arrayy->searchIndex()" |
||
2771 | * |
||
2772 | * @param mixed $value <p>The value to search for.</p> |
||
2773 | * |
||
2774 | * @return false|mixed |
||
2775 | * |
||
2776 | * @see Arrayy::searchIndex() |
||
2777 | */ |
||
2778 | 4 | public function indexOf($value) |
|
2782 | |||
2783 | /** |
||
2784 | * Get everything but the last..$to items. |
||
2785 | * |
||
2786 | * @param int $to |
||
2787 | * |
||
2788 | * @return static |
||
2789 | * <p>(Immutable)</p> |
||
2790 | * |
||
2791 | * @psalm-return static<TKey,T> |
||
2792 | * @psalm-mutation-free |
||
2793 | */ |
||
2794 | 12 | public function initial(int $to = 1): self |
|
2798 | |||
2799 | /** |
||
2800 | * Return an array with all elements found in input array. |
||
2801 | * |
||
2802 | * @param array $search |
||
2803 | * @param bool $keepKeys |
||
2804 | * |
||
2805 | * @return static |
||
2806 | * <p>(Immutable)</p> |
||
2807 | * |
||
2808 | * @psalm-param array<mixed,mixed>|array<TKey,T> $search |
||
2809 | * @psalm-return static<TKey,T> |
||
2810 | * @psalm-mutation-free |
||
2811 | */ |
||
2812 | 4 | public function intersection(array $search, bool $keepKeys = false): self |
|
2838 | |||
2839 | /** |
||
2840 | * Return an array with all elements found in input array. |
||
2841 | * |
||
2842 | * @param array ...$array |
||
2843 | * |
||
2844 | * @return static |
||
2845 | * <p>(Immutable)</p> |
||
2846 | * |
||
2847 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
2848 | * @psalm-return static<TKey,T> |
||
2849 | * @psalm-mutation-free |
||
2850 | */ |
||
2851 | 1 | public function intersectionMulti(...$array): self |
|
2859 | |||
2860 | /** |
||
2861 | * Return a boolean flag which indicates whether the two input arrays have any common elements. |
||
2862 | * |
||
2863 | * @param array $search |
||
2864 | * |
||
2865 | * @return bool |
||
2866 | * |
||
2867 | * @psalm-param array<mixed,mixed>|array<TKey,T> $search |
||
2868 | */ |
||
2869 | 1 | public function intersects(array $search): bool |
|
2873 | |||
2874 | /** |
||
2875 | * Invoke a function on all of an array's values. |
||
2876 | * |
||
2877 | * @param callable $callable |
||
2878 | * @param mixed $arguments |
||
2879 | * |
||
2880 | * @return static |
||
2881 | * <p>(Immutable)</p> |
||
2882 | * |
||
2883 | * @psalm-param callable(T=,mixed):mixed $callable |
||
2884 | * @psalm-return static<TKey,T> |
||
2885 | * @psalm-mutation-free |
||
2886 | */ |
||
2887 | 1 | public function invoke($callable, $arguments = []): self |
|
2911 | |||
2912 | /** |
||
2913 | * Check whether array is associative or not. |
||
2914 | * |
||
2915 | * @param bool $recursive |
||
2916 | * |
||
2917 | * @return bool |
||
2918 | * <p>Returns true if associative, false otherwise.</p> |
||
2919 | */ |
||
2920 | 15 | View Code Duplication | public function isAssoc(bool $recursive = false): bool |
2934 | |||
2935 | /** |
||
2936 | * Check if a given key or keys are empty. |
||
2937 | * |
||
2938 | * @param int|int[]|string|string[]|null $keys |
||
2939 | * |
||
2940 | * @return bool |
||
2941 | * <p>Returns true if empty, false otherwise.</p> |
||
2942 | * @psalm-mutation-free |
||
2943 | */ |
||
2944 | 38 | public function isEmpty($keys = null): bool |
|
2962 | |||
2963 | /** |
||
2964 | * Check if the current array is equal to the given "$array" or not. |
||
2965 | * |
||
2966 | * @param array $array |
||
2967 | * |
||
2968 | * @return bool |
||
2969 | * |
||
2970 | * @psalm-param array<mixed,mixed> $array |
||
2971 | */ |
||
2972 | 1 | public function isEqual(array $array): bool |
|
2976 | |||
2977 | /** |
||
2978 | * Check if the current array is a multi-array. |
||
2979 | * |
||
2980 | * @return bool |
||
2981 | */ |
||
2982 | 22 | public function isMultiArray(): bool |
|
2990 | |||
2991 | /** |
||
2992 | * Check whether array is numeric or not. |
||
2993 | * |
||
2994 | * @return bool |
||
2995 | * <p>Returns true if numeric, false otherwise.</p> |
||
2996 | */ |
||
2997 | 5 | View Code Duplication | public function isNumeric(): bool |
3011 | |||
3012 | /** |
||
3013 | * Check if the current array is sequential [0, 1, 2, 3, 4, 5 ...] or not. |
||
3014 | * |
||
3015 | * @param bool $recursive |
||
3016 | * |
||
3017 | * @return bool |
||
3018 | * @psalm-mutation-free |
||
3019 | */ |
||
3020 | 9 | public function isSequential(bool $recursive = false): bool |
|
3037 | |||
3038 | /** |
||
3039 | * @return array |
||
3040 | * |
||
3041 | * @psalm-return array<TKey,T> |
||
3042 | */ |
||
3043 | public function jsonSerialize(): array |
||
3047 | |||
3048 | /** |
||
3049 | * Gets the key/index of the element at the current internal iterator position. |
||
3050 | * |
||
3051 | * @return int|string|null |
||
3052 | */ |
||
3053 | public function key() |
||
3057 | |||
3058 | /** |
||
3059 | * Checks if the given key exists in the provided array. |
||
3060 | * |
||
3061 | * INFO: This method only use "array_key_exists()" if you want to use "dot"-notation, |
||
3062 | * then you need to use "Arrayy->offsetExists()". |
||
3063 | * |
||
3064 | * @param int|string $key the key to look for |
||
3065 | * |
||
3066 | * @return bool |
||
3067 | */ |
||
3068 | 127 | public function keyExists($key): bool |
|
3072 | |||
3073 | /** |
||
3074 | * Get all keys from the current array. |
||
3075 | * |
||
3076 | * @param bool $recursive [optional] <p> |
||
3077 | * Get all keys, also from all sub-arrays from an multi-dimensional array. |
||
3078 | * </p> |
||
3079 | * @param mixed|null $search_values [optional] <p> |
||
3080 | * If specified, then only keys containing these values are returned. |
||
3081 | * </p> |
||
3082 | * @param bool $strict [optional] <p> |
||
3083 | * Determines if strict comparison (===) should be used during the search. |
||
3084 | * </p> |
||
3085 | * |
||
3086 | * @return static |
||
3087 | * <p>(Immutable) An array of all the keys in input.</p> |
||
3088 | * |
||
3089 | * @psalm-return static<array-key,TKey> |
||
3090 | * @psalm-mutation-free |
||
3091 | */ |
||
3092 | 29 | public function keys( |
|
3162 | |||
3163 | /** |
||
3164 | * Sort an array by key in reverse order. |
||
3165 | * |
||
3166 | * @param int $sort_flags [optional] <p> |
||
3167 | * You may modify the behavior of the sort using the optional |
||
3168 | * parameter sort_flags, for details |
||
3169 | * see sort. |
||
3170 | * </p> |
||
3171 | * |
||
3172 | * @return $this |
||
3173 | * <p>(Mutable) Return this Arrayy object.</p> |
||
3174 | * |
||
3175 | * @psalm-return static<TKey,T> |
||
3176 | */ |
||
3177 | 4 | public function krsort(int $sort_flags = 0): self |
|
3185 | |||
3186 | /** |
||
3187 | * Sort an array by key in reverse order. |
||
3188 | * |
||
3189 | * @param int $sort_flags [optional] <p> |
||
3190 | * You may modify the behavior of the sort using the optional |
||
3191 | * parameter sort_flags, for details |
||
3192 | * see sort. |
||
3193 | * </p> |
||
3194 | * |
||
3195 | * @return $this |
||
3196 | * <p>(Immutable) Return this Arrayy object.</p> |
||
3197 | * |
||
3198 | * @psalm-return static<TKey,T> |
||
3199 | * @psalm-mutation-free |
||
3200 | */ |
||
3201 | 4 | public function krsortImmutable(int $sort_flags = 0): self |
|
3212 | |||
3213 | /** |
||
3214 | * Get the last value from the current array. |
||
3215 | * |
||
3216 | * @return mixed|null |
||
3217 | * <p>Return null if there wasn't a element.</p> |
||
3218 | * @psalm-mutation-free |
||
3219 | */ |
||
3220 | 17 | public function last() |
|
3229 | |||
3230 | /** |
||
3231 | * Get the last key from the current array. |
||
3232 | * |
||
3233 | * @return mixed|null |
||
3234 | * <p>Return null if there wasn't a element.</p> |
||
3235 | * @psalm-mutation-free |
||
3236 | */ |
||
3237 | 21 | public function lastKey() |
|
3243 | |||
3244 | /** |
||
3245 | * Get the last value(s) from the current array. |
||
3246 | * |
||
3247 | * @param int|null $number |
||
3248 | * |
||
3249 | * @return static |
||
3250 | * <p>(Immutable)</p> |
||
3251 | * |
||
3252 | * @psalm-return static<TKey,T> |
||
3253 | * @psalm-mutation-free |
||
3254 | */ |
||
3255 | 13 | public function lastsImmutable(int $number = null): self |
|
3286 | |||
3287 | /** |
||
3288 | * Get the last value(s) from the current array. |
||
3289 | * |
||
3290 | * @param int|null $number |
||
3291 | * |
||
3292 | * @return $this |
||
3293 | * <p>(Mutable)</p> |
||
3294 | * |
||
3295 | * @psalm-return static<TKey,T> |
||
3296 | */ |
||
3297 | 13 | public function lastsMutable(int $number = null): self |
|
3326 | |||
3327 | /** |
||
3328 | * Count the values from the current array. |
||
3329 | * |
||
3330 | * alias: for "Arrayy->count()" |
||
3331 | * |
||
3332 | * @param int $mode |
||
3333 | * |
||
3334 | * @return int |
||
3335 | * |
||
3336 | * @see Arrayy::count() |
||
3337 | */ |
||
3338 | 20 | public function length(int $mode = \COUNT_NORMAL): int |
|
3342 | |||
3343 | /** |
||
3344 | * Apply the given function to the every element of the array, |
||
3345 | * collecting the results. |
||
3346 | * |
||
3347 | * @param callable $callable |
||
3348 | * @param bool $useKeyAsSecondParameter |
||
3349 | * @param mixed ...$arguments |
||
3350 | * |
||
3351 | * @return static |
||
3352 | * <p>(Immutable) Arrayy object with modified elements.</p> |
||
3353 | * |
||
3354 | * @psalm-param callable(T,TKey=,mixed=):mixed $callable |
||
3355 | * @psalm-return static<TKey,T> |
||
3356 | * @psalm-mutation-free |
||
3357 | */ |
||
3358 | 5 | public function map( |
|
3391 | |||
3392 | /** |
||
3393 | * Check if all items in current array match a truth test. |
||
3394 | * |
||
3395 | * @param \Closure $closure |
||
3396 | * |
||
3397 | * @return bool |
||
3398 | */ |
||
3399 | 15 | View Code Duplication | public function matches(\Closure $closure): bool |
3415 | |||
3416 | /** |
||
3417 | * Check if any item in the current array matches a truth test. |
||
3418 | * |
||
3419 | * @param \Closure $closure |
||
3420 | * |
||
3421 | * @return bool |
||
3422 | */ |
||
3423 | 14 | View Code Duplication | public function matchesAny(\Closure $closure): bool |
3439 | |||
3440 | /** |
||
3441 | * Get the max value from an array. |
||
3442 | * |
||
3443 | * @return false|mixed |
||
3444 | * <p>Will return false if there are no values.</p> |
||
3445 | */ |
||
3446 | 10 | View Code Duplication | public function max() |
3465 | |||
3466 | /** |
||
3467 | * Merge the new $array into the current array. |
||
3468 | * |
||
3469 | * - keep key,value from the current array, also if the index is in the new $array |
||
3470 | * |
||
3471 | * @param array $array |
||
3472 | * @param bool $recursive |
||
3473 | * |
||
3474 | * @return static |
||
3475 | * <p>(Immutable)</p> |
||
3476 | * |
||
3477 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3478 | * @psalm-return static<int|TKey,T> |
||
3479 | * @psalm-mutation-free |
||
3480 | */ |
||
3481 | 25 | View Code Duplication | public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self |
3495 | |||
3496 | /** |
||
3497 | * Merge the new $array into the current array. |
||
3498 | * |
||
3499 | * - replace duplicate assoc-keys from the current array with the key,values from the new $array |
||
3500 | * - create new indexes |
||
3501 | * |
||
3502 | * @param array $array |
||
3503 | * @param bool $recursive |
||
3504 | * |
||
3505 | * @return static |
||
3506 | * <p>(Immutable)</p> |
||
3507 | * |
||
3508 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3509 | * @psalm-return static<TKey,T> |
||
3510 | * @psalm-mutation-free |
||
3511 | */ |
||
3512 | 16 | View Code Duplication | public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self |
3526 | |||
3527 | /** |
||
3528 | * Merge the the current array into the $array. |
||
3529 | * |
||
3530 | * - use key,value from the new $array, also if the index is in the current array |
||
3531 | * |
||
3532 | * @param array $array |
||
3533 | * @param bool $recursive |
||
3534 | * |
||
3535 | * @return static |
||
3536 | * <p>(Immutable)</p> |
||
3537 | * |
||
3538 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3539 | * @psalm-return static<TKey,T> |
||
3540 | * @psalm-mutation-free |
||
3541 | */ |
||
3542 | 16 | View Code Duplication | public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self |
3556 | |||
3557 | /** |
||
3558 | * Merge the current array into the new $array. |
||
3559 | * |
||
3560 | * - replace duplicate assoc-keys from new $array with the key,values from the current array |
||
3561 | * - create new indexes |
||
3562 | * |
||
3563 | * @param array $array |
||
3564 | * @param bool $recursive |
||
3565 | * |
||
3566 | * @return static |
||
3567 | * <p>(Immutable)</p> |
||
3568 | * |
||
3569 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3570 | * @psalm-return static<TKey,T> |
||
3571 | * @psalm-mutation-free |
||
3572 | */ |
||
3573 | 17 | View Code Duplication | public function mergePrependNewIndex(array $array = [], bool $recursive = false): self |
3587 | |||
3588 | /** |
||
3589 | * @return ArrayyMeta|static |
||
3590 | */ |
||
3591 | 15 | public static function meta() |
|
3595 | |||
3596 | /** |
||
3597 | * Get the min value from an array. |
||
3598 | * |
||
3599 | * @return false|mixed |
||
3600 | * <p>Will return false if there are no values.</p> |
||
3601 | */ |
||
3602 | 10 | View Code Duplication | public function min() |
3621 | |||
3622 | /** |
||
3623 | * Get the most used value from the array. |
||
3624 | * |
||
3625 | * @return mixed|null |
||
3626 | * <p>(Immutable) Return null if there wasn't a element.</p> |
||
3627 | * @psalm-mutation-free |
||
3628 | */ |
||
3629 | 3 | public function mostUsedValue() |
|
3633 | |||
3634 | /** |
||
3635 | * Get the most used value from the array. |
||
3636 | * |
||
3637 | * @param int|null $number <p>How many values you will take?</p> |
||
3638 | * |
||
3639 | * @return static |
||
3640 | * <p>(Immutable)</p> |
||
3641 | * |
||
3642 | * @psalm-return static<TKey,T> |
||
3643 | * @psalm-mutation-free |
||
3644 | */ |
||
3645 | 3 | public function mostUsedValues(int $number = null): self |
|
3649 | |||
3650 | /** |
||
3651 | * Move an array element to a new index. |
||
3652 | * |
||
3653 | * cherry-picked from: http://stackoverflow.com/questions/12624153/move-an-array-element-to-a-new-index-in-php |
||
3654 | * |
||
3655 | * @param int|string $from |
||
3656 | * @param int $to |
||
3657 | * |
||
3658 | * @return static |
||
3659 | * <p>(Immutable)</p> |
||
3660 | * |
||
3661 | * @psalm-return static<TKey,T> |
||
3662 | * @psalm-mutation-free |
||
3663 | */ |
||
3664 | 1 | public function moveElement($from, $to): self |
|
3697 | |||
3698 | /** |
||
3699 | * Move an array element to the first place. |
||
3700 | * |
||
3701 | * INFO: Instead of "Arrayy->moveElement()" this method will NOT |
||
3702 | * loss the keys of an indexed array. |
||
3703 | * |
||
3704 | * @param int|string $key |
||
3705 | * |
||
3706 | * @return static |
||
3707 | * <p>(Immutable)</p> |
||
3708 | * |
||
3709 | * @psalm-return static<TKey,T> |
||
3710 | * @psalm-mutation-free |
||
3711 | */ |
||
3712 | 1 | View Code Duplication | public function moveElementToFirstPlace($key): self |
3728 | |||
3729 | /** |
||
3730 | * Move an array element to the last place. |
||
3731 | * |
||
3732 | * INFO: Instead of "Arrayy->moveElement()" this method will NOT |
||
3733 | * loss the keys of an indexed array. |
||
3734 | * |
||
3735 | * @param int|string $key |
||
3736 | * |
||
3737 | * @return static |
||
3738 | * <p>(Immutable)</p> |
||
3739 | * |
||
3740 | * @psalm-return static<TKey,T> |
||
3741 | * @psalm-mutation-free |
||
3742 | */ |
||
3743 | 1 | View Code Duplication | public function moveElementToLastPlace($key): self |
3759 | |||
3760 | /** |
||
3761 | * Moves the internal iterator position to the next element and returns this element. |
||
3762 | * |
||
3763 | * @return false|mixed |
||
3764 | * <p>(Mutable) Will return false if there are no values.</p> |
||
3765 | */ |
||
3766 | public function next() |
||
3770 | |||
3771 | /** |
||
3772 | * Get the next nth keys and values from the array. |
||
3773 | * |
||
3774 | * @param int $step |
||
3775 | * @param int $offset |
||
3776 | * |
||
3777 | * @return static |
||
3778 | * <p>(Immutable)</p> |
||
3779 | * |
||
3780 | * @psalm-return static<TKey,T> |
||
3781 | * @psalm-mutation-free |
||
3782 | */ |
||
3783 | 1 | public function nth(int $step, int $offset = 0): self |
|
3802 | |||
3803 | /** |
||
3804 | * Get a subset of the items from the given array. |
||
3805 | * |
||
3806 | * @param mixed[] $keys |
||
3807 | * |
||
3808 | * @return static |
||
3809 | * <p>(Immutable)</p> |
||
3810 | * |
||
3811 | * @psalm-return static<TKey,T> |
||
3812 | * @psalm-mutation-free |
||
3813 | */ |
||
3814 | 1 | public function only(array $keys): self |
|
3824 | |||
3825 | /** |
||
3826 | * Pad array to the specified size with a given value. |
||
3827 | * |
||
3828 | * @param int $size <p>Size of the result array.</p> |
||
3829 | * @param mixed $value <p>Empty value by default.</p> |
||
3830 | * |
||
3831 | * @return static |
||
3832 | * <p>(Immutable) Arrayy object padded to $size with $value.</p> |
||
3833 | * |
||
3834 | * @psalm-return static<TKey,T> |
||
3835 | * @psalm-mutation-free |
||
3836 | */ |
||
3837 | 5 | public function pad(int $size, $value): self |
|
3845 | |||
3846 | /** |
||
3847 | * Partitions this array in two array according to a predicate. |
||
3848 | * Keys are preserved in the resulting array. |
||
3849 | * |
||
3850 | * @param \Closure $closure |
||
3851 | * <p>The predicate on which to partition.</p> |
||
3852 | * |
||
3853 | * @return array<int, static> |
||
3854 | * <p>An array with two elements. The first element contains the array |
||
3855 | * of elements where the predicate returned TRUE, the second element |
||
3856 | * contains the array of elements where the predicate returned FALSE.</p> |
||
3857 | * |
||
3858 | * @psalm-return array<int, static<TKey,T>> |
||
3859 | */ |
||
3860 | 1 | public function partition(\Closure $closure): array |
|
3876 | |||
3877 | /** |
||
3878 | * Pop a specified value off the end of the current array. |
||
3879 | * |
||
3880 | * @return mixed|null |
||
3881 | * <p>(Mutable) The popped element from the current array or null if the array is e.g. empty.</p> |
||
3882 | */ |
||
3883 | 5 | public function pop() |
|
3889 | |||
3890 | /** |
||
3891 | * Prepend a (key) + value to the current array. |
||
3892 | * |
||
3893 | * @param mixed $value |
||
3894 | * @param mixed $key |
||
3895 | * |
||
3896 | * @return $this |
||
3897 | * <p>(Mutable) Return this Arrayy object, with the prepended value.</p> |
||
3898 | * |
||
3899 | * @psalm-return static<TKey,T> |
||
3900 | */ |
||
3901 | 11 | public function prepend($value, $key = null) |
|
3917 | |||
3918 | /** |
||
3919 | * Add a suffix to each key. |
||
3920 | * |
||
3921 | * @param mixed $suffix |
||
3922 | * |
||
3923 | * @return static |
||
3924 | * <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> |
||
3925 | * |
||
3926 | * @psalm-return static<TKey,T> |
||
3927 | * @psalm-mutation-free |
||
3928 | */ |
||
3929 | 10 | View Code Duplication | public function prependToEachKey($suffix): self |
3955 | |||
3956 | /** |
||
3957 | * Add a suffix to each value. |
||
3958 | * |
||
3959 | * @param mixed $suffix |
||
3960 | * |
||
3961 | * @return static |
||
3962 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
||
3963 | * |
||
3964 | * @psalm-return static<TKey,T> |
||
3965 | * @psalm-mutation-free |
||
3966 | */ |
||
3967 | 10 | View Code Duplication | public function prependToEachValue($suffix): self |
3995 | |||
3996 | /** |
||
3997 | * Return the value of a given key and |
||
3998 | * delete the key. |
||
3999 | * |
||
4000 | * @param int|int[]|string|string[]|null $keyOrKeys |
||
4001 | * @param mixed $fallback |
||
4002 | * |
||
4003 | * @return mixed |
||
4004 | */ |
||
4005 | 1 | public function pull($keyOrKeys = null, $fallback = null) |
|
4027 | |||
4028 | /** |
||
4029 | * Push one or more values onto the end of array at once. |
||
4030 | * |
||
4031 | * @param array ...$args |
||
4032 | * |
||
4033 | * @return $this |
||
4034 | * <p>(Mutable) Return this Arrayy object, with pushed elements to the end of array.</p> |
||
4035 | * |
||
4036 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
4037 | * |
||
4038 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$args |
||
4039 | * @psalm-return static<TKey,T> |
||
4040 | */ |
||
4041 | 5 | public function push(...$args) |
|
4059 | |||
4060 | /** |
||
4061 | * Get a random value from the current array. |
||
4062 | * |
||
4063 | * @param int|null $number <p>How many values you will take?</p> |
||
4064 | * |
||
4065 | * @return static |
||
4066 | * <p>(Immutable)</p> |
||
4067 | * |
||
4068 | * @psalm-return static<int|array-key,T> |
||
4069 | */ |
||
4070 | 19 | public function randomImmutable(int $number = null): self |
|
4103 | |||
4104 | /** |
||
4105 | * Pick a random key/index from the keys of this array. |
||
4106 | * |
||
4107 | * @throws \RangeException If array is empty |
||
4108 | * |
||
4109 | * @return mixed |
||
4110 | * <p>Get a key/index or null if there wasn't a key/index.</p> |
||
4111 | */ |
||
4112 | 4 | public function randomKey() |
|
4122 | |||
4123 | /** |
||
4124 | * Pick a given number of random keys/indexes out of this array. |
||
4125 | * |
||
4126 | * @param int $number <p>The number of keys/indexes (should be <= \count($this->array))</p> |
||
4127 | * |
||
4128 | * @throws \RangeException If array is empty |
||
4129 | * |
||
4130 | * @return static |
||
4131 | * <p>(Immutable)</p> |
||
4132 | * |
||
4133 | * @psalm-return static<TKey,T> |
||
4134 | */ |
||
4135 | 13 | public function randomKeys(int $number): self |
|
4163 | |||
4164 | /** |
||
4165 | * Get a random value from the current array. |
||
4166 | * |
||
4167 | * @param int|null $number <p>How many values you will take?</p> |
||
4168 | * |
||
4169 | * @return $this |
||
4170 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4171 | * |
||
4172 | * @psalm-return static<TKey,T> |
||
4173 | */ |
||
4174 | 17 | public function randomMutable(int $number = null): self |
|
4199 | |||
4200 | /** |
||
4201 | * Pick a random value from the values of this array. |
||
4202 | * |
||
4203 | * @return mixed |
||
4204 | * <p>Get a random value or null if there wasn't a value.</p> |
||
4205 | */ |
||
4206 | 4 | public function randomValue() |
|
4216 | |||
4217 | /** |
||
4218 | * Pick a given number of random values out of this array. |
||
4219 | * |
||
4220 | * @param int $number |
||
4221 | * |
||
4222 | * @return static |
||
4223 | * <p>(Mutable)</p> |
||
4224 | * |
||
4225 | * @psalm-return static<TKey,T> |
||
4226 | */ |
||
4227 | 7 | public function randomValues(int $number): self |
|
4231 | |||
4232 | /** |
||
4233 | * Get a random value from an array, with the ability to skew the results. |
||
4234 | * |
||
4235 | * Example: randomWeighted(['foo' => 1, 'bar' => 2]) has a 66% chance of returning bar. |
||
4236 | * |
||
4237 | * @param array $array |
||
4238 | * @param int|null $number <p>How many values you will take?</p> |
||
4239 | * |
||
4240 | * @return static<int,mixed> |
||
4241 | * <p>(Immutable)</p> |
||
4242 | * |
||
4243 | * @psalm-param array<mixed,mixed> $array |
||
4244 | * @psalm-return static<int|array-key,T> |
||
4245 | */ |
||
4246 | 9 | public function randomWeighted(array $array, int $number = null): self |
|
4261 | |||
4262 | /** |
||
4263 | * Reduce the current array via callable e.g. anonymous-function. |
||
4264 | * |
||
4265 | * @param callable $callable |
||
4266 | * @param mixed $init |
||
4267 | * |
||
4268 | * @return static |
||
4269 | * <p>(Immutable)</p> |
||
4270 | * |
||
4271 | * @psalm-return static<TKey,T> |
||
4272 | * @psalm-mutation-free |
||
4273 | */ |
||
4274 | 18 | public function reduce($callable, $init = []): self |
|
4304 | |||
4305 | /** |
||
4306 | * @param bool $unique |
||
4307 | * |
||
4308 | * @return static |
||
4309 | * <p>(Immutable)</p> |
||
4310 | * |
||
4311 | * @psalm-return static<TKey,T> |
||
4312 | * @psalm-mutation-free |
||
4313 | */ |
||
4314 | 14 | public function reduce_dimension(bool $unique = true): self |
|
4337 | |||
4338 | /** |
||
4339 | * Create a numerically re-indexed Arrayy object. |
||
4340 | * |
||
4341 | * @return $this |
||
4342 | * <p>(Mutable) Return this Arrayy object, with re-indexed array-elements.</p> |
||
4343 | * |
||
4344 | * @psalm-return static<TKey,T> |
||
4345 | */ |
||
4346 | 9 | public function reindex(): self |
|
4354 | |||
4355 | /** |
||
4356 | * Return all items that fail the truth test. |
||
4357 | * |
||
4358 | * @param \Closure $closure |
||
4359 | * |
||
4360 | * @return static |
||
4361 | * <p>(Immutable)</p> |
||
4362 | * |
||
4363 | * @psalm-return static<TKey,T> |
||
4364 | * @psalm-mutation-free |
||
4365 | */ |
||
4366 | 1 | View Code Duplication | public function reject(\Closure $closure): self |
4383 | |||
4384 | /** |
||
4385 | * Remove a value from the current array (optional using dot-notation). |
||
4386 | * |
||
4387 | * @param mixed $key |
||
4388 | * |
||
4389 | * @return static |
||
4390 | * <p>(Mutable)</p> |
||
4391 | * |
||
4392 | * @psalm-param TKey $key |
||
4393 | * @psalm-return static<TKey,T> |
||
4394 | */ |
||
4395 | 18 | public function remove($key) |
|
4418 | |||
4419 | /** |
||
4420 | * alias: for "Arrayy->removeValue()" |
||
4421 | * |
||
4422 | * @param mixed $element |
||
4423 | * |
||
4424 | * @return static |
||
4425 | * <p>(Immutable)</p> |
||
4426 | * |
||
4427 | * @psalm-param T $element |
||
4428 | * @psalm-return static<TKey,T> |
||
4429 | * @psalm-mutation-free |
||
4430 | */ |
||
4431 | 8 | public function removeElement($element) |
|
4435 | |||
4436 | /** |
||
4437 | * Remove the first value from the current array. |
||
4438 | * |
||
4439 | * @return static |
||
4440 | * <p>(Immutable)</p> |
||
4441 | * |
||
4442 | * @psalm-return static<TKey,T> |
||
4443 | * @psalm-mutation-free |
||
4444 | */ |
||
4445 | 7 | View Code Duplication | public function removeFirst(): self |
4457 | |||
4458 | /** |
||
4459 | * Remove the last value from the current array. |
||
4460 | * |
||
4461 | * @return static |
||
4462 | * <p>(Immutable)</p> |
||
4463 | * |
||
4464 | * @psalm-return static<TKey,T> |
||
4465 | * @psalm-mutation-free |
||
4466 | */ |
||
4467 | 7 | View Code Duplication | public function removeLast(): self |
4479 | |||
4480 | /** |
||
4481 | * Removes a particular value from an array (numeric or associative). |
||
4482 | * |
||
4483 | * @param mixed $value |
||
4484 | * |
||
4485 | * @return static |
||
4486 | * <p>(Immutable)</p> |
||
4487 | * |
||
4488 | * @psalm-param T $value |
||
4489 | * @psalm-return static<TKey,T> |
||
4490 | * @psalm-mutation-free |
||
4491 | */ |
||
4492 | 8 | public function removeValue($value): self |
|
4515 | |||
4516 | /** |
||
4517 | * Generate array of repeated arrays. |
||
4518 | * |
||
4519 | * @param int $times <p>How many times has to be repeated.</p> |
||
4520 | * |
||
4521 | * @return static |
||
4522 | * <p>(Immutable)</p> |
||
4523 | * |
||
4524 | * @psalm-return static<TKey,T> |
||
4525 | * @psalm-mutation-free |
||
4526 | */ |
||
4527 | 1 | public function repeat($times): self |
|
4539 | |||
4540 | /** |
||
4541 | * Replace a key with a new key/value pair. |
||
4542 | * |
||
4543 | * @param mixed $replace |
||
4544 | * @param mixed $key |
||
4545 | * @param mixed $value |
||
4546 | * |
||
4547 | * @return static |
||
4548 | * <p>(Immutable)</p> |
||
4549 | * |
||
4550 | * @psalm-return static<TKey,T> |
||
4551 | * @psalm-mutation-free |
||
4552 | */ |
||
4553 | 2 | public function replace($replace, $key, $value): self |
|
4563 | |||
4564 | /** |
||
4565 | * Create an array using the current array as values and the other array as keys. |
||
4566 | * |
||
4567 | * @param array $keys <p>An array of keys.</p> |
||
4568 | * |
||
4569 | * @return static |
||
4570 | * <p>(Immutable) Arrayy object with keys from the other array.</p> |
||
4571 | * |
||
4572 | * @psalm-param array<mixed,mixed>|array<mixed,TKey> $keys |
||
4573 | * @psalm-return static<TKey,T> |
||
4574 | * @psalm-mutation-free |
||
4575 | */ |
||
4576 | 2 | public function replaceAllKeys(array $keys): self |
|
4584 | |||
4585 | /** |
||
4586 | * Create an array using the current array as keys and the other array as values. |
||
4587 | * |
||
4588 | * @param array $array <p>An array o values.</p> |
||
4589 | * |
||
4590 | * @return static |
||
4591 | * <p>(Immutable) Arrayy object with values from the other array.</p> |
||
4592 | * |
||
4593 | * @psalm-param array<mixed,T> $array |
||
4594 | * @psalm-return static<TKey,T> |
||
4595 | * @psalm-mutation-free |
||
4596 | */ |
||
4597 | 2 | public function replaceAllValues(array $array): self |
|
4605 | |||
4606 | /** |
||
4607 | * Replace the keys in an array with another set. |
||
4608 | * |
||
4609 | * @param array $keys <p>An array of keys matching the array's size</p> |
||
4610 | * |
||
4611 | * @return static |
||
4612 | * <p>(Immutable)</p> |
||
4613 | * |
||
4614 | * @psalm-param array<mixed,mixed>|array<mixed,TKey> $keys |
||
4615 | * @psalm-return static<TKey,T> |
||
4616 | * @psalm-mutation-free |
||
4617 | */ |
||
4618 | 1 | public function replaceKeys(array $keys): self |
|
4629 | |||
4630 | /** |
||
4631 | * Replace the first matched value in an array. |
||
4632 | * |
||
4633 | * @param mixed $search <p>The value to replace.</p> |
||
4634 | * @param mixed $replacement <p>The value to replace.</p> |
||
4635 | * |
||
4636 | * @return static |
||
4637 | * <p>(Immutable)</p> |
||
4638 | * |
||
4639 | * @psalm-return static<TKey,T> |
||
4640 | * @psalm-mutation-free |
||
4641 | */ |
||
4642 | 3 | public function replaceOneValue($search, $replacement = ''): self |
|
4657 | |||
4658 | /** |
||
4659 | * Replace values in the current array. |
||
4660 | * |
||
4661 | * @param mixed $search <p>The value to replace.</p> |
||
4662 | * @param mixed $replacement <p>What to replace it with.</p> |
||
4663 | * |
||
4664 | * @return static |
||
4665 | * <p>(Immutable)</p> |
||
4666 | * |
||
4667 | * @psalm-return static<TKey,T> |
||
4668 | * @psalm-mutation-free |
||
4669 | */ |
||
4670 | 1 | public function replaceValues($search, $replacement = ''): self |
|
4682 | |||
4683 | /** |
||
4684 | * Get the last elements from index $from until the end of this array. |
||
4685 | * |
||
4686 | * @param int $from |
||
4687 | * |
||
4688 | * @return static |
||
4689 | * <p>(Immutable)</p> |
||
4690 | * |
||
4691 | * @psalm-return static<TKey,T> |
||
4692 | * @psalm-mutation-free |
||
4693 | */ |
||
4694 | 15 | View Code Duplication | public function rest(int $from = 1): self |
4704 | |||
4705 | /** |
||
4706 | * Return the array in the reverse order. |
||
4707 | * |
||
4708 | * @return $this |
||
4709 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4710 | * |
||
4711 | * @psalm-return static<TKey,T> |
||
4712 | */ |
||
4713 | 9 | public function reverse(): self |
|
4721 | |||
4722 | /** |
||
4723 | * Sort an array in reverse order. |
||
4724 | * |
||
4725 | * @param int $sort_flags [optional] <p> |
||
4726 | * You may modify the behavior of the sort using the optional |
||
4727 | * parameter sort_flags, for details |
||
4728 | * see sort. |
||
4729 | * </p> |
||
4730 | * |
||
4731 | * @return $this |
||
4732 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4733 | * |
||
4734 | * @psalm-return static<TKey,T> |
||
4735 | */ |
||
4736 | 4 | public function rsort(int $sort_flags = 0): self |
|
4744 | |||
4745 | /** |
||
4746 | * Sort an array in reverse order. |
||
4747 | * |
||
4748 | * @param int $sort_flags [optional] <p> |
||
4749 | * You may modify the behavior of the sort using the optional |
||
4750 | * parameter sort_flags, for details |
||
4751 | * see sort. |
||
4752 | * </p> |
||
4753 | * |
||
4754 | * @return $this |
||
4755 | * <p>(Immutable) Return this Arrayy object.</p> |
||
4756 | * |
||
4757 | * @psalm-return static<TKey,T> |
||
4758 | * @psalm-mutation-free |
||
4759 | */ |
||
4760 | 4 | public function rsortImmutable(int $sort_flags = 0): self |
|
4771 | |||
4772 | /** |
||
4773 | * Search for the first index of the current array via $value. |
||
4774 | * |
||
4775 | * @param mixed $value |
||
4776 | * |
||
4777 | * @return false|float|int|string |
||
4778 | * <p>Will return <b>FALSE</b> if the value can't be found.</p> |
||
4779 | * @psalm-mutation-free |
||
4780 | */ |
||
4781 | 21 | public function searchIndex($value) |
|
4791 | |||
4792 | /** |
||
4793 | * Search for the value of the current array via $index. |
||
4794 | * |
||
4795 | * @param mixed $index |
||
4796 | * |
||
4797 | * @return static |
||
4798 | * <p>(Immutable) Will return a empty Arrayy if the value wasn't found.</p> |
||
4799 | * |
||
4800 | * @psalm-return static<TKey,T> |
||
4801 | * @psalm-mutation-free |
||
4802 | */ |
||
4803 | 9 | public function searchValue($index): self |
|
4833 | |||
4834 | /** |
||
4835 | * Set a value for the current array (optional using dot-notation). |
||
4836 | * |
||
4837 | * @param string $key <p>The key to set.</p> |
||
4838 | * @param mixed $value <p>Its value.</p> |
||
4839 | * |
||
4840 | * @return $this |
||
4841 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4842 | * |
||
4843 | * @psalm-param TKey $key |
||
4844 | * @psalm-param T $value |
||
4845 | * @psalm-return static<TKey,T> |
||
4846 | */ |
||
4847 | 18 | public function set($key, $value): self |
|
4853 | |||
4854 | /** |
||
4855 | * Get a value from a array and set it if it was not. |
||
4856 | * |
||
4857 | * WARNING: this method only set the value, if the $key is not already set |
||
4858 | * |
||
4859 | * @param mixed $key <p>The key</p> |
||
4860 | * @param mixed $fallback <p>The default value to set if it isn't.</p> |
||
4861 | * |
||
4862 | * @return mixed |
||
4863 | * <p>(Mutable)</p> |
||
4864 | */ |
||
4865 | 11 | public function setAndGet($key, $fallback = null) |
|
4876 | |||
4877 | /** |
||
4878 | * Shifts a specified value off the beginning of array. |
||
4879 | * |
||
4880 | * @return mixed |
||
4881 | * <p>(Mutable) A shifted element from the current array.</p> |
||
4882 | */ |
||
4883 | 5 | public function shift() |
|
4889 | |||
4890 | /** |
||
4891 | * Shuffle the current array. |
||
4892 | * |
||
4893 | * @param bool $secure <p>using a CSPRNG | @link https://paragonie.com/b/JvICXzh_jhLyt4y3</p> |
||
4894 | * @param array $array [optional] |
||
4895 | * |
||
4896 | * @return static |
||
4897 | * <p>(Immutable)</p> |
||
4898 | * |
||
4899 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
4900 | * @psalm-return static<TKey,T> |
||
4901 | * |
||
4902 | * @noinspection BadExceptionsProcessingInspection |
||
4903 | * @noinspection RandomApiMigrationInspection |
||
4904 | * @noinspection NonSecureShuffleUsageInspection |
||
4905 | */ |
||
4906 | 2 | public function shuffle(bool $secure = false, array $array = null): self |
|
4944 | |||
4945 | /** |
||
4946 | * Count the values from the current array. |
||
4947 | * |
||
4948 | * alias: for "Arrayy->count()" |
||
4949 | * |
||
4950 | * @param int $mode |
||
4951 | * |
||
4952 | * @return int |
||
4953 | */ |
||
4954 | 20 | public function size(int $mode = \COUNT_NORMAL): int |
|
4958 | |||
4959 | /** |
||
4960 | * Checks whether array has exactly $size items. |
||
4961 | * |
||
4962 | * @param int $size |
||
4963 | * |
||
4964 | * @return bool |
||
4965 | */ |
||
4966 | 1 | View Code Duplication | public function sizeIs(int $size): bool |
4980 | |||
4981 | /** |
||
4982 | * Checks whether array has between $fromSize to $toSize items. $toSize can be |
||
4983 | * smaller than $fromSize. |
||
4984 | * |
||
4985 | * @param int $fromSize |
||
4986 | * @param int $toSize |
||
4987 | * |
||
4988 | * @return bool |
||
4989 | */ |
||
4990 | 1 | public function sizeIsBetween(int $fromSize, int $toSize): bool |
|
5010 | |||
5011 | /** |
||
5012 | * Checks whether array has more than $size items. |
||
5013 | * |
||
5014 | * @param int $size |
||
5015 | * |
||
5016 | * @return bool |
||
5017 | */ |
||
5018 | 1 | View Code Duplication | public function sizeIsGreaterThan(int $size): bool |
5032 | |||
5033 | /** |
||
5034 | * Checks whether array has less than $size items. |
||
5035 | * |
||
5036 | * @param int $size |
||
5037 | * |
||
5038 | * @return bool |
||
5039 | */ |
||
5040 | 1 | View Code Duplication | public function sizeIsLessThan(int $size): bool |
5054 | |||
5055 | /** |
||
5056 | * Counts all elements in an array, or something in an object. |
||
5057 | * |
||
5058 | * <p> |
||
5059 | * For objects, if you have SPL installed, you can hook into count() by implementing interface {@see Countable}. |
||
5060 | * The interface has exactly one method, {@see Countable::count()}, which returns the return value for the count() |
||
5061 | * function. Please see the {@see Array} section of the manual for a detailed explanation of how arrays are |
||
5062 | * implemented and used in PHP. |
||
5063 | * </p> |
||
5064 | * |
||
5065 | * @return int |
||
5066 | * <p> |
||
5067 | * The number of elements in var, which is |
||
5068 | * typically an array, since anything else will have one |
||
5069 | * element. |
||
5070 | * </p> |
||
5071 | * <p> |
||
5072 | * If var is not an array or an object with |
||
5073 | * implemented Countable interface, |
||
5074 | * 1 will be returned. |
||
5075 | * There is one exception, if var is &null;, |
||
5076 | * 0 will be returned. |
||
5077 | * </p> |
||
5078 | * <p> |
||
5079 | * Caution: count may return 0 for a variable that isn't set, |
||
5080 | * but it may also return 0 for a variable that has been initialized with an |
||
5081 | * empty array. Use isset to test if a variable is set. |
||
5082 | * </p> |
||
5083 | */ |
||
5084 | 10 | public function sizeRecursive(): int |
|
5088 | |||
5089 | /** |
||
5090 | * Extract a slice of the array. |
||
5091 | * |
||
5092 | * @param int $offset <p>Slice begin index.</p> |
||
5093 | * @param int|null $length <p>Length of the slice.</p> |
||
5094 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
5095 | * |
||
5096 | * @return static |
||
5097 | * <p>(Immutable) A slice of the original array with length $length.</p> |
||
5098 | * |
||
5099 | * @psalm-return static<TKey,T> |
||
5100 | * @psalm-mutation-free |
||
5101 | */ |
||
5102 | 5 | public function slice(int $offset, int $length = null, bool $preserveKeys = false) |
|
5115 | |||
5116 | /** |
||
5117 | * Sort the current array and optional you can keep the keys. |
||
5118 | * |
||
5119 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5120 | * @param int $strategy <p>sort_flags => use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5121 | * <strong>SORT_NATURAL</strong></p> |
||
5122 | * @param bool $keepKeys |
||
5123 | * |
||
5124 | * @return static |
||
5125 | * <p>(Mutable) Return this Arrayy object.</p> |
||
5126 | * |
||
5127 | * @psalm-return static<TKey,T> |
||
5128 | */ |
||
5129 | 20 | public function sort( |
|
5143 | |||
5144 | /** |
||
5145 | * Sort the current array and optional you can keep the keys. |
||
5146 | * |
||
5147 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5148 | * @param int $strategy <p>sort_flags => use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5149 | * <strong>SORT_NATURAL</strong></p> |
||
5150 | * @param bool $keepKeys |
||
5151 | * |
||
5152 | * @return static |
||
5153 | * <p>(Immutable) Return this Arrayy object.</p> |
||
5154 | * |
||
5155 | * @psalm-return static<TKey,T> |
||
5156 | */ |
||
5157 | 12 | public function sortImmutable( |
|
5173 | |||
5174 | /** |
||
5175 | * Sort the current array by key. |
||
5176 | * |
||
5177 | * @see http://php.net/manual/en/function.ksort.php |
||
5178 | * @see http://php.net/manual/en/function.krsort.php |
||
5179 | * |
||
5180 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5181 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5182 | * <strong>SORT_NATURAL</strong></p> |
||
5183 | * |
||
5184 | * @return $this |
||
5185 | * <p>(Mutable) Return this Arrayy object.</p> |
||
5186 | * |
||
5187 | * @psalm-return static<TKey,T> |
||
5188 | */ |
||
5189 | 18 | public function sortKeys( |
|
5199 | |||
5200 | /** |
||
5201 | * Sort the current array by key. |
||
5202 | * |
||
5203 | * @see http://php.net/manual/en/function.ksort.php |
||
5204 | * @see http://php.net/manual/en/function.krsort.php |
||
5205 | * |
||
5206 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5207 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5208 | * <strong>SORT_NATURAL</strong></p> |
||
5209 | * |
||
5210 | * @return $this |
||
5211 | * <p>(Immutable) Return this Arrayy object.</p> |
||
5212 | * |
||
5213 | * @psalm-return static<TKey,T> |
||
5214 | * @psalm-mutation-free |
||
5215 | */ |
||
5216 | 8 | public function sortKeysImmutable( |
|
5229 | |||
5230 | /** |
||
5231 | * Sort the current array by value. |
||
5232 | * |
||
5233 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5234 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5235 | * <strong>SORT_NATURAL</strong></p> |
||
5236 | * |
||
5237 | * @return static |
||
5238 | * <p>(Mutable)</p> |
||
5239 | * |
||
5240 | * @psalm-return static<TKey,T> |
||
5241 | */ |
||
5242 | 1 | public function sortValueKeepIndex( |
|
5248 | |||
5249 | /** |
||
5250 | * Sort the current array by value. |
||
5251 | * |
||
5252 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5253 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5254 | * <strong>SORT_NATURAL</strong></p> |
||
5255 | * |
||
5256 | * @return static |
||
5257 | * <p>(Mutable)</p> |
||
5258 | * |
||
5259 | * @psalm-return static<TKey,T> |
||
5260 | */ |
||
5261 | 1 | public function sortValueNewIndex($direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
5265 | |||
5266 | /** |
||
5267 | * Sort a array by value, by a closure or by a property. |
||
5268 | * |
||
5269 | * - If the sorter is null, the array is sorted naturally. |
||
5270 | * - Associative (string) keys will be maintained, but numeric keys will be re-indexed. |
||
5271 | * |
||
5272 | * @param callable|string|null $sorter |
||
5273 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or |
||
5274 | * <strong>SORT_DESC</strong></p> |
||
5275 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5276 | * <strong>SORT_NATURAL</strong></p> |
||
5277 | * |
||
5278 | * @return static |
||
5279 | * <p>(Immutable)</p> |
||
5280 | * |
||
5281 | * @psalm-return static<TKey,T> |
||
5282 | * @psalm-mutation-free |
||
5283 | */ |
||
5284 | 1 | public function sorter($sorter = null, $direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
5325 | |||
5326 | /** |
||
5327 | * @param int $offset |
||
5328 | * @param int|null $length |
||
5329 | * @param array $replacement |
||
5330 | * |
||
5331 | * @return static |
||
5332 | * <p>(Immutable)</p> |
||
5333 | * |
||
5334 | * @psalm-param array<mixed,mixed>|array<mixed,T> $replacement |
||
5335 | * @psalm-return static<TKey,T> |
||
5336 | * @psalm-mutation-free |
||
5337 | */ |
||
5338 | 1 | public function splice(int $offset, int $length = null, $replacement = []): self |
|
5355 | |||
5356 | /** |
||
5357 | * Split an array in the given amount of pieces. |
||
5358 | * |
||
5359 | * @param int $numberOfPieces |
||
5360 | * @param bool $keepKeys |
||
5361 | * |
||
5362 | * @return static |
||
5363 | * <p>(Immutable)</p> |
||
5364 | * |
||
5365 | * @psalm-return static<TKey,T> |
||
5366 | * @psalm-mutation-free |
||
5367 | */ |
||
5368 | 1 | public function split(int $numberOfPieces = 2, bool $keepKeys = false): self |
|
5387 | |||
5388 | /** |
||
5389 | * Stripe all empty items. |
||
5390 | * |
||
5391 | * @return static |
||
5392 | * <p>(Immutable)</p> |
||
5393 | * |
||
5394 | * @psalm-return static<TKey,T> |
||
5395 | * @psalm-mutation-free |
||
5396 | */ |
||
5397 | 1 | public function stripEmpty(): self |
|
5409 | |||
5410 | /** |
||
5411 | * Swap two values between positions by key. |
||
5412 | * |
||
5413 | * @param int|string $swapA <p>a key in the array</p> |
||
5414 | * @param int|string $swapB <p>a key in the array</p> |
||
5415 | * |
||
5416 | * @return static |
||
5417 | * <p>(Immutable)</p> |
||
5418 | * |
||
5419 | * @psalm-return static<TKey,T> |
||
5420 | * @psalm-mutation-free |
||
5421 | */ |
||
5422 | 1 | public function swap($swapA, $swapB): self |
|
5434 | |||
5435 | /** |
||
5436 | * Get the current array from the "Arrayy"-object. |
||
5437 | * alias for "getArray()" |
||
5438 | * |
||
5439 | * @param bool $convertAllArrayyElements <p> |
||
5440 | * Convert all Child-"Arrayy" objects also to arrays. |
||
5441 | * </p> |
||
5442 | * @param bool $preserveKeys <p> |
||
5443 | * e.g.: A generator maybe return the same key more then once, |
||
5444 | * so maybe you will ignore the keys. |
||
5445 | * </p> |
||
5446 | * |
||
5447 | * @return array |
||
5448 | * |
||
5449 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
5450 | * @psalm-mutation-free |
||
5451 | */ |
||
5452 | 893 | public function toArray( |
|
5477 | |||
5478 | /** |
||
5479 | * Get the current array from the "Arrayy"-object as list. |
||
5480 | * |
||
5481 | * @param bool $convertAllArrayyElements <p> |
||
5482 | * Convert all Child-"Arrayy" objects also to arrays. |
||
5483 | * </p> |
||
5484 | * |
||
5485 | * @return array |
||
5486 | * |
||
5487 | * @psalm-return array<int,mixed>|array<int,T> |
||
5488 | * @psalm-mutation-free |
||
5489 | */ |
||
5490 | 1 | public function toList(bool $convertAllArrayyElements = false): array |
|
5497 | |||
5498 | /** |
||
5499 | * Convert the current array to JSON. |
||
5500 | * |
||
5501 | * @param int $options [optional] <p>e.g. JSON_PRETTY_PRINT</p> |
||
5502 | * @param int $depth [optional] <p>Set the maximum depth. Must be greater than zero.</p> |
||
5503 | * |
||
5504 | * @return string |
||
5505 | */ |
||
5506 | 7 | public function toJson(int $options = 0, int $depth = 512): string |
|
5515 | |||
5516 | /** |
||
5517 | * @param string[]|null $items |
||
5518 | * @param string[] $helper |
||
5519 | * |
||
5520 | * @return static |
||
5521 | * |
||
5522 | * @psalm-return static<TKey,T> |
||
5523 | */ |
||
5524 | 1 | public function toPermutation(array $items = null, array $helper = []): self |
|
5558 | |||
5559 | /** |
||
5560 | * Implodes array to a string with specified separator. |
||
5561 | * |
||
5562 | * @param string $separator [optional] <p>The element's separator.</p> |
||
5563 | * |
||
5564 | * @return string |
||
5565 | * <p>The string representation of array, separated by ",".</p> |
||
5566 | */ |
||
5567 | 19 | public function toString(string $separator = ','): string |
|
5571 | |||
5572 | /** |
||
5573 | * Return a duplicate free copy of the current array. |
||
5574 | * |
||
5575 | * @return $this |
||
5576 | * <p>(Mutable)</p> |
||
5577 | * |
||
5578 | * @psalm-return static<TKey,T> |
||
5579 | */ |
||
5580 | 13 | public function unique(): self |
|
5602 | |||
5603 | /** |
||
5604 | * Return a duplicate free copy of the current array. (with the old keys) |
||
5605 | * |
||
5606 | * @return $this |
||
5607 | * <p>(Mutable)</p> |
||
5608 | * |
||
5609 | * @psalm-return static<TKey,T> |
||
5610 | */ |
||
5611 | 11 | public function uniqueKeepIndex(): self |
|
5637 | |||
5638 | /** |
||
5639 | * alias: for "Arrayy->unique()" |
||
5640 | * |
||
5641 | * @return static |
||
5642 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
5643 | * |
||
5644 | * @see Arrayy::unique() |
||
5645 | * |
||
5646 | * @psalm-return static<TKey,T> |
||
5647 | */ |
||
5648 | 10 | public function uniqueNewIndex(): self |
|
5652 | |||
5653 | /** |
||
5654 | * Prepends one or more values to the beginning of array at once. |
||
5655 | * |
||
5656 | * @param array ...$args |
||
5657 | * |
||
5658 | * @return $this |
||
5659 | * <p>(Mutable) Return this Arrayy object, with prepended elements to the beginning of array.</p> |
||
5660 | * |
||
5661 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$args |
||
5662 | * @psalm-return static<TKey,T> |
||
5663 | */ |
||
5664 | 4 | public function unshift(...$args): self |
|
5672 | |||
5673 | /** |
||
5674 | * Tests whether the given closure return something valid for all elements of this array. |
||
5675 | * |
||
5676 | * @param \Closure $closure the predicate |
||
5677 | * |
||
5678 | * @return bool |
||
5679 | * <p>TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.</p> |
||
5680 | */ |
||
5681 | 1 | View Code Duplication | public function validate(\Closure $closure): bool |
5691 | |||
5692 | /** |
||
5693 | * Get all values from a array. |
||
5694 | * |
||
5695 | * @return static |
||
5696 | * <p>(Immutable)</p> |
||
5697 | * |
||
5698 | * @psalm-return static<TKey,T> |
||
5699 | * @psalm-mutation-free |
||
5700 | */ |
||
5701 | 2 | public function values(): self |
|
5714 | |||
5715 | /** |
||
5716 | * Apply the given function to every element in the array, discarding the results. |
||
5717 | * |
||
5718 | * @param callable $callable |
||
5719 | * @param bool $recursive <p>Whether array will be walked recursively or no</p> |
||
5720 | * |
||
5721 | * @return $this |
||
5722 | * <p>(Mutable) Return this Arrayy object, with modified elements.</p> |
||
5723 | * |
||
5724 | * @psalm-return static<TKey,T> |
||
5725 | */ |
||
5726 | 12 | public function walk($callable, bool $recursive = false): self |
|
5738 | |||
5739 | /** |
||
5740 | * Returns a collection of matching items. |
||
5741 | * |
||
5742 | * @param string $keyOrPropertyOrMethod the property or method to evaluate |
||
5743 | * @param mixed $value the value to match |
||
5744 | * |
||
5745 | * @throws \InvalidArgumentException if property or method is not defined |
||
5746 | * |
||
5747 | * @return static |
||
5748 | * |
||
5749 | * @psalm-param T $value |
||
5750 | * @psalm-return static<TKey,T> |
||
5751 | */ |
||
5752 | 1 | public function where(string $keyOrPropertyOrMethod, $value): self |
|
5765 | |||
5766 | /** |
||
5767 | * Convert an array into a object. |
||
5768 | * |
||
5769 | * @param array $array |
||
5770 | * |
||
5771 | * @return \stdClass |
||
5772 | * |
||
5773 | * @psalm-param array<mixed,mixed> $array |
||
5774 | */ |
||
5775 | 4 | final protected static function arrayToObject(array $array = []): \stdClass |
|
5794 | |||
5795 | /** |
||
5796 | * @param array|\Generator|null $input <p> |
||
5797 | * An array containing keys to return. |
||
5798 | * </p> |
||
5799 | * @param mixed|null $search_values [optional] <p> |
||
5800 | * If specified, then only keys containing these values are returned. |
||
5801 | * </p> |
||
5802 | * @param bool $strict [optional] <p> |
||
5803 | * Determines if strict comparison (===) should be used during the |
||
5804 | * search. |
||
5805 | * </p> |
||
5806 | * |
||
5807 | * @return array |
||
5808 | * <p>an array of all the keys in input</p> |
||
5809 | * |
||
5810 | * @psalm-param array<mixed,mixed>|\Generator<TKey,T>|null $input |
||
5811 | * @psalm-return array<TKey|mixed> |
||
5812 | * @psalm-mutation-free |
||
5813 | */ |
||
5814 | 11 | protected function array_keys_recursive( |
|
5875 | |||
5876 | /** |
||
5877 | * @param mixed $path |
||
5878 | * @param callable $callable |
||
5879 | * @param array|null $currentOffset |
||
5880 | * |
||
5881 | * @return void |
||
5882 | * |
||
5883 | * @psalm-param array<mixed,mixed>|array<TKey,T>|null $currentOffset |
||
5884 | */ |
||
5885 | 4 | protected function callAtPath($path, $callable, &$currentOffset = null) |
|
5914 | |||
5915 | /** |
||
5916 | * Extracts the value of the given property or method from the object. |
||
5917 | * |
||
5918 | * @param static $object <p>The object to extract the value from.</p> |
||
5919 | * @param string $keyOrPropertyOrMethod <p>The property or method for which the |
||
5920 | * value should be extracted.</p> |
||
5921 | * |
||
5922 | * @throws \InvalidArgumentException if the method or property is not defined |
||
5923 | * |
||
5924 | * @return mixed |
||
5925 | * <p>The value extracted from the specified property or method.</p> |
||
5926 | * |
||
5927 | * @psalm-param self<TKey,T> $object |
||
5928 | */ |
||
5929 | 2 | final protected function extractValue(self $object, string $keyOrPropertyOrMethod) |
|
5951 | |||
5952 | /** |
||
5953 | * create a fallback for array |
||
5954 | * |
||
5955 | * 1. use the current array, if it's a array |
||
5956 | * 2. fallback to empty array, if there is nothing |
||
5957 | * 3. call "getArray()" on object, if there is a "Arrayy"-object |
||
5958 | * 4. call "createFromObject()" on object, if there is a "\Traversable"-object |
||
5959 | * 5. call "__toArray()" on object, if the method exists |
||
5960 | * 6. cast a string or object with "__toString()" into an array |
||
5961 | * 7. throw a "InvalidArgumentException"-Exception |
||
5962 | * |
||
5963 | * @param mixed $data |
||
5964 | * |
||
5965 | * @throws \InvalidArgumentException |
||
5966 | * |
||
5967 | * @return array |
||
5968 | * |
||
5969 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
5970 | */ |
||
5971 | 1100 | protected function fallbackForArray(&$data): array |
|
5981 | |||
5982 | /** |
||
5983 | * @param bool $preserveKeys <p> |
||
5984 | * e.g.: A generator maybe return the same key more then once, |
||
5985 | * so maybe you will ignore the keys. |
||
5986 | * </p> |
||
5987 | * |
||
5988 | * @return bool |
||
5989 | * |
||
5990 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
5991 | * @psalm-mutation-free :/ |
||
5992 | */ |
||
5993 | 1014 | protected function generatorToArray(bool $preserveKeys = true) |
|
6004 | |||
6005 | /** |
||
6006 | * Get correct PHP constant for direction. |
||
6007 | * |
||
6008 | * @param int|string $direction |
||
6009 | * |
||
6010 | * @return int |
||
6011 | * @psalm-mutation-free |
||
6012 | */ |
||
6013 | 43 | protected function getDirection($direction): int |
|
6035 | |||
6036 | /** |
||
6037 | * @return TypeCheckPhpDoc[] |
||
6038 | * |
||
6039 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
6040 | */ |
||
6041 | 16 | protected function getPropertiesFromPhpDoc() |
|
6066 | |||
6067 | /** |
||
6068 | * @param mixed $glue |
||
6069 | * @param mixed $pieces |
||
6070 | * @param bool $useKeys |
||
6071 | * |
||
6072 | * @return string |
||
6073 | */ |
||
6074 | 36 | protected function implode_recursive($glue = '', $pieces = [], bool $useKeys = false): string |
|
6104 | |||
6105 | /** |
||
6106 | * @param mixed $needle <p> |
||
6107 | * The searched value. |
||
6108 | * </p> |
||
6109 | * <p> |
||
6110 | * If needle is a string, the comparison is done |
||
6111 | * in a case-sensitive manner. |
||
6112 | * </p> |
||
6113 | * @param array|\Generator|null $haystack <p> |
||
6114 | * The array. |
||
6115 | * </p> |
||
6116 | * @param bool $strict [optional] <p> |
||
6117 | * If the third parameter strict is set to true |
||
6118 | * then the in_array function will also check the |
||
6119 | * types of the |
||
6120 | * needle in the haystack. |
||
6121 | * </p> |
||
6122 | * |
||
6123 | * @return bool |
||
6124 | * <p>true if needle is found in the array, false otherwise</p> |
||
6125 | * |
||
6126 | * @psalm-param array<mixed,mixed>|\Generator<TKey,T>|null $haystack |
||
6127 | */ |
||
6128 | 18 | protected function in_array_recursive($needle, $haystack = null, $strict = true): bool |
|
6153 | |||
6154 | /** |
||
6155 | * @param mixed $data |
||
6156 | * |
||
6157 | * @return array|null |
||
6158 | * |
||
6159 | * @psalm-return array<mixed,mixed>|array<TKey,T>|null |
||
6160 | */ |
||
6161 | 1100 | protected function internalGetArray(&$data) |
|
6212 | |||
6213 | /** |
||
6214 | * Internal mechanics of remove method. |
||
6215 | * |
||
6216 | * @param mixed $key |
||
6217 | * |
||
6218 | * @return bool |
||
6219 | */ |
||
6220 | 18 | protected function internalRemove($key): bool |
|
6253 | |||
6254 | /** |
||
6255 | * Internal mechanic of set method. |
||
6256 | * |
||
6257 | * @param int|string|null $key |
||
6258 | * @param mixed $value |
||
6259 | * @param bool $checkProperties |
||
6260 | * |
||
6261 | * @return bool |
||
6262 | */ |
||
6263 | 962 | protected function internalSet( |
|
6316 | |||
6317 | /** |
||
6318 | * Convert a object into an array. |
||
6319 | * |
||
6320 | * @param mixed|object $object |
||
6321 | * |
||
6322 | * @return array|mixed |
||
6323 | * |
||
6324 | * @psalm-mutation-free |
||
6325 | */ |
||
6326 | 5 | protected static function objectToArray($object) |
|
6339 | |||
6340 | /** |
||
6341 | * @param array $data |
||
6342 | * @param bool $checkPropertiesInConstructor |
||
6343 | * |
||
6344 | * @return void |
||
6345 | * |
||
6346 | * @psalm-param array<mixed,T> $data |
||
6347 | */ |
||
6348 | 1098 | protected function setInitialValuesAndProperties(array &$data, bool $checkPropertiesInConstructor) |
|
6393 | |||
6394 | /** |
||
6395 | * sorting keys |
||
6396 | * |
||
6397 | * @param array $elements |
||
6398 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
6399 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
6400 | * <strong>SORT_NATURAL</strong></p> |
||
6401 | * |
||
6402 | * @return $this |
||
6403 | * <p>(Mutable) Return this Arrayy object.</p> |
||
6404 | * |
||
6405 | * @psalm-param array<mixed,mixed>|array<mixed|TKey,T> $elements |
||
6406 | * @psalm-return static<TKey,T> |
||
6407 | */ |
||
6408 | 18 | protected function sorterKeys( |
|
6429 | |||
6430 | /** |
||
6431 | * @param array $elements <p>Warning: used as reference</p> |
||
6432 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
6433 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
6434 | * <strong>SORT_NATURAL</strong></p> |
||
6435 | * @param bool $keepKeys |
||
6436 | * |
||
6437 | * @return $this |
||
6438 | * <p>(Mutable) Return this Arrayy object.</p> |
||
6439 | * |
||
6440 | * @psalm-param array<mixed,mixed>|array<mixed|TKey,T> $elements |
||
6441 | * @psalm-return static<TKey,T> |
||
6442 | */ |
||
6443 | 24 | protected function sorting(array &$elements, $direction = \SORT_ASC, int $strategy = \SORT_REGULAR, bool $keepKeys = false): self |
|
6473 | |||
6474 | /** |
||
6475 | * @param int|string|null $key |
||
6476 | * @param mixed $value |
||
6477 | * |
||
6478 | * @return void |
||
6479 | */ |
||
6480 | 87 | private function checkType($key, $value) |
|
6498 | } |
||
6499 |
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..