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( |
|
119 | |||
120 | /** |
||
121 | * @return void |
||
122 | */ |
||
123 | 47 | public function __clone() |
|
133 | |||
134 | /** |
||
135 | * Call object as function. |
||
136 | * |
||
137 | * @param mixed $key |
||
138 | * |
||
139 | * @return mixed |
||
140 | */ |
||
141 | 1 | public function __invoke($key = null) |
|
151 | |||
152 | /** |
||
153 | * Whether or not an element exists by key. |
||
154 | * |
||
155 | * @param mixed $key |
||
156 | * |
||
157 | * @return bool |
||
158 | * <p>True is the key/index exists, otherwise false.</p> |
||
159 | */ |
||
160 | public function __isset($key): bool |
||
164 | |||
165 | /** |
||
166 | * Assigns a value to the specified element. |
||
167 | * |
||
168 | * @param mixed $key |
||
169 | * @param mixed $value |
||
170 | * |
||
171 | * @return void |
||
172 | */ |
||
173 | 2 | public function __set($key, $value) |
|
177 | |||
178 | /** |
||
179 | * magic to string |
||
180 | * |
||
181 | * @return string |
||
182 | */ |
||
183 | 15 | public function __toString(): string |
|
187 | |||
188 | /** |
||
189 | * Unset element by key. |
||
190 | * |
||
191 | * @param mixed $key |
||
192 | */ |
||
193 | public function __unset($key) |
||
197 | |||
198 | /** |
||
199 | * Get a value by key. |
||
200 | * |
||
201 | * @param mixed $key |
||
202 | * |
||
203 | * @return mixed |
||
204 | * <p>Get a Value from the current array.</p> |
||
205 | */ |
||
206 | 4 | public function &__get($key) |
|
216 | |||
217 | /** |
||
218 | * alias: for "Arrayy->append()" |
||
219 | * |
||
220 | * @param mixed $value |
||
221 | * |
||
222 | * @return static |
||
223 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
224 | * |
||
225 | * @see Arrayy::append() |
||
226 | * |
||
227 | * @psalm-param T $value |
||
228 | * @psalm-return static<TKey,T> |
||
229 | */ |
||
230 | 3 | public function add($value) |
|
234 | |||
235 | /** |
||
236 | * Append a (key) + value to the current array. |
||
237 | * |
||
238 | * @param mixed $value |
||
239 | * @param mixed $key |
||
240 | * |
||
241 | * @return $this |
||
242 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
243 | * |
||
244 | * @psalm-return static<TKey,T> |
||
245 | */ |
||
246 | 13 | public function append($value, $key = null): self |
|
270 | |||
271 | /** |
||
272 | * Sort the entries by value. |
||
273 | * |
||
274 | * @param int $sort_flags [optional] <p> |
||
275 | * You may modify the behavior of the sort using the optional |
||
276 | * parameter sort_flags, for details |
||
277 | * see sort. |
||
278 | * </p> |
||
279 | * |
||
280 | * @return $this |
||
281 | * <p>(Mutable) Return this Arrayy object.</p> |
||
282 | * |
||
283 | * @psalm-return static<TKey,T> |
||
284 | */ |
||
285 | 4 | public function asort(int $sort_flags = 0): self |
|
293 | |||
294 | /** |
||
295 | * Sort the entries by value. |
||
296 | * |
||
297 | * @param int $sort_flags [optional] <p> |
||
298 | * You may modify the behavior of the sort using the optional |
||
299 | * parameter sort_flags, for details |
||
300 | * see sort. |
||
301 | * </p> |
||
302 | * |
||
303 | * @return $this |
||
304 | * <p>(Immutable) Return this Arrayy object.</p> |
||
305 | * |
||
306 | * @psalm-return static<TKey,T> |
||
307 | * @psalm-mutation-free |
||
308 | */ |
||
309 | 4 | public function asortImmutable(int $sort_flags = 0): self |
|
320 | |||
321 | /** |
||
322 | * Counts all elements in an array, or something in an object. |
||
323 | * |
||
324 | * <p> |
||
325 | * For objects, if you have SPL installed, you can hook into count() by implementing interface {@see Countable}. |
||
326 | * The interface has exactly one method, {@see Countable::count()}, which returns the return value for the count() |
||
327 | * function. Please see the {@see Array} section of the manual for a detailed explanation of how arrays are |
||
328 | * implemented and used in PHP. |
||
329 | * </p> |
||
330 | * |
||
331 | * @see http://php.net/manual/en/function.count.php |
||
332 | * |
||
333 | * @param int $mode [optional] If the optional mode parameter is set to |
||
334 | * COUNT_RECURSIVE (or 1), count |
||
335 | * will recursively count the array. This is particularly useful for |
||
336 | * counting all the elements of a multidimensional array. count does not detect infinite recursion. |
||
337 | * |
||
338 | * @return int |
||
339 | * <p> |
||
340 | * The number of elements in var, which is |
||
341 | * typically an array, since anything else will have one |
||
342 | * element. |
||
343 | * </p> |
||
344 | * <p> |
||
345 | * If var is not an array or an object with |
||
346 | * implemented Countable interface, |
||
347 | * 1 will be returned. |
||
348 | * There is one exception, if var is &null;, |
||
349 | * 0 will be returned. |
||
350 | * </p> |
||
351 | * <p> |
||
352 | * Caution: count may return 0 for a variable that isn't set, |
||
353 | * but it may also return 0 for a variable that has been initialized with an |
||
354 | * empty array. Use isset to test if a variable is set. |
||
355 | * </p> |
||
356 | * @psalm-mutation-free |
||
357 | */ |
||
358 | 145 | public function count(int $mode = \COUNT_NORMAL): int |
|
370 | |||
371 | /** |
||
372 | * Exchange the array for another one. |
||
373 | * |
||
374 | * @param array|static $data |
||
375 | * |
||
376 | * @return array |
||
377 | * |
||
378 | * @psalm-param array<TKey,T>|self<TKey,T> $data |
||
379 | * @psalm-return array<TKey,T> |
||
380 | */ |
||
381 | 1 | public function exchangeArray($data): array |
|
387 | |||
388 | /** |
||
389 | * Creates a copy of the ArrayyObject. |
||
390 | * |
||
391 | * @return array |
||
392 | * |
||
393 | * @psalm-return array<TKey,T> |
||
394 | */ |
||
395 | 5 | public function getArrayCopy(): array |
|
401 | |||
402 | /** |
||
403 | * Returns a new iterator, thus implementing the \Iterator interface. |
||
404 | * |
||
405 | * @return \Iterator<mixed, mixed> |
||
406 | * <p>An iterator for the values in the array.</p> |
||
407 | * @psalm-return \Iterator<array-key|TKey, mixed|T> |
||
408 | */ |
||
409 | 24 | public function getIterator(): \Iterator |
|
426 | |||
427 | /** |
||
428 | * Gets the iterator classname for the ArrayObject. |
||
429 | * |
||
430 | * @return string |
||
431 | * |
||
432 | * @psalm-return class-string |
||
433 | */ |
||
434 | 23 | public function getIteratorClass(): string |
|
438 | |||
439 | /** |
||
440 | * Sort the entries by key. |
||
441 | * |
||
442 | * @param int $sort_flags [optional] <p> |
||
443 | * You may modify the behavior of the sort using the optional |
||
444 | * parameter sort_flags, for details |
||
445 | * see sort. |
||
446 | * </p> |
||
447 | * |
||
448 | * @return $this |
||
449 | * <p>(Mutable) Return this Arrayy object.</p> |
||
450 | * |
||
451 | * @psalm-return static<TKey,T> |
||
452 | */ |
||
453 | 4 | public function ksort(int $sort_flags = 0): self |
|
461 | |||
462 | /** |
||
463 | * Sort the entries by key. |
||
464 | * |
||
465 | * @param int $sort_flags [optional] <p> |
||
466 | * You may modify the behavior of the sort using the optional |
||
467 | * parameter sort_flags, for details |
||
468 | * see sort. |
||
469 | * </p> |
||
470 | * |
||
471 | * @return $this |
||
472 | * <p>(Immutable) Return this Arrayy object.</p> |
||
473 | * |
||
474 | * @psalm-return static<TKey,T> |
||
475 | */ |
||
476 | 4 | public function ksortImmutable(int $sort_flags = 0): self |
|
487 | |||
488 | /** |
||
489 | * Sort an array using a case insensitive "natural order" algorithm. |
||
490 | * |
||
491 | * @return $this |
||
492 | * <p>(Mutable) Return this Arrayy object.</p> |
||
493 | * |
||
494 | * @psalm-return static<TKey,T> |
||
495 | */ |
||
496 | 8 | public function natcasesort(): self |
|
504 | |||
505 | /** |
||
506 | * Sort an array using a case insensitive "natural order" algorithm. |
||
507 | * |
||
508 | * @return $this |
||
509 | * <p>(Immutable) Return this Arrayy object.</p> |
||
510 | * |
||
511 | * @psalm-return static<TKey,T> |
||
512 | * @psalm-mutation-free |
||
513 | */ |
||
514 | 4 | public function natcasesortImmutable(): self |
|
525 | |||
526 | /** |
||
527 | * Sort entries using a "natural order" algorithm. |
||
528 | * |
||
529 | * @return $this |
||
530 | * <p>(Mutable) Return this Arrayy object.</p> |
||
531 | * |
||
532 | * @psalm-return static<TKey,T> |
||
533 | */ |
||
534 | 9 | public function natsort(): self |
|
542 | |||
543 | /** |
||
544 | * Sort entries using a "natural order" algorithm. |
||
545 | * |
||
546 | * @return $this |
||
547 | * <p>(Immutable) Return this Arrayy object.</p> |
||
548 | * |
||
549 | * @psalm-return static<TKey,T> |
||
550 | * @psalm-mutation-free |
||
551 | */ |
||
552 | 4 | public function natsortImmutable(): self |
|
563 | |||
564 | /** |
||
565 | * Whether or not an offset exists. |
||
566 | * |
||
567 | * @param bool|int|string $offset |
||
568 | * |
||
569 | * @return bool |
||
570 | * |
||
571 | * @noinspection PhpSillyAssignmentInspection |
||
572 | * |
||
573 | * @psalm-mutation-free |
||
574 | */ |
||
575 | 130 | public function offsetExists($offset): bool |
|
637 | |||
638 | /** |
||
639 | * Returns the value at specified offset. |
||
640 | * |
||
641 | * @param int|string $offset |
||
642 | * |
||
643 | * @return mixed |
||
644 | * <p>Will return null if the offset did not exists.</p> |
||
645 | */ |
||
646 | 101 | public function offsetGet($offset) |
|
650 | |||
651 | /** |
||
652 | * Assigns a value to the specified offset + check the type. |
||
653 | * |
||
654 | * @param int|string|null $offset |
||
655 | * @param mixed $value |
||
656 | * |
||
657 | * @return void |
||
658 | */ |
||
659 | 18 | public function offsetSet($offset, $value) |
|
660 | { |
||
661 | 18 | $this->generatorToArray(); |
|
662 | |||
663 | 18 | if ($offset === null) { |
|
664 | 5 | if ($this->properties !== []) { |
|
665 | 1 | $this->checkType(null, $value); |
|
666 | } |
||
667 | |||
668 | 4 | $this->array[] = $value; |
|
669 | } else { |
||
670 | 13 | $this->internalSet( |
|
671 | 13 | $offset, |
|
672 | $value, |
||
673 | 13 | true |
|
674 | ); |
||
675 | } |
||
676 | 17 | } |
|
677 | |||
678 | /** |
||
679 | * Unset an offset. |
||
680 | * |
||
681 | * @param int|string $offset |
||
682 | * |
||
683 | * @return void |
||
684 | */ |
||
685 | 12 | public function offsetUnset($offset) |
|
732 | |||
733 | /** |
||
734 | * Serialize the current "Arrayy"-object. |
||
735 | * |
||
736 | * @return string |
||
737 | */ |
||
738 | 2 | public function serialize(): string |
|
748 | |||
749 | /** |
||
750 | * Sets the iterator classname for the current "Arrayy"-object. |
||
751 | * |
||
752 | * @param string $iteratorClass |
||
753 | * |
||
754 | * @throws \InvalidArgumentException |
||
755 | * |
||
756 | * @return void |
||
757 | * |
||
758 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
759 | */ |
||
760 | 1091 | public function setIteratorClass($iteratorClass) |
|
782 | |||
783 | /** |
||
784 | * Sort the entries with a user-defined comparison function and maintain key association. |
||
785 | * |
||
786 | * @param callable $function |
||
787 | * |
||
788 | * @throws \InvalidArgumentException |
||
789 | * |
||
790 | * @return $this |
||
791 | * <p>(Mutable) Return this Arrayy object.</p> |
||
792 | * |
||
793 | * @psalm-return static<TKey,T> |
||
794 | */ |
||
795 | 8 | View Code Duplication | public function uasort($function): self |
807 | |||
808 | /** |
||
809 | * Sort the entries with a user-defined comparison function and maintain key association. |
||
810 | * |
||
811 | * @param callable $function |
||
812 | * |
||
813 | * @throws \InvalidArgumentException |
||
814 | * |
||
815 | * @return $this |
||
816 | * <p>(Immutable) Return this Arrayy object.</p> |
||
817 | * |
||
818 | * @psalm-return static<TKey,T> |
||
819 | * @psalm-mutation-free |
||
820 | */ |
||
821 | 4 | public function uasortImmutable($function): self |
|
832 | |||
833 | /** |
||
834 | * Sort the entries by keys using a user-defined comparison function. |
||
835 | * |
||
836 | * @param callable $function |
||
837 | * |
||
838 | * @throws \InvalidArgumentException |
||
839 | * |
||
840 | * @return static |
||
841 | * <p>(Mutable) Return this Arrayy object.</p> |
||
842 | * |
||
843 | * @psalm-return static<TKey,T> |
||
844 | */ |
||
845 | 5 | public function uksort($function): self |
|
849 | |||
850 | /** |
||
851 | * Sort the entries by keys using a user-defined comparison function. |
||
852 | * |
||
853 | * @param callable $function |
||
854 | * |
||
855 | * @throws \InvalidArgumentException |
||
856 | * |
||
857 | * @return static |
||
858 | * <p>(Immutable) Return this Arrayy object.</p> |
||
859 | * |
||
860 | * @psalm-return static<TKey,T> |
||
861 | * @psalm-mutation-free |
||
862 | */ |
||
863 | 1 | public function uksortImmutable($function): self |
|
867 | |||
868 | /** |
||
869 | * Unserialize an string and return the instance of the "Arrayy"-class. |
||
870 | * |
||
871 | * @param string $string |
||
872 | * |
||
873 | * @return $this |
||
874 | * |
||
875 | * @psalm-return static<TKey,T> |
||
876 | */ |
||
877 | 2 | public function unserialize($string): self |
|
887 | |||
888 | /** |
||
889 | * Append a (key) + values to the current array. |
||
890 | * |
||
891 | * @param array $values |
||
892 | * @param mixed $key |
||
893 | * |
||
894 | * @return $this |
||
895 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
896 | * |
||
897 | * @psalm-param array<mixed,T> $values |
||
898 | * @psalm-param TKey|null $key |
||
899 | * @psalm-return static<TKey,T> |
||
900 | */ |
||
901 | 1 | public function appendArrayValues(array $values, $key = null) |
|
927 | |||
928 | /** |
||
929 | * Add a suffix to each key. |
||
930 | * |
||
931 | * @param mixed $prefix |
||
932 | * |
||
933 | * @return static |
||
934 | * <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> |
||
935 | * |
||
936 | * @psalm-return static<TKey,T> |
||
937 | * @psalm-mutation-free |
||
938 | */ |
||
939 | 10 | View Code Duplication | public function appendToEachKey($prefix): self |
958 | |||
959 | /** |
||
960 | * Add a prefix to each value. |
||
961 | * |
||
962 | * @param mixed $prefix |
||
963 | * |
||
964 | * @return static |
||
965 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
||
966 | * |
||
967 | * @psalm-return static<TKey,T> |
||
968 | * @psalm-mutation-free |
||
969 | */ |
||
970 | 10 | View Code Duplication | public function appendToEachValue($prefix): self |
989 | |||
990 | /** |
||
991 | * Sort an array in reverse order and maintain index association. |
||
992 | * |
||
993 | * @return $this |
||
994 | * <p>(Mutable) Return this Arrayy object.</p> |
||
995 | * |
||
996 | * @psalm-return static<TKey,T> |
||
997 | */ |
||
998 | 4 | public function arsort(): self |
|
1006 | |||
1007 | /** |
||
1008 | * Sort an array in reverse order and maintain index association. |
||
1009 | * |
||
1010 | * @return $this |
||
1011 | * <p>(Immutable) Return this Arrayy object.</p> |
||
1012 | * |
||
1013 | * @psalm-return static<TKey,T> |
||
1014 | * @psalm-mutation-free |
||
1015 | */ |
||
1016 | 10 | public function arsortImmutable(): self |
|
1026 | |||
1027 | /** |
||
1028 | * Iterate over the current array and execute a callback for each loop. |
||
1029 | * |
||
1030 | * @param \Closure $closure |
||
1031 | * |
||
1032 | * @return static |
||
1033 | * <p>(Immutable)</p> |
||
1034 | * |
||
1035 | * @psalm-return static<TKey,T> |
||
1036 | * @psalm-mutation-free |
||
1037 | */ |
||
1038 | 2 | public function at(\Closure $closure): self |
|
1052 | |||
1053 | /** |
||
1054 | * Returns the average value of the current array. |
||
1055 | * |
||
1056 | * @param int $decimals <p>The number of decimal-numbers to return.</p> |
||
1057 | * |
||
1058 | * @return float|int |
||
1059 | * <p>The average value.</p> |
||
1060 | * @psalm-mutation-free |
||
1061 | */ |
||
1062 | 10 | public function average($decimals = 0) |
|
1076 | |||
1077 | /** |
||
1078 | * Changes all keys in an array. |
||
1079 | * |
||
1080 | * @param int $case [optional] <p> Either <strong>CASE_UPPER</strong><br /> |
||
1081 | * or <strong>CASE_LOWER</strong> (default)</p> |
||
1082 | * |
||
1083 | * @return static |
||
1084 | * <p>(Immutable)</p> |
||
1085 | * |
||
1086 | * @psalm-return static<TKey,T> |
||
1087 | * @psalm-mutation-free |
||
1088 | */ |
||
1089 | 1 | public function changeKeyCase(int $case = \CASE_LOWER): self |
|
1116 | |||
1117 | /** |
||
1118 | * Change the path separator of the array wrapper. |
||
1119 | * |
||
1120 | * By default, the separator is: "." |
||
1121 | * |
||
1122 | * @param string $separator <p>Separator to set.</p> |
||
1123 | * |
||
1124 | * @return $this |
||
1125 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1126 | * |
||
1127 | * @psalm-return static<TKey,T> |
||
1128 | */ |
||
1129 | 11 | public function changeSeparator($separator): self |
|
1135 | |||
1136 | /** |
||
1137 | * Create a chunked version of the current array. |
||
1138 | * |
||
1139 | * @param int $size <p>Size of each chunk.</p> |
||
1140 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
1141 | * |
||
1142 | * @return static |
||
1143 | * <p>(Immutable) A new array of chunks from the original array.</p> |
||
1144 | * |
||
1145 | * @psalm-return static<TKey,T> |
||
1146 | * @psalm-mutation-free |
||
1147 | */ |
||
1148 | 5 | public function chunk($size, $preserveKeys = false): self |
|
1156 | |||
1157 | /** |
||
1158 | * Clean all falsy values from the current array. |
||
1159 | * |
||
1160 | * @return static |
||
1161 | * <p>(Immutable)</p> |
||
1162 | * |
||
1163 | * @psalm-return static<TKey,T> |
||
1164 | * @psalm-mutation-free |
||
1165 | */ |
||
1166 | 8 | public function clean(): self |
|
1174 | |||
1175 | /** |
||
1176 | * WARNING!!! -> Clear the current array. |
||
1177 | * |
||
1178 | * @return $this |
||
1179 | * <p>(Mutable) Return this Arrayy object, with an empty array.</p> |
||
1180 | * |
||
1181 | * @psalm-return static<TKey,T> |
||
1182 | */ |
||
1183 | 5 | public function clear(): self |
|
1190 | |||
1191 | /** |
||
1192 | * Check if an item is in the current array. |
||
1193 | * |
||
1194 | * @param float|int|string $value |
||
1195 | * @param bool $recursive |
||
1196 | * @param bool $strict |
||
1197 | * |
||
1198 | * @return bool |
||
1199 | * @psalm-mutation-free |
||
1200 | */ |
||
1201 | 24 | public function contains($value, bool $recursive = false, bool $strict = true): bool |
|
1222 | |||
1223 | /** |
||
1224 | * Check if an (case-insensitive) string is in the current array. |
||
1225 | * |
||
1226 | * @param mixed $value |
||
1227 | * @param bool $recursive |
||
1228 | * |
||
1229 | * @return bool |
||
1230 | * @psalm-mutation-free |
||
1231 | * |
||
1232 | * @psalm-suppress InvalidCast - hack for int|float|bool support |
||
1233 | */ |
||
1234 | 26 | public function containsCaseInsensitive($value, $recursive = false): bool |
|
1263 | |||
1264 | /** |
||
1265 | * Check if the given key/index exists in the array. |
||
1266 | * |
||
1267 | * @param int|string $key <p>key/index to search for</p> |
||
1268 | * |
||
1269 | * @return bool |
||
1270 | * <p>Returns true if the given key/index exists in the array, false otherwise.</p> |
||
1271 | * |
||
1272 | * @psalm-mutation-free |
||
1273 | */ |
||
1274 | 4 | public function containsKey($key): bool |
|
1278 | |||
1279 | /** |
||
1280 | * Check if all given needles are present in the array as key/index. |
||
1281 | * |
||
1282 | * @param array $needles <p>The keys you are searching for.</p> |
||
1283 | * @param bool $recursive |
||
1284 | * |
||
1285 | * @return bool |
||
1286 | * <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p> |
||
1287 | * |
||
1288 | * @psalm-param array<mixed,mixed>|array<TKey> $needles |
||
1289 | * @psalm-mutation-free |
||
1290 | */ |
||
1291 | 2 | public function containsKeys(array $needles, $recursive = false): bool |
|
1319 | |||
1320 | /** |
||
1321 | * Check if all given needles are present in the array as key/index. |
||
1322 | * |
||
1323 | * @param array $needles <p>The keys you are searching for.</p> |
||
1324 | * |
||
1325 | * @return bool |
||
1326 | * <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p> |
||
1327 | * |
||
1328 | * @psalm-param array<mixed,mixed>|array<TKey> $needles |
||
1329 | * @psalm-mutation-free |
||
1330 | */ |
||
1331 | 1 | public function containsKeysRecursive(array $needles): bool |
|
1335 | |||
1336 | /** |
||
1337 | * alias: for "Arrayy->contains()" |
||
1338 | * |
||
1339 | * @param float|int|string $value |
||
1340 | * |
||
1341 | * @return bool |
||
1342 | * |
||
1343 | * @see Arrayy::contains() |
||
1344 | * @psalm-mutation-free |
||
1345 | */ |
||
1346 | 9 | public function containsValue($value): bool |
|
1350 | |||
1351 | /** |
||
1352 | * alias: for "Arrayy->contains($value, true)" |
||
1353 | * |
||
1354 | * @param float|int|string $value |
||
1355 | * |
||
1356 | * @return bool |
||
1357 | * |
||
1358 | * @see Arrayy::contains() |
||
1359 | * @psalm-mutation-free |
||
1360 | */ |
||
1361 | 18 | public function containsValueRecursive($value): bool |
|
1365 | |||
1366 | /** |
||
1367 | * Check if all given needles are present in the array. |
||
1368 | * |
||
1369 | * @param array $needles |
||
1370 | * |
||
1371 | * @return bool |
||
1372 | * <p>Returns true if all the given values exists in the array, false otherwise.</p> |
||
1373 | * |
||
1374 | * @psalm-param array<mixed>|array<T> $needles |
||
1375 | * @psalm-mutation-free |
||
1376 | */ |
||
1377 | 1 | public function containsValues(array $needles): bool |
|
1383 | |||
1384 | /** |
||
1385 | * Counts all the values of an array |
||
1386 | * |
||
1387 | * @see http://php.net/manual/en/function.array-count-values.php |
||
1388 | * |
||
1389 | * @return static |
||
1390 | * <p> |
||
1391 | * (Immutable) |
||
1392 | * An associative Arrayy-object of values from input as |
||
1393 | * keys and their count as value. |
||
1394 | * </p> |
||
1395 | * |
||
1396 | * @psalm-return static<TKey,T> |
||
1397 | * @psalm-mutation-free |
||
1398 | */ |
||
1399 | 7 | public function countValues(): self |
|
1403 | |||
1404 | /** |
||
1405 | * Creates an Arrayy object. |
||
1406 | * |
||
1407 | * @param mixed $data |
||
1408 | * @param string $iteratorClass |
||
1409 | * @param bool $checkPropertiesInConstructor |
||
1410 | * |
||
1411 | * @return static |
||
1412 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1413 | * |
||
1414 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
1415 | * |
||
1416 | * @psalm-mutation-free |
||
1417 | */ |
||
1418 | 672 | public static function create( |
|
1419 | $data = [], |
||
1420 | string $iteratorClass = ArrayyIterator::class, |
||
1421 | bool $checkPropertiesInConstructor = true |
||
1422 | ) { |
||
1423 | 672 | return new static( |
|
1424 | 672 | $data, |
|
1425 | $iteratorClass, |
||
1426 | $checkPropertiesInConstructor |
||
1427 | ); |
||
1428 | } |
||
1429 | |||
1430 | /** |
||
1431 | * WARNING: Creates an Arrayy object by reference. |
||
1432 | * |
||
1433 | * @param array $array |
||
1434 | * |
||
1435 | * @return $this |
||
1436 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1437 | * |
||
1438 | * @psalm-param array<mixed,mixed>|array<array-key,mixed> $array |
||
1439 | */ |
||
1440 | 1 | public function createByReference(array &$array = []): self |
|
1448 | |||
1449 | /** |
||
1450 | * Create an new instance from a callable function which will return an Generator. |
||
1451 | * |
||
1452 | * @param callable $generatorFunction |
||
1453 | * |
||
1454 | * @return static |
||
1455 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1456 | * |
||
1457 | * @psalm-param callable():\Generator<array-key,mixed> $generatorFunction |
||
1458 | * |
||
1459 | * @psalm-mutation-free |
||
1460 | */ |
||
1461 | 7 | public static function createFromGeneratorFunction(callable $generatorFunction): self |
|
1465 | |||
1466 | /** |
||
1467 | * Create an new instance filled with a copy of values from a "Generator"-object. |
||
1468 | * |
||
1469 | * @param \Generator $generator |
||
1470 | * |
||
1471 | * @return static |
||
1472 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1473 | * |
||
1474 | * @psalm-param \Generator<array-key,mixed> $generator |
||
1475 | * |
||
1476 | * @psalm-mutation-free |
||
1477 | */ |
||
1478 | 4 | public static function createFromGeneratorImmutable(\Generator $generator): self |
|
1482 | |||
1483 | /** |
||
1484 | * Create an new Arrayy object via JSON. |
||
1485 | * |
||
1486 | * @param string $json |
||
1487 | * |
||
1488 | * @return static |
||
1489 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1490 | * |
||
1491 | * @psalm-mutation-free |
||
1492 | */ |
||
1493 | 5 | public static function createFromJson(string $json): self |
|
1497 | |||
1498 | /** |
||
1499 | * Create an new instance filled with values from an object that is iterable. |
||
1500 | * |
||
1501 | * @param \Traversable $object <p>iterable object</p> |
||
1502 | * |
||
1503 | * @return static |
||
1504 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1505 | * |
||
1506 | * @psalm-param \Traversable<array-key,mixed> $object |
||
1507 | * |
||
1508 | * @psalm-mutation-free |
||
1509 | */ |
||
1510 | 4 | public static function createFromObject(\Traversable $object): self |
|
1530 | |||
1531 | /** |
||
1532 | * Create an new instance filled with values from an object. |
||
1533 | * |
||
1534 | * @param object $object |
||
1535 | * |
||
1536 | * @return static |
||
1537 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1538 | * |
||
1539 | * @psalm-mutation-free |
||
1540 | */ |
||
1541 | 5 | public static function createFromObjectVars($object): self |
|
1545 | |||
1546 | /** |
||
1547 | * Create an new Arrayy object via string. |
||
1548 | * |
||
1549 | * @param string $str <p>The input string.</p> |
||
1550 | * @param string|null $delimiter <p>The boundary string.</p> |
||
1551 | * @param string|null $regEx <p>Use the $delimiter or the $regEx, so if $pattern is null, $delimiter will be |
||
1552 | * used.</p> |
||
1553 | * |
||
1554 | * @return static |
||
1555 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1556 | * |
||
1557 | * @psalm-mutation-free |
||
1558 | */ |
||
1559 | 10 | public static function createFromString(string $str, string $delimiter = null, string $regEx = null): self |
|
1591 | |||
1592 | /** |
||
1593 | * Create an new instance filled with a copy of values from a "Traversable"-object. |
||
1594 | * |
||
1595 | * @param \Traversable $traversable |
||
1596 | * |
||
1597 | * @return static |
||
1598 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1599 | * |
||
1600 | * @psalm-param \Traversable<array-key,mixed> $traversable |
||
1601 | * |
||
1602 | * @psalm-mutation-free |
||
1603 | */ |
||
1604 | 1 | public static function createFromTraversableImmutable(\Traversable $traversable): self |
|
1608 | |||
1609 | /** |
||
1610 | * Create an new instance containing a range of elements. |
||
1611 | * |
||
1612 | * @param float|int|string $low <p>First value of the sequence.</p> |
||
1613 | * @param float|int|string $high <p>The sequence is ended upon reaching the end value.</p> |
||
1614 | * @param float|int $step <p>Used as the increment between elements in the sequence.</p> |
||
1615 | * |
||
1616 | * @return static |
||
1617 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1618 | * |
||
1619 | * @psalm-mutation-free |
||
1620 | */ |
||
1621 | 2 | public static function createWithRange($low, $high, $step = 1): self |
|
1625 | |||
1626 | /** |
||
1627 | * Gets the element of the array at the current internal iterator position. |
||
1628 | * |
||
1629 | * @return false|mixed |
||
1630 | */ |
||
1631 | public function current() |
||
1635 | |||
1636 | /** |
||
1637 | * Custom sort by index via "uksort". |
||
1638 | * |
||
1639 | * @see http://php.net/manual/en/function.uksort.php |
||
1640 | * |
||
1641 | * @param callable $function |
||
1642 | * |
||
1643 | * @throws \InvalidArgumentException |
||
1644 | * |
||
1645 | * @return $this |
||
1646 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1647 | * |
||
1648 | * @psalm-return static<TKey,T> |
||
1649 | */ |
||
1650 | 5 | public function customSortKeys(callable $function): self |
|
1658 | |||
1659 | /** |
||
1660 | * Custom sort by index via "uksort". |
||
1661 | * |
||
1662 | * @see http://php.net/manual/en/function.uksort.php |
||
1663 | * |
||
1664 | * @param callable $function |
||
1665 | * |
||
1666 | * @throws \InvalidArgumentException |
||
1667 | * |
||
1668 | * @return $this |
||
1669 | * <p>(Immutable) Return this Arrayy object.</p> |
||
1670 | * |
||
1671 | * @psalm-return static<TKey,T> |
||
1672 | * @psalm-mutation-free |
||
1673 | */ |
||
1674 | 1 | public function customSortKeysImmutable(callable $function): self |
|
1684 | |||
1685 | /** |
||
1686 | * Custom sort by value via "usort". |
||
1687 | * |
||
1688 | * @see http://php.net/manual/en/function.usort.php |
||
1689 | * |
||
1690 | * @param callable $function |
||
1691 | * |
||
1692 | * @throws \InvalidArgumentException |
||
1693 | * |
||
1694 | * @return $this |
||
1695 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1696 | * |
||
1697 | * @psalm-return static<TKey,T> |
||
1698 | */ |
||
1699 | 10 | View Code Duplication | public function customSortValues($function): self |
1711 | |||
1712 | /** |
||
1713 | * Custom sort by value via "usort". |
||
1714 | * |
||
1715 | * @see http://php.net/manual/en/function.usort.php |
||
1716 | * |
||
1717 | * @param callable $function |
||
1718 | * |
||
1719 | * @throws \InvalidArgumentException |
||
1720 | * |
||
1721 | * @return $this |
||
1722 | * <p>(Immutable) Return this Arrayy object.</p> |
||
1723 | * |
||
1724 | * @psalm-return static<TKey,T> |
||
1725 | * @psalm-mutation-free |
||
1726 | */ |
||
1727 | 4 | public function customSortValuesImmutable($function): self |
|
1738 | |||
1739 | /** |
||
1740 | * Delete the given key or keys. |
||
1741 | * |
||
1742 | * @param int|int[]|string|string[] $keyOrKeys |
||
1743 | * |
||
1744 | * @return void |
||
1745 | */ |
||
1746 | 4 | public function delete($keyOrKeys) |
|
1754 | |||
1755 | /** |
||
1756 | * Return values that are only in the current array. |
||
1757 | * |
||
1758 | * @param array ...$array |
||
1759 | * |
||
1760 | * @return static |
||
1761 | * <p>(Immutable)</p> |
||
1762 | * |
||
1763 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
1764 | * @psalm-return static<TKey,T> |
||
1765 | * @psalm-mutation-free |
||
1766 | */ |
||
1767 | 13 | public function diff(...$array): self |
|
1775 | |||
1776 | /** |
||
1777 | * Return values that are only in the current array. |
||
1778 | * |
||
1779 | * @param array ...$array |
||
1780 | * |
||
1781 | * @return static |
||
1782 | * <p>(Immutable)</p> |
||
1783 | * |
||
1784 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
1785 | * @psalm-return static<TKey,T> |
||
1786 | * @psalm-mutation-free |
||
1787 | */ |
||
1788 | 8 | public function diffKey(...$array): self |
|
1796 | |||
1797 | /** |
||
1798 | * Return values and Keys that are only in the current array. |
||
1799 | * |
||
1800 | * @param array $array |
||
1801 | * |
||
1802 | * @return static |
||
1803 | * <p>(Immutable)</p> |
||
1804 | * |
||
1805 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1806 | * @psalm-return static<TKey,T> |
||
1807 | * @psalm-mutation-free |
||
1808 | */ |
||
1809 | 8 | public function diffKeyAndValue(array $array = []): self |
|
1817 | |||
1818 | /** |
||
1819 | * Return values that are only in the current multi-dimensional array. |
||
1820 | * |
||
1821 | * @param array $array |
||
1822 | * @param array|\Generator|null $helperVariableForRecursion <p>(only for internal usage)</p> |
||
1823 | * |
||
1824 | * @return static |
||
1825 | * <p>(Immutable)</p> |
||
1826 | * |
||
1827 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1828 | * @psalm-param null|array<TKey,T>|\Generator<TKey,T> $helperVariableForRecursion |
||
1829 | * @psalm-return static<TKey,T> |
||
1830 | * @psalm-mutation-free |
||
1831 | */ |
||
1832 | 1 | public function diffRecursive(array $array = [], $helperVariableForRecursion = null): self |
|
1867 | |||
1868 | /** |
||
1869 | * Return values that are only in the new $array. |
||
1870 | * |
||
1871 | * @param array $array |
||
1872 | * |
||
1873 | * @return static |
||
1874 | * <p>(Immutable)</p> |
||
1875 | * |
||
1876 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1877 | * @psalm-return static<TKey,T> |
||
1878 | * @psalm-mutation-free |
||
1879 | */ |
||
1880 | 8 | public function diffReverse(array $array = []): self |
|
1888 | |||
1889 | /** |
||
1890 | * Divide an array into two arrays. One with keys and the other with values. |
||
1891 | * |
||
1892 | * @return static |
||
1893 | * <p>(Immutable)</p> |
||
1894 | * |
||
1895 | * @psalm-return static<TKey,T> |
||
1896 | * @psalm-mutation-free |
||
1897 | */ |
||
1898 | 1 | public function divide(): self |
|
1909 | |||
1910 | /** |
||
1911 | * Iterate over the current array and modify the array's value. |
||
1912 | * |
||
1913 | * @param \Closure $closure |
||
1914 | * |
||
1915 | * @return static |
||
1916 | * <p>(Immutable)</p> |
||
1917 | * |
||
1918 | * @psalm-return static<TKey,T> |
||
1919 | * @psalm-mutation-free |
||
1920 | */ |
||
1921 | 5 | View Code Duplication | public function each(\Closure $closure): self |
1936 | |||
1937 | /** |
||
1938 | * Sets the internal iterator to the last element in the array and returns this element. |
||
1939 | * |
||
1940 | * @return mixed |
||
1941 | */ |
||
1942 | public function end() |
||
1946 | |||
1947 | /** |
||
1948 | * Check if a value is in the current array using a closure. |
||
1949 | * |
||
1950 | * @param \Closure $closure |
||
1951 | * |
||
1952 | * @return bool |
||
1953 | * <p>Returns true if the given value is found, false otherwise.</p> |
||
1954 | */ |
||
1955 | 4 | public function exists(\Closure $closure): bool |
|
1970 | |||
1971 | /** |
||
1972 | * Fill the array until "$num" with "$default" values. |
||
1973 | * |
||
1974 | * @param int $num |
||
1975 | * @param mixed $default |
||
1976 | * |
||
1977 | * @return static |
||
1978 | * <p>(Immutable)</p> |
||
1979 | * |
||
1980 | * @psalm-return static<TKey,T> |
||
1981 | * @psalm-mutation-free |
||
1982 | */ |
||
1983 | 8 | public function fillWithDefaults(int $num, $default = null): self |
|
2006 | |||
2007 | /** |
||
2008 | * Find all items in an array that pass the truth test. |
||
2009 | * |
||
2010 | * @param \Closure|null $closure [optional] <p> |
||
2011 | * The callback function to use |
||
2012 | * </p> |
||
2013 | * <p> |
||
2014 | * If no callback is supplied, all entries of |
||
2015 | * input equal to false (see |
||
2016 | * converting to |
||
2017 | * boolean) will be removed. |
||
2018 | * </p> |
||
2019 | * @param int $flag [optional] <p> |
||
2020 | * Flag determining what arguments are sent to <i>callback</i>: |
||
2021 | * </p><ul> |
||
2022 | * <li> |
||
2023 | * <b>ARRAY_FILTER_USE_KEY</b> [1] - pass key as the only argument |
||
2024 | * to <i>callback</i> instead of the value</span> |
||
2025 | * </li> |
||
2026 | * <li> |
||
2027 | * <b>ARRAY_FILTER_USE_BOTH</b> [2] - pass both value and key as |
||
2028 | * arguments to <i>callback</i> instead of the value</span> |
||
2029 | * </li> |
||
2030 | * </ul> |
||
2031 | * |
||
2032 | * @return static |
||
2033 | * <p>(Immutable)</p> |
||
2034 | * |
||
2035 | * @psalm-param \Closure(T=,TKey=):bool|\Closure(T=):bool $closure |
||
2036 | * @psalm-return static<TKey,T> |
||
2037 | * @psalm-mutation-free |
||
2038 | */ |
||
2039 | 12 | public function filter($closure = null, int $flag = \ARRAY_FILTER_USE_BOTH) |
|
2051 | |||
2052 | /** |
||
2053 | * Filters an array of objects (or a numeric array of associative arrays) based on the value of a particular |
||
2054 | * property within that. |
||
2055 | * |
||
2056 | * @param string $property |
||
2057 | * @param string|string[] $value |
||
2058 | * @param string $comparisonOp |
||
2059 | * <p> |
||
2060 | * 'eq' (equals),<br /> |
||
2061 | * 'gt' (greater),<br /> |
||
2062 | * 'gte' || 'ge' (greater or equals),<br /> |
||
2063 | * 'lt' (less),<br /> |
||
2064 | * 'lte' || 'le' (less or equals),<br /> |
||
2065 | * 'ne' (not equals),<br /> |
||
2066 | * 'contains',<br /> |
||
2067 | * 'notContains',<br /> |
||
2068 | * 'newer' (via strtotime),<br /> |
||
2069 | * 'older' (via strtotime),<br /> |
||
2070 | * </p> |
||
2071 | * |
||
2072 | * @return static |
||
2073 | * <p>(Immutable)</p> |
||
2074 | * |
||
2075 | * @psalm-return static<TKey,T> |
||
2076 | * @psalm-mutation-free |
||
2077 | * |
||
2078 | * @psalm-suppress MissingClosureReturnType |
||
2079 | * @psalm-suppress MissingClosureParamType |
||
2080 | */ |
||
2081 | 1 | public function filterBy( |
|
2153 | |||
2154 | /** |
||
2155 | * Find the first item in an array that passes the truth test, |
||
2156 | * otherwise return false |
||
2157 | * |
||
2158 | * @param \Closure $closure |
||
2159 | * |
||
2160 | * @return false|mixed |
||
2161 | * <p>Return false if we did not find the value.</p> |
||
2162 | */ |
||
2163 | 8 | View Code Duplication | public function find(\Closure $closure) |
2173 | |||
2174 | /** |
||
2175 | * find by ... |
||
2176 | * |
||
2177 | * @param string $property |
||
2178 | * @param string|string[] $value |
||
2179 | * @param string $comparisonOp |
||
2180 | * |
||
2181 | * @return static |
||
2182 | * <p>(Immutable)</p> |
||
2183 | * |
||
2184 | * @psalm-return static<TKey,T> |
||
2185 | * @psalm-mutation-free |
||
2186 | */ |
||
2187 | 1 | public function findBy(string $property, $value, string $comparisonOp = 'eq'): self |
|
2191 | |||
2192 | /** |
||
2193 | * Get the first value from the current array. |
||
2194 | * |
||
2195 | * @return mixed |
||
2196 | * <p>Return null if there wasn't a element.</p> |
||
2197 | */ |
||
2198 | 22 | public function first() |
|
2207 | |||
2208 | /** |
||
2209 | * Get the first key from the current array. |
||
2210 | * |
||
2211 | * @return mixed |
||
2212 | * <p>Return null if there wasn't a element.</p> |
||
2213 | * @psalm-mutation-free |
||
2214 | */ |
||
2215 | 29 | public function firstKey() |
|
2221 | |||
2222 | /** |
||
2223 | * Get the first value(s) from the current array. |
||
2224 | * And will return an empty array if there was no first entry. |
||
2225 | * |
||
2226 | * @param int|null $number <p>How many values you will take?</p> |
||
2227 | * |
||
2228 | * @return static |
||
2229 | * <p>(Immutable)</p> |
||
2230 | * |
||
2231 | * @psalm-return static<TKey,T> |
||
2232 | * @psalm-mutation-free |
||
2233 | */ |
||
2234 | 37 | View Code Duplication | public function firstsImmutable(int $number = null): self |
2251 | |||
2252 | /** |
||
2253 | * Get the first value(s) from the current array. |
||
2254 | * And will return an empty array if there was no first entry. |
||
2255 | * |
||
2256 | * @param int|null $number <p>How many values you will take?</p> |
||
2257 | * |
||
2258 | * @return static |
||
2259 | * <p>(Immutable)</p> |
||
2260 | * |
||
2261 | * @psalm-return static<TKey,T> |
||
2262 | * @psalm-mutation-free |
||
2263 | */ |
||
2264 | 3 | View Code Duplication | public function firstsKeys(int $number = null): self |
2281 | |||
2282 | /** |
||
2283 | * Get and rmove the first value(s) from the current array. |
||
2284 | * And will return an empty array if there was no first entry. |
||
2285 | * |
||
2286 | * @param int|null $number <p>How many values you will take?</p> |
||
2287 | * |
||
2288 | * @return $this |
||
2289 | * <p>(Mutable)</p> |
||
2290 | * |
||
2291 | * @psalm-return static<TKey,T> |
||
2292 | */ |
||
2293 | 34 | public function firstsMutable(int $number = null): self |
|
2306 | |||
2307 | /** |
||
2308 | * Exchanges all keys with their associated values in an array. |
||
2309 | * |
||
2310 | * @return static |
||
2311 | * <p>(Immutable)</p> |
||
2312 | * |
||
2313 | * @psalm-return static<TKey,T> |
||
2314 | * @psalm-mutation-free |
||
2315 | */ |
||
2316 | 1 | public function flip(): self |
|
2324 | |||
2325 | /** |
||
2326 | * Get a value from an array (optional using dot-notation). |
||
2327 | * |
||
2328 | * @param mixed $key <p>The key to look for.</p> |
||
2329 | * @param mixed $fallback <p>Value to fallback to.</p> |
||
2330 | * @param array $array <p>The array to get from, if it's set to "null" we use the current array from the |
||
2331 | * class.</p> |
||
2332 | * |
||
2333 | * @return mixed|static |
||
2334 | * |
||
2335 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
2336 | * @psalm-mutation-free |
||
2337 | */ |
||
2338 | 172 | public function get($key, $fallback = null, array $array = null) |
|
2430 | |||
2431 | /** |
||
2432 | * alias: for "Arrayy->toArray()" |
||
2433 | * |
||
2434 | * @return array |
||
2435 | * |
||
2436 | * @see Arrayy::getArray() |
||
2437 | * |
||
2438 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
2439 | */ |
||
2440 | 1 | public function getAll(): array |
|
2444 | |||
2445 | /** |
||
2446 | * Get the current array from the "Arrayy"-object. |
||
2447 | * |
||
2448 | * alias for "toArray()" |
||
2449 | * |
||
2450 | * @param bool $convertAllArrayyElements <p> |
||
2451 | * Convert all Child-"Arrayy" objects also to arrays. |
||
2452 | * </p> |
||
2453 | * @param bool $preserveKeys <p> |
||
2454 | * e.g.: A generator maybe return the same key more then once, |
||
2455 | * so maybe you will ignore the keys. |
||
2456 | * </p> |
||
2457 | * |
||
2458 | * @return array |
||
2459 | * |
||
2460 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
2461 | * @psalm-mutation-free |
||
2462 | * |
||
2463 | * @see Arrayy::toArray() |
||
2464 | */ |
||
2465 | 481 | public function getArray( |
|
2466 | bool $convertAllArrayyElements = false, |
||
2467 | bool $preserveKeys = true |
||
2468 | ): array { |
||
2469 | 481 | return $this->toArray( |
|
2470 | 481 | $convertAllArrayyElements, |
|
2471 | $preserveKeys |
||
2472 | ); |
||
2473 | } |
||
2474 | |||
2475 | /** |
||
2476 | * Get the current array from the "Arrayy"-object as list. |
||
2477 | * |
||
2478 | * alias for "toList()" |
||
2479 | * |
||
2480 | * @param bool $convertAllArrayyElements <p> |
||
2481 | * Convert all Child-"Arrayy" objects also to arrays. |
||
2482 | * </p> |
||
2483 | * |
||
2484 | * @return array |
||
2485 | * |
||
2486 | * @psalm-return array<int,mixed>|array<int,T> |
||
2487 | * @psalm-mutation-free |
||
2488 | * |
||
2489 | * @see Arrayy::toList() |
||
2490 | */ |
||
2491 | 1 | public function getList(bool $convertAllArrayyElements = false): array |
|
2495 | |||
2496 | /** |
||
2497 | * Returns the values from a single column of the input array, identified by |
||
2498 | * the $columnKey, can be used to extract data-columns from multi-arrays. |
||
2499 | * |
||
2500 | * Info: Optionally, you may provide an $indexKey to index the values in the returned |
||
2501 | * array by the values from the $indexKey column in the input array. |
||
2502 | * |
||
2503 | * @param mixed $columnKey |
||
2504 | * @param mixed $indexKey |
||
2505 | * |
||
2506 | * @return static |
||
2507 | * <p>(Immutable)</p> |
||
2508 | * |
||
2509 | * @psalm-return static<TKey,T> |
||
2510 | * @psalm-mutation-free |
||
2511 | */ |
||
2512 | 1 | public function getColumn($columnKey = null, $indexKey = null): self |
|
2520 | |||
2521 | /** |
||
2522 | * Get the current array from the "Arrayy"-object as generator. |
||
2523 | * |
||
2524 | * @return \Generator |
||
2525 | * |
||
2526 | * @psalm-return \Generator<mixed,T>|\Generator<TKey,T> |
||
2527 | * @psalm-mutation-free |
||
2528 | */ |
||
2529 | 974 | public function getGenerator(): \Generator |
|
2537 | |||
2538 | /** |
||
2539 | * alias: for "Arrayy->keys()" |
||
2540 | * |
||
2541 | * @return static |
||
2542 | * <p>(Immutable)</p> |
||
2543 | * |
||
2544 | * @see Arrayy::keys() |
||
2545 | * |
||
2546 | * @psalm-return static<array-key,TKey> |
||
2547 | * @psalm-mutation-free |
||
2548 | */ |
||
2549 | 2 | public function getKeys() |
|
2553 | |||
2554 | /** |
||
2555 | * Get the current array from the "Arrayy"-object as object. |
||
2556 | * |
||
2557 | * @return \stdClass |
||
2558 | */ |
||
2559 | 4 | public function getObject(): \stdClass |
|
2563 | |||
2564 | /** |
||
2565 | * alias: for "Arrayy->randomImmutable()" |
||
2566 | * |
||
2567 | * @return static |
||
2568 | * <p>(Immutable)</p> |
||
2569 | * |
||
2570 | * @see Arrayy::randomImmutable() |
||
2571 | * |
||
2572 | * @psalm-return static<int|array-key,T> |
||
2573 | */ |
||
2574 | 4 | public function getRandom(): self |
|
2578 | |||
2579 | /** |
||
2580 | * alias: for "Arrayy->randomKey()" |
||
2581 | * |
||
2582 | * @return mixed |
||
2583 | * <p>Get a key/index or null if there wasn't a key/index.</p> |
||
2584 | * |
||
2585 | * @see Arrayy::randomKey() |
||
2586 | */ |
||
2587 | 3 | public function getRandomKey() |
|
2591 | |||
2592 | /** |
||
2593 | * alias: for "Arrayy->randomKeys()" |
||
2594 | * |
||
2595 | * @param int $number |
||
2596 | * |
||
2597 | * @return static |
||
2598 | * <p>(Immutable)</p> |
||
2599 | * |
||
2600 | * @see Arrayy::randomKeys() |
||
2601 | * |
||
2602 | * @psalm-return static<TKey,T> |
||
2603 | */ |
||
2604 | 8 | public function getRandomKeys(int $number): self |
|
2608 | |||
2609 | /** |
||
2610 | * alias: for "Arrayy->randomValue()" |
||
2611 | * |
||
2612 | * @return mixed |
||
2613 | * <p>Get a random value or null if there wasn't a value.</p> |
||
2614 | * |
||
2615 | * @see Arrayy::randomValue() |
||
2616 | */ |
||
2617 | 3 | public function getRandomValue() |
|
2621 | |||
2622 | /** |
||
2623 | * alias: for "Arrayy->randomValues()" |
||
2624 | * |
||
2625 | * @param int $number |
||
2626 | * |
||
2627 | * @return static |
||
2628 | * <p>(Immutable)</p> |
||
2629 | * |
||
2630 | * @see Arrayy::randomValues() |
||
2631 | * |
||
2632 | * @psalm-return static<TKey,T> |
||
2633 | */ |
||
2634 | 6 | public function getRandomValues(int $number): self |
|
2638 | |||
2639 | /** |
||
2640 | * Gets all values. |
||
2641 | * |
||
2642 | * @return static |
||
2643 | * <p>The values of all elements in this array, in the order they |
||
2644 | * appear in the array.</p> |
||
2645 | * |
||
2646 | * @psalm-return static<TKey,T> |
||
2647 | */ |
||
2648 | 4 | public function getValues() |
|
2658 | |||
2659 | /** |
||
2660 | * Gets all values via Generator. |
||
2661 | * |
||
2662 | * @return \Generator |
||
2663 | * <p>The values of all elements in this array, in the order they |
||
2664 | * appear in the array as Generator.</p> |
||
2665 | * |
||
2666 | * @psalm-return \Generator<TKey,T> |
||
2667 | */ |
||
2668 | 4 | public function getValuesYield(): \Generator |
|
2672 | |||
2673 | /** |
||
2674 | * Group values from a array according to the results of a closure. |
||
2675 | * |
||
2676 | * @param callable|string $grouper <p>A callable function name.</p> |
||
2677 | * @param bool $saveKeys |
||
2678 | * |
||
2679 | * @return static |
||
2680 | * <p>(Immutable)</p> |
||
2681 | * |
||
2682 | * @psalm-return static<TKey,T> |
||
2683 | * @psalm-mutation-free |
||
2684 | */ |
||
2685 | 4 | public function group($grouper, bool $saveKeys = false): self |
|
2726 | |||
2727 | /** |
||
2728 | * Check if an array has a given key. |
||
2729 | * |
||
2730 | * @param mixed $key |
||
2731 | * |
||
2732 | * @return bool |
||
2733 | */ |
||
2734 | 23 | public function has($key): bool |
|
2745 | |||
2746 | /** |
||
2747 | * Check if an array has a given value. |
||
2748 | * |
||
2749 | * INFO: if you need to search recursive please use ```contains()``` |
||
2750 | * |
||
2751 | * @param mixed $value |
||
2752 | * |
||
2753 | * @return bool |
||
2754 | */ |
||
2755 | 1 | public function hasValue($value): bool |
|
2759 | |||
2760 | /** |
||
2761 | * Implodes the values of this array. |
||
2762 | * |
||
2763 | * @param string $glue |
||
2764 | * |
||
2765 | * @return string |
||
2766 | * @psalm-mutation-free |
||
2767 | */ |
||
2768 | 28 | public function implode(string $glue = ''): string |
|
2772 | |||
2773 | /** |
||
2774 | * Implodes the keys of this array. |
||
2775 | * |
||
2776 | * @param string $glue |
||
2777 | * |
||
2778 | * @return string |
||
2779 | * @psalm-mutation-free |
||
2780 | */ |
||
2781 | 8 | public function implodeKeys(string $glue = ''): string |
|
2785 | |||
2786 | /** |
||
2787 | * Given a list and an iterate-function that returns |
||
2788 | * a key for each element in the list (or a property name), |
||
2789 | * returns an object with an index of each item. |
||
2790 | * |
||
2791 | * @param mixed $key |
||
2792 | * |
||
2793 | * @return static |
||
2794 | * <p>(Immutable)</p> |
||
2795 | * |
||
2796 | * @psalm-return static<TKey,T> |
||
2797 | * @psalm-mutation-free |
||
2798 | */ |
||
2799 | 4 | public function indexBy($key): self |
|
2816 | |||
2817 | /** |
||
2818 | * alias: for "Arrayy->searchIndex()" |
||
2819 | * |
||
2820 | * @param mixed $value <p>The value to search for.</p> |
||
2821 | * |
||
2822 | * @return false|mixed |
||
2823 | * |
||
2824 | * @see Arrayy::searchIndex() |
||
2825 | */ |
||
2826 | 4 | public function indexOf($value) |
|
2830 | |||
2831 | /** |
||
2832 | * Get everything but the last..$to items. |
||
2833 | * |
||
2834 | * @param int $to |
||
2835 | * |
||
2836 | * @return static |
||
2837 | * <p>(Immutable)</p> |
||
2838 | * |
||
2839 | * @psalm-return static<TKey,T> |
||
2840 | * @psalm-mutation-free |
||
2841 | */ |
||
2842 | 12 | public function initial(int $to = 1): self |
|
2846 | |||
2847 | /** |
||
2848 | * Return an array with all elements found in input array. |
||
2849 | * |
||
2850 | * @param array $search |
||
2851 | * @param bool $keepKeys |
||
2852 | * |
||
2853 | * @return static |
||
2854 | * <p>(Immutable)</p> |
||
2855 | * |
||
2856 | * @psalm-param array<mixed,mixed>|array<TKey,T> $search |
||
2857 | * @psalm-return static<TKey,T> |
||
2858 | * @psalm-mutation-free |
||
2859 | */ |
||
2860 | 4 | public function intersection(array $search, bool $keepKeys = false): self |
|
2886 | |||
2887 | /** |
||
2888 | * Return an array with all elements found in input array. |
||
2889 | * |
||
2890 | * @param array ...$array |
||
2891 | * |
||
2892 | * @return static |
||
2893 | * <p>(Immutable)</p> |
||
2894 | * |
||
2895 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
2896 | * @psalm-return static<TKey,T> |
||
2897 | * @psalm-mutation-free |
||
2898 | */ |
||
2899 | 1 | public function intersectionMulti(...$array): self |
|
2907 | |||
2908 | /** |
||
2909 | * Return a boolean flag which indicates whether the two input arrays have any common elements. |
||
2910 | * |
||
2911 | * @param array $search |
||
2912 | * |
||
2913 | * @return bool |
||
2914 | * |
||
2915 | * @psalm-param array<mixed,mixed>|array<TKey,T> $search |
||
2916 | */ |
||
2917 | 1 | public function intersects(array $search): bool |
|
2921 | |||
2922 | /** |
||
2923 | * Invoke a function on all of an array's values. |
||
2924 | * |
||
2925 | * @param callable $callable |
||
2926 | * @param mixed $arguments |
||
2927 | * |
||
2928 | * @return static |
||
2929 | * <p>(Immutable)</p> |
||
2930 | * |
||
2931 | * @psalm-param callable(T=,mixed):mixed $callable |
||
2932 | * @psalm-return static<TKey,T> |
||
2933 | * @psalm-mutation-free |
||
2934 | */ |
||
2935 | 1 | public function invoke($callable, $arguments = []): self |
|
2959 | |||
2960 | /** |
||
2961 | * Check whether array is associative or not. |
||
2962 | * |
||
2963 | * @param bool $recursive |
||
2964 | * |
||
2965 | * @return bool |
||
2966 | * <p>Returns true if associative, false otherwise.</p> |
||
2967 | */ |
||
2968 | 15 | View Code Duplication | public function isAssoc(bool $recursive = false): bool |
2982 | |||
2983 | /** |
||
2984 | * Check if a given key or keys are empty. |
||
2985 | * |
||
2986 | * @param int|int[]|string|string[]|null $keys |
||
2987 | * |
||
2988 | * @return bool |
||
2989 | * <p>Returns true if empty, false otherwise.</p> |
||
2990 | * @psalm-mutation-free |
||
2991 | */ |
||
2992 | 38 | public function isEmpty($keys = null): bool |
|
3010 | |||
3011 | /** |
||
3012 | * Check if the current array is equal to the given "$array" or not. |
||
3013 | * |
||
3014 | * @param array $array |
||
3015 | * |
||
3016 | * @return bool |
||
3017 | * |
||
3018 | * @psalm-param array<mixed,mixed> $array |
||
3019 | */ |
||
3020 | 1 | public function isEqual(array $array): bool |
|
3024 | |||
3025 | /** |
||
3026 | * Check if the current array is a multi-array. |
||
3027 | * |
||
3028 | * @return bool |
||
3029 | */ |
||
3030 | 22 | public function isMultiArray(): bool |
|
3038 | |||
3039 | /** |
||
3040 | * Check whether array is numeric or not. |
||
3041 | * |
||
3042 | * @return bool |
||
3043 | * <p>Returns true if numeric, false otherwise.</p> |
||
3044 | */ |
||
3045 | 5 | View Code Duplication | public function isNumeric(): bool |
3059 | |||
3060 | /** |
||
3061 | * Check if the current array is sequential [0, 1, 2, 3, 4, 5 ...] or not. |
||
3062 | * |
||
3063 | * @param bool $recursive |
||
3064 | * |
||
3065 | * @return bool |
||
3066 | * @psalm-mutation-free |
||
3067 | */ |
||
3068 | 9 | public function isSequential(bool $recursive = false): bool |
|
3085 | |||
3086 | /** |
||
3087 | * @return array |
||
3088 | * |
||
3089 | * @psalm-return array<TKey,T> |
||
3090 | */ |
||
3091 | public function jsonSerialize(): array |
||
3095 | |||
3096 | /** |
||
3097 | * Gets the key/index of the element at the current internal iterator position. |
||
3098 | * |
||
3099 | * @return int|string|null |
||
3100 | */ |
||
3101 | public function key() |
||
3105 | |||
3106 | /** |
||
3107 | * Checks if the given key exists in the provided array. |
||
3108 | * |
||
3109 | * INFO: This method only use "array_key_exists()" if you want to use "dot"-notation, |
||
3110 | * then you need to use "Arrayy->offsetExists()". |
||
3111 | * |
||
3112 | * @param int|string $key the key to look for |
||
3113 | * |
||
3114 | * @return bool |
||
3115 | * @psalm-mutation-free |
||
3116 | */ |
||
3117 | 127 | public function keyExists($key): bool |
|
3121 | |||
3122 | /** |
||
3123 | * Get all keys from the current array. |
||
3124 | * |
||
3125 | * @param bool $recursive [optional] <p> |
||
3126 | * Get all keys, also from all sub-arrays from an multi-dimensional array. |
||
3127 | * </p> |
||
3128 | * @param mixed|null $search_values [optional] <p> |
||
3129 | * If specified, then only keys containing these values are returned. |
||
3130 | * </p> |
||
3131 | * @param bool $strict [optional] <p> |
||
3132 | * Determines if strict comparison (===) should be used during the search. |
||
3133 | * </p> |
||
3134 | * |
||
3135 | * @return static |
||
3136 | * <p>(Immutable) An array of all the keys in input.</p> |
||
3137 | * |
||
3138 | * @psalm-return static<array-key,TKey> |
||
3139 | * @psalm-mutation-free |
||
3140 | */ |
||
3141 | 29 | public function keys( |
|
3211 | |||
3212 | /** |
||
3213 | * Sort an array by key in reverse order. |
||
3214 | * |
||
3215 | * @param int $sort_flags [optional] <p> |
||
3216 | * You may modify the behavior of the sort using the optional |
||
3217 | * parameter sort_flags, for details |
||
3218 | * see sort. |
||
3219 | * </p> |
||
3220 | * |
||
3221 | * @return $this |
||
3222 | * <p>(Mutable) Return this Arrayy object.</p> |
||
3223 | * |
||
3224 | * @psalm-return static<TKey,T> |
||
3225 | */ |
||
3226 | 4 | public function krsort(int $sort_flags = 0): self |
|
3234 | |||
3235 | /** |
||
3236 | * Sort an array by key in reverse order. |
||
3237 | * |
||
3238 | * @param int $sort_flags [optional] <p> |
||
3239 | * You may modify the behavior of the sort using the optional |
||
3240 | * parameter sort_flags, for details |
||
3241 | * see sort. |
||
3242 | * </p> |
||
3243 | * |
||
3244 | * @return $this |
||
3245 | * <p>(Immutable) Return this Arrayy object.</p> |
||
3246 | * |
||
3247 | * @psalm-return static<TKey,T> |
||
3248 | * @psalm-mutation-free |
||
3249 | */ |
||
3250 | 4 | public function krsortImmutable(int $sort_flags = 0): self |
|
3261 | |||
3262 | /** |
||
3263 | * Get the last value from the current array. |
||
3264 | * |
||
3265 | * @return mixed|null |
||
3266 | * <p>Return null if there wasn't a element.</p> |
||
3267 | * @psalm-mutation-free |
||
3268 | */ |
||
3269 | 17 | public function last() |
|
3278 | |||
3279 | /** |
||
3280 | * Get the last key from the current array. |
||
3281 | * |
||
3282 | * @return mixed|null |
||
3283 | * <p>Return null if there wasn't a element.</p> |
||
3284 | * @psalm-mutation-free |
||
3285 | */ |
||
3286 | 21 | public function lastKey() |
|
3292 | |||
3293 | /** |
||
3294 | * Get the last value(s) from the current array. |
||
3295 | * |
||
3296 | * @param int|null $number |
||
3297 | * |
||
3298 | * @return static |
||
3299 | * <p>(Immutable)</p> |
||
3300 | * |
||
3301 | * @psalm-return static<TKey,T> |
||
3302 | * @psalm-mutation-free |
||
3303 | */ |
||
3304 | 13 | public function lastsImmutable(int $number = null): self |
|
3335 | |||
3336 | /** |
||
3337 | * Get the last value(s) from the current array. |
||
3338 | * |
||
3339 | * @param int|null $number |
||
3340 | * |
||
3341 | * @return $this |
||
3342 | * <p>(Mutable)</p> |
||
3343 | * |
||
3344 | * @psalm-return static<TKey,T> |
||
3345 | */ |
||
3346 | 13 | public function lastsMutable(int $number = null): self |
|
3375 | |||
3376 | /** |
||
3377 | * Count the values from the current array. |
||
3378 | * |
||
3379 | * alias: for "Arrayy->count()" |
||
3380 | * |
||
3381 | * @param int $mode |
||
3382 | * |
||
3383 | * @return int |
||
3384 | * |
||
3385 | * @see Arrayy::count() |
||
3386 | */ |
||
3387 | 20 | public function length(int $mode = \COUNT_NORMAL): int |
|
3391 | |||
3392 | /** |
||
3393 | * Apply the given function to the every element of the array, |
||
3394 | * collecting the results. |
||
3395 | * |
||
3396 | * @param callable $callable |
||
3397 | * @param bool $useKeyAsSecondParameter |
||
3398 | * @param mixed ...$arguments |
||
3399 | * |
||
3400 | * @return static |
||
3401 | * <p>(Immutable) Arrayy object with modified elements.</p> |
||
3402 | * |
||
3403 | * @psalm-param callable(T,TKey=,mixed=):mixed $callable |
||
3404 | * @psalm-return static<TKey,T> |
||
3405 | * @psalm-mutation-free |
||
3406 | */ |
||
3407 | 5 | public function map( |
|
3440 | |||
3441 | /** |
||
3442 | * Check if all items in current array match a truth test. |
||
3443 | * |
||
3444 | * @param \Closure $closure |
||
3445 | * |
||
3446 | * @return bool |
||
3447 | */ |
||
3448 | 15 | View Code Duplication | public function matches(\Closure $closure): bool |
3464 | |||
3465 | /** |
||
3466 | * Check if any item in the current array matches a truth test. |
||
3467 | * |
||
3468 | * @param \Closure $closure |
||
3469 | * |
||
3470 | * @return bool |
||
3471 | */ |
||
3472 | 14 | View Code Duplication | public function matchesAny(\Closure $closure): bool |
3488 | |||
3489 | /** |
||
3490 | * Get the max value from an array. |
||
3491 | * |
||
3492 | * @return false|mixed |
||
3493 | * <p>Will return false if there are no values.</p> |
||
3494 | */ |
||
3495 | 10 | View Code Duplication | public function max() |
3514 | |||
3515 | /** |
||
3516 | * Merge the new $array into the current array. |
||
3517 | * |
||
3518 | * - keep key,value from the current array, also if the index is in the new $array |
||
3519 | * |
||
3520 | * @param array $array |
||
3521 | * @param bool $recursive |
||
3522 | * |
||
3523 | * @return static |
||
3524 | * <p>(Immutable)</p> |
||
3525 | * |
||
3526 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3527 | * @psalm-return static<int|TKey,T> |
||
3528 | * @psalm-mutation-free |
||
3529 | */ |
||
3530 | 25 | View Code Duplication | public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self |
3544 | |||
3545 | /** |
||
3546 | * Merge the new $array into the current array. |
||
3547 | * |
||
3548 | * - replace duplicate assoc-keys from the current array with the key,values from the new $array |
||
3549 | * - create new indexes |
||
3550 | * |
||
3551 | * @param array $array |
||
3552 | * @param bool $recursive |
||
3553 | * |
||
3554 | * @return static |
||
3555 | * <p>(Immutable)</p> |
||
3556 | * |
||
3557 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3558 | * @psalm-return static<TKey,T> |
||
3559 | * @psalm-mutation-free |
||
3560 | */ |
||
3561 | 16 | View Code Duplication | public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self |
3575 | |||
3576 | /** |
||
3577 | * Merge the the current array into the $array. |
||
3578 | * |
||
3579 | * - use key,value from the new $array, also if the index is in the current array |
||
3580 | * |
||
3581 | * @param array $array |
||
3582 | * @param bool $recursive |
||
3583 | * |
||
3584 | * @return static |
||
3585 | * <p>(Immutable)</p> |
||
3586 | * |
||
3587 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3588 | * @psalm-return static<TKey,T> |
||
3589 | * @psalm-mutation-free |
||
3590 | */ |
||
3591 | 16 | View Code Duplication | public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self |
3605 | |||
3606 | /** |
||
3607 | * Merge the current array into the new $array. |
||
3608 | * |
||
3609 | * - replace duplicate assoc-keys from new $array with the key,values from the current array |
||
3610 | * - create new indexes |
||
3611 | * |
||
3612 | * @param array $array |
||
3613 | * @param bool $recursive |
||
3614 | * |
||
3615 | * @return static |
||
3616 | * <p>(Immutable)</p> |
||
3617 | * |
||
3618 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3619 | * @psalm-return static<TKey,T> |
||
3620 | * @psalm-mutation-free |
||
3621 | */ |
||
3622 | 17 | View Code Duplication | public function mergePrependNewIndex(array $array = [], bool $recursive = false): self |
3636 | |||
3637 | /** |
||
3638 | * @return ArrayyMeta|static |
||
3639 | */ |
||
3640 | 15 | public static function meta() |
|
3644 | |||
3645 | /** |
||
3646 | * Get the min value from an array. |
||
3647 | * |
||
3648 | * @return false|mixed |
||
3649 | * <p>Will return false if there are no values.</p> |
||
3650 | */ |
||
3651 | 10 | View Code Duplication | public function min() |
3670 | |||
3671 | /** |
||
3672 | * Get the most used value from the array. |
||
3673 | * |
||
3674 | * @return mixed|null |
||
3675 | * <p>(Immutable) Return null if there wasn't a element.</p> |
||
3676 | * @psalm-mutation-free |
||
3677 | */ |
||
3678 | 3 | public function mostUsedValue() |
|
3682 | |||
3683 | /** |
||
3684 | * Get the most used value from the array. |
||
3685 | * |
||
3686 | * @param int|null $number <p>How many values you will take?</p> |
||
3687 | * |
||
3688 | * @return static |
||
3689 | * <p>(Immutable)</p> |
||
3690 | * |
||
3691 | * @psalm-return static<TKey,T> |
||
3692 | * @psalm-mutation-free |
||
3693 | */ |
||
3694 | 3 | public function mostUsedValues(int $number = null): self |
|
3698 | |||
3699 | /** |
||
3700 | * Move an array element to a new index. |
||
3701 | * |
||
3702 | * cherry-picked from: http://stackoverflow.com/questions/12624153/move-an-array-element-to-a-new-index-in-php |
||
3703 | * |
||
3704 | * @param int|string $from |
||
3705 | * @param int $to |
||
3706 | * |
||
3707 | * @return static |
||
3708 | * <p>(Immutable)</p> |
||
3709 | * |
||
3710 | * @psalm-return static<TKey,T> |
||
3711 | * @psalm-mutation-free |
||
3712 | */ |
||
3713 | 1 | public function moveElement($from, $to): self |
|
3746 | |||
3747 | /** |
||
3748 | * Move an array element to the first place. |
||
3749 | * |
||
3750 | * INFO: Instead of "Arrayy->moveElement()" this method will NOT |
||
3751 | * loss the keys of an indexed array. |
||
3752 | * |
||
3753 | * @param int|string $key |
||
3754 | * |
||
3755 | * @return static |
||
3756 | * <p>(Immutable)</p> |
||
3757 | * |
||
3758 | * @psalm-return static<TKey,T> |
||
3759 | * @psalm-mutation-free |
||
3760 | */ |
||
3761 | 1 | View Code Duplication | public function moveElementToFirstPlace($key): self |
3777 | |||
3778 | /** |
||
3779 | * Move an array element to the last place. |
||
3780 | * |
||
3781 | * INFO: Instead of "Arrayy->moveElement()" this method will NOT |
||
3782 | * loss the keys of an indexed array. |
||
3783 | * |
||
3784 | * @param int|string $key |
||
3785 | * |
||
3786 | * @return static |
||
3787 | * <p>(Immutable)</p> |
||
3788 | * |
||
3789 | * @psalm-return static<TKey,T> |
||
3790 | * @psalm-mutation-free |
||
3791 | */ |
||
3792 | 1 | View Code Duplication | public function moveElementToLastPlace($key): self |
3808 | |||
3809 | /** |
||
3810 | * Moves the internal iterator position to the next element and returns this element. |
||
3811 | * |
||
3812 | * @return false|mixed |
||
3813 | * <p>(Mutable) Will return false if there are no values.</p> |
||
3814 | */ |
||
3815 | public function next() |
||
3819 | |||
3820 | /** |
||
3821 | * Get the next nth keys and values from the array. |
||
3822 | * |
||
3823 | * @param int $step |
||
3824 | * @param int $offset |
||
3825 | * |
||
3826 | * @return static |
||
3827 | * <p>(Immutable)</p> |
||
3828 | * |
||
3829 | * @psalm-return static<TKey,T> |
||
3830 | * @psalm-mutation-free |
||
3831 | */ |
||
3832 | 1 | public function nth(int $step, int $offset = 0): self |
|
3851 | |||
3852 | /** |
||
3853 | * Get a subset of the items from the given array. |
||
3854 | * |
||
3855 | * @param mixed[] $keys |
||
3856 | * |
||
3857 | * @return static |
||
3858 | * <p>(Immutable)</p> |
||
3859 | * |
||
3860 | * @psalm-return static<TKey,T> |
||
3861 | * @psalm-mutation-free |
||
3862 | */ |
||
3863 | 1 | public function only(array $keys): self |
|
3873 | |||
3874 | /** |
||
3875 | * Pad array to the specified size with a given value. |
||
3876 | * |
||
3877 | * @param int $size <p>Size of the result array.</p> |
||
3878 | * @param mixed $value <p>Empty value by default.</p> |
||
3879 | * |
||
3880 | * @return static |
||
3881 | * <p>(Immutable) Arrayy object padded to $size with $value.</p> |
||
3882 | * |
||
3883 | * @psalm-return static<TKey,T> |
||
3884 | * @psalm-mutation-free |
||
3885 | */ |
||
3886 | 5 | public function pad(int $size, $value): self |
|
3894 | |||
3895 | /** |
||
3896 | * Partitions this array in two array according to a predicate. |
||
3897 | * Keys are preserved in the resulting array. |
||
3898 | * |
||
3899 | * @param \Closure $closure |
||
3900 | * <p>The predicate on which to partition.</p> |
||
3901 | * |
||
3902 | * @return array<int, static> |
||
3903 | * <p>An array with two elements. The first element contains the array |
||
3904 | * of elements where the predicate returned TRUE, the second element |
||
3905 | * contains the array of elements where the predicate returned FALSE.</p> |
||
3906 | * |
||
3907 | * @psalm-return array<int, static<TKey,T>> |
||
3908 | */ |
||
3909 | 1 | public function partition(\Closure $closure): array |
|
3925 | |||
3926 | /** |
||
3927 | * Pop a specified value off the end of the current array. |
||
3928 | * |
||
3929 | * @return mixed|null |
||
3930 | * <p>(Mutable) The popped element from the current array or null if the array is e.g. empty.</p> |
||
3931 | */ |
||
3932 | 5 | public function pop() |
|
3938 | |||
3939 | /** |
||
3940 | * Prepend a (key) + value to the current array. |
||
3941 | * |
||
3942 | * @param mixed $value |
||
3943 | * @param mixed $key |
||
3944 | * |
||
3945 | * @return $this |
||
3946 | * <p>(Mutable) Return this Arrayy object, with the prepended value.</p> |
||
3947 | * |
||
3948 | * @psalm-return static<TKey,T> |
||
3949 | */ |
||
3950 | 11 | public function prepend($value, $key = null) |
|
3966 | |||
3967 | /** |
||
3968 | * Add a suffix to each key. |
||
3969 | * |
||
3970 | * @param mixed $suffix |
||
3971 | * |
||
3972 | * @return static |
||
3973 | * <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> |
||
3974 | * |
||
3975 | * @psalm-return static<TKey,T> |
||
3976 | * @psalm-mutation-free |
||
3977 | */ |
||
3978 | 10 | View Code Duplication | public function prependToEachKey($suffix): self |
4004 | |||
4005 | /** |
||
4006 | * Add a suffix to each value. |
||
4007 | * |
||
4008 | * @param mixed $suffix |
||
4009 | * |
||
4010 | * @return static |
||
4011 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
||
4012 | * |
||
4013 | * @psalm-return static<TKey,T> |
||
4014 | * @psalm-mutation-free |
||
4015 | */ |
||
4016 | 10 | View Code Duplication | public function prependToEachValue($suffix): self |
4044 | |||
4045 | /** |
||
4046 | * Return the value of a given key and |
||
4047 | * delete the key. |
||
4048 | * |
||
4049 | * @param int|int[]|string|string[]|null $keyOrKeys |
||
4050 | * @param mixed $fallback |
||
4051 | * |
||
4052 | * @return mixed |
||
4053 | */ |
||
4054 | 1 | public function pull($keyOrKeys = null, $fallback = null) |
|
4076 | |||
4077 | /** |
||
4078 | * Push one or more values onto the end of array at once. |
||
4079 | * |
||
4080 | * @param array ...$args |
||
4081 | * |
||
4082 | * @return $this |
||
4083 | * <p>(Mutable) Return this Arrayy object, with pushed elements to the end of array.</p> |
||
4084 | * |
||
4085 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
4086 | * |
||
4087 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$args |
||
4088 | * @psalm-return static<TKey,T> |
||
4089 | */ |
||
4090 | 5 | public function push(...$args) |
|
4108 | |||
4109 | /** |
||
4110 | * Get a random value from the current array. |
||
4111 | * |
||
4112 | * @param int|null $number <p>How many values you will take?</p> |
||
4113 | * |
||
4114 | * @return static |
||
4115 | * <p>(Immutable)</p> |
||
4116 | * |
||
4117 | * @psalm-return static<int|array-key,T> |
||
4118 | */ |
||
4119 | 19 | public function randomImmutable(int $number = null): self |
|
4152 | |||
4153 | /** |
||
4154 | * Pick a random key/index from the keys of this array. |
||
4155 | * |
||
4156 | * @throws \RangeException If array is empty |
||
4157 | * |
||
4158 | * @return mixed |
||
4159 | * <p>Get a key/index or null if there wasn't a key/index.</p> |
||
4160 | */ |
||
4161 | 4 | public function randomKey() |
|
4171 | |||
4172 | /** |
||
4173 | * Pick a given number of random keys/indexes out of this array. |
||
4174 | * |
||
4175 | * @param int $number <p>The number of keys/indexes (should be <= \count($this->array))</p> |
||
4176 | * |
||
4177 | * @throws \RangeException If array is empty |
||
4178 | * |
||
4179 | * @return static |
||
4180 | * <p>(Immutable)</p> |
||
4181 | * |
||
4182 | * @psalm-return static<TKey,T> |
||
4183 | */ |
||
4184 | 13 | public function randomKeys(int $number): self |
|
4212 | |||
4213 | /** |
||
4214 | * Get a random value from the current array. |
||
4215 | * |
||
4216 | * @param int|null $number <p>How many values you will take?</p> |
||
4217 | * |
||
4218 | * @return $this |
||
4219 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4220 | * |
||
4221 | * @psalm-return static<TKey,T> |
||
4222 | */ |
||
4223 | 17 | public function randomMutable(int $number = null): self |
|
4248 | |||
4249 | /** |
||
4250 | * Pick a random value from the values of this array. |
||
4251 | * |
||
4252 | * @return mixed |
||
4253 | * <p>Get a random value or null if there wasn't a value.</p> |
||
4254 | */ |
||
4255 | 4 | public function randomValue() |
|
4265 | |||
4266 | /** |
||
4267 | * Pick a given number of random values out of this array. |
||
4268 | * |
||
4269 | * @param int $number |
||
4270 | * |
||
4271 | * @return static |
||
4272 | * <p>(Mutable)</p> |
||
4273 | * |
||
4274 | * @psalm-return static<TKey,T> |
||
4275 | */ |
||
4276 | 7 | public function randomValues(int $number): self |
|
4280 | |||
4281 | /** |
||
4282 | * Get a random value from an array, with the ability to skew the results. |
||
4283 | * |
||
4284 | * Example: randomWeighted(['foo' => 1, 'bar' => 2]) has a 66% chance of returning bar. |
||
4285 | * |
||
4286 | * @param array $array |
||
4287 | * @param int|null $number <p>How many values you will take?</p> |
||
4288 | * |
||
4289 | * @return static<int,mixed> |
||
4290 | * <p>(Immutable)</p> |
||
4291 | * |
||
4292 | * @psalm-param array<mixed,mixed> $array |
||
4293 | * @psalm-return static<int|array-key,T> |
||
4294 | */ |
||
4295 | 9 | public function randomWeighted(array $array, int $number = null): self |
|
4310 | |||
4311 | /** |
||
4312 | * Reduce the current array via callable e.g. anonymous-function. |
||
4313 | * |
||
4314 | * @param callable $callable |
||
4315 | * @param mixed $init |
||
4316 | * |
||
4317 | * @return static |
||
4318 | * <p>(Immutable)</p> |
||
4319 | * |
||
4320 | * @psalm-return static<TKey,T> |
||
4321 | * @psalm-mutation-free |
||
4322 | */ |
||
4323 | 18 | public function reduce($callable, $init = []): self |
|
4353 | |||
4354 | /** |
||
4355 | * @param bool $unique |
||
4356 | * |
||
4357 | * @return static |
||
4358 | * <p>(Immutable)</p> |
||
4359 | * |
||
4360 | * @psalm-return static<TKey,T> |
||
4361 | * @psalm-mutation-free |
||
4362 | */ |
||
4363 | 14 | public function reduce_dimension(bool $unique = true): self |
|
4386 | |||
4387 | /** |
||
4388 | * Create a numerically re-indexed Arrayy object. |
||
4389 | * |
||
4390 | * @return $this |
||
4391 | * <p>(Mutable) Return this Arrayy object, with re-indexed array-elements.</p> |
||
4392 | * |
||
4393 | * @psalm-return static<TKey,T> |
||
4394 | */ |
||
4395 | 9 | public function reindex(): self |
|
4403 | |||
4404 | /** |
||
4405 | * Return all items that fail the truth test. |
||
4406 | * |
||
4407 | * @param \Closure $closure |
||
4408 | * |
||
4409 | * @return static |
||
4410 | * <p>(Immutable)</p> |
||
4411 | * |
||
4412 | * @psalm-return static<TKey,T> |
||
4413 | * @psalm-mutation-free |
||
4414 | */ |
||
4415 | 1 | View Code Duplication | public function reject(\Closure $closure): self |
4432 | |||
4433 | /** |
||
4434 | * Remove a value from the current array (optional using dot-notation). |
||
4435 | * |
||
4436 | * @param mixed $key |
||
4437 | * |
||
4438 | * @return static |
||
4439 | * <p>(Mutable)</p> |
||
4440 | * |
||
4441 | * @psalm-param TKey $key |
||
4442 | * @psalm-return static<TKey,T> |
||
4443 | */ |
||
4444 | 18 | public function remove($key) |
|
4467 | |||
4468 | /** |
||
4469 | * alias: for "Arrayy->removeValue()" |
||
4470 | * |
||
4471 | * @param mixed $element |
||
4472 | * |
||
4473 | * @return static |
||
4474 | * <p>(Immutable)</p> |
||
4475 | * |
||
4476 | * @psalm-param T $element |
||
4477 | * @psalm-return static<TKey,T> |
||
4478 | * @psalm-mutation-free |
||
4479 | */ |
||
4480 | 8 | public function removeElement($element) |
|
4484 | |||
4485 | /** |
||
4486 | * Remove the first value from the current array. |
||
4487 | * |
||
4488 | * @return static |
||
4489 | * <p>(Immutable)</p> |
||
4490 | * |
||
4491 | * @psalm-return static<TKey,T> |
||
4492 | * @psalm-mutation-free |
||
4493 | */ |
||
4494 | 7 | View Code Duplication | public function removeFirst(): self |
4506 | |||
4507 | /** |
||
4508 | * Remove the last value from the current array. |
||
4509 | * |
||
4510 | * @return static |
||
4511 | * <p>(Immutable)</p> |
||
4512 | * |
||
4513 | * @psalm-return static<TKey,T> |
||
4514 | * @psalm-mutation-free |
||
4515 | */ |
||
4516 | 7 | View Code Duplication | public function removeLast(): self |
4528 | |||
4529 | /** |
||
4530 | * Removes a particular value from an array (numeric or associative). |
||
4531 | * |
||
4532 | * @param mixed $value |
||
4533 | * |
||
4534 | * @return static |
||
4535 | * <p>(Immutable)</p> |
||
4536 | * |
||
4537 | * @psalm-param T $value |
||
4538 | * @psalm-return static<TKey,T> |
||
4539 | * @psalm-mutation-free |
||
4540 | */ |
||
4541 | 8 | public function removeValue($value): self |
|
4564 | |||
4565 | /** |
||
4566 | * Generate array of repeated arrays. |
||
4567 | * |
||
4568 | * @param int $times <p>How many times has to be repeated.</p> |
||
4569 | * |
||
4570 | * @return static |
||
4571 | * <p>(Immutable)</p> |
||
4572 | * |
||
4573 | * @psalm-return static<TKey,T> |
||
4574 | * @psalm-mutation-free |
||
4575 | */ |
||
4576 | 1 | public function repeat($times): self |
|
4588 | |||
4589 | /** |
||
4590 | * Replace a key with a new key/value pair. |
||
4591 | * |
||
4592 | * @param mixed $replace |
||
4593 | * @param mixed $key |
||
4594 | * @param mixed $value |
||
4595 | * |
||
4596 | * @return static |
||
4597 | * <p>(Immutable)</p> |
||
4598 | * |
||
4599 | * @psalm-return static<TKey,T> |
||
4600 | * @psalm-mutation-free |
||
4601 | */ |
||
4602 | 2 | public function replace($replace, $key, $value): self |
|
4612 | |||
4613 | /** |
||
4614 | * Create an array using the current array as values and the other array as keys. |
||
4615 | * |
||
4616 | * @param array $keys <p>An array of keys.</p> |
||
4617 | * |
||
4618 | * @return static |
||
4619 | * <p>(Immutable) Arrayy object with keys from the other array.</p> |
||
4620 | * |
||
4621 | * @psalm-param array<mixed,mixed>|array<mixed,TKey> $keys |
||
4622 | * @psalm-return static<TKey,T> |
||
4623 | * @psalm-mutation-free |
||
4624 | */ |
||
4625 | 2 | public function replaceAllKeys(array $keys): self |
|
4633 | |||
4634 | /** |
||
4635 | * Create an array using the current array as keys and the other array as values. |
||
4636 | * |
||
4637 | * @param array $array <p>An array o values.</p> |
||
4638 | * |
||
4639 | * @return static |
||
4640 | * <p>(Immutable) Arrayy object with values from the other array.</p> |
||
4641 | * |
||
4642 | * @psalm-param array<mixed,T> $array |
||
4643 | * @psalm-return static<TKey,T> |
||
4644 | * @psalm-mutation-free |
||
4645 | */ |
||
4646 | 2 | public function replaceAllValues(array $array): self |
|
4654 | |||
4655 | /** |
||
4656 | * Replace the keys in an array with another set. |
||
4657 | * |
||
4658 | * @param array $keys <p>An array of keys matching the array's size</p> |
||
4659 | * |
||
4660 | * @return static |
||
4661 | * <p>(Immutable)</p> |
||
4662 | * |
||
4663 | * @psalm-param array<mixed,mixed>|array<mixed,TKey> $keys |
||
4664 | * @psalm-return static<TKey,T> |
||
4665 | * @psalm-mutation-free |
||
4666 | */ |
||
4667 | 1 | public function replaceKeys(array $keys): self |
|
4678 | |||
4679 | /** |
||
4680 | * Replace the first matched value in an array. |
||
4681 | * |
||
4682 | * @param mixed $search <p>The value to replace.</p> |
||
4683 | * @param mixed $replacement <p>The value to replace.</p> |
||
4684 | * |
||
4685 | * @return static |
||
4686 | * <p>(Immutable)</p> |
||
4687 | * |
||
4688 | * @psalm-return static<TKey,T> |
||
4689 | * @psalm-mutation-free |
||
4690 | */ |
||
4691 | 3 | public function replaceOneValue($search, $replacement = ''): self |
|
4706 | |||
4707 | /** |
||
4708 | * Replace values in the current array. |
||
4709 | * |
||
4710 | * @param mixed $search <p>The value to replace.</p> |
||
4711 | * @param mixed $replacement <p>What to replace it with.</p> |
||
4712 | * |
||
4713 | * @return static |
||
4714 | * <p>(Immutable)</p> |
||
4715 | * |
||
4716 | * @psalm-return static<TKey,T> |
||
4717 | * @psalm-mutation-free |
||
4718 | */ |
||
4719 | 1 | public function replaceValues($search, $replacement = ''): self |
|
4731 | |||
4732 | /** |
||
4733 | * Get the last elements from index $from until the end of this array. |
||
4734 | * |
||
4735 | * @param int $from |
||
4736 | * |
||
4737 | * @return static |
||
4738 | * <p>(Immutable)</p> |
||
4739 | * |
||
4740 | * @psalm-return static<TKey,T> |
||
4741 | * @psalm-mutation-free |
||
4742 | */ |
||
4743 | 15 | View Code Duplication | public function rest(int $from = 1): self |
4753 | |||
4754 | /** |
||
4755 | * Return the array in the reverse order. |
||
4756 | * |
||
4757 | * @return $this |
||
4758 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4759 | * |
||
4760 | * @psalm-return static<TKey,T> |
||
4761 | */ |
||
4762 | 9 | public function reverse(): self |
|
4770 | |||
4771 | /** |
||
4772 | * Sort an array in reverse order. |
||
4773 | * |
||
4774 | * @param int $sort_flags [optional] <p> |
||
4775 | * You may modify the behavior of the sort using the optional |
||
4776 | * parameter sort_flags, for details |
||
4777 | * see sort. |
||
4778 | * </p> |
||
4779 | * |
||
4780 | * @return $this |
||
4781 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4782 | * |
||
4783 | * @psalm-return static<TKey,T> |
||
4784 | */ |
||
4785 | 4 | public function rsort(int $sort_flags = 0): self |
|
4793 | |||
4794 | /** |
||
4795 | * Sort an array in reverse order. |
||
4796 | * |
||
4797 | * @param int $sort_flags [optional] <p> |
||
4798 | * You may modify the behavior of the sort using the optional |
||
4799 | * parameter sort_flags, for details |
||
4800 | * see sort. |
||
4801 | * </p> |
||
4802 | * |
||
4803 | * @return $this |
||
4804 | * <p>(Immutable) Return this Arrayy object.</p> |
||
4805 | * |
||
4806 | * @psalm-return static<TKey,T> |
||
4807 | * @psalm-mutation-free |
||
4808 | */ |
||
4809 | 4 | public function rsortImmutable(int $sort_flags = 0): self |
|
4820 | |||
4821 | /** |
||
4822 | * Search for the first index of the current array via $value. |
||
4823 | * |
||
4824 | * @param mixed $value |
||
4825 | * |
||
4826 | * @return false|float|int|string |
||
4827 | * <p>Will return <b>FALSE</b> if the value can't be found.</p> |
||
4828 | * @psalm-mutation-free |
||
4829 | */ |
||
4830 | 21 | public function searchIndex($value) |
|
4840 | |||
4841 | /** |
||
4842 | * Search for the value of the current array via $index. |
||
4843 | * |
||
4844 | * @param mixed $index |
||
4845 | * |
||
4846 | * @return static |
||
4847 | * <p>(Immutable) Will return a empty Arrayy if the value wasn't found.</p> |
||
4848 | * |
||
4849 | * @psalm-return static<TKey,T> |
||
4850 | * @psalm-mutation-free |
||
4851 | */ |
||
4852 | 9 | public function searchValue($index): self |
|
4882 | |||
4883 | /** |
||
4884 | * Set a value for the current array (optional using dot-notation). |
||
4885 | * |
||
4886 | * @param string $key <p>The key to set.</p> |
||
4887 | * @param mixed $value <p>Its value.</p> |
||
4888 | * |
||
4889 | * @return $this |
||
4890 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4891 | * |
||
4892 | * @psalm-param TKey $key |
||
4893 | * @psalm-param T $value |
||
4894 | * @psalm-return static<TKey,T> |
||
4895 | */ |
||
4896 | 18 | public function set($key, $value): self |
|
4902 | |||
4903 | /** |
||
4904 | * Get a value from a array and set it if it was not. |
||
4905 | * |
||
4906 | * WARNING: this method only set the value, if the $key is not already set |
||
4907 | * |
||
4908 | * @param mixed $key <p>The key</p> |
||
4909 | * @param mixed $fallback <p>The default value to set if it isn't.</p> |
||
4910 | * |
||
4911 | * @return mixed |
||
4912 | * <p>(Mutable)</p> |
||
4913 | */ |
||
4914 | 11 | public function setAndGet($key, $fallback = null) |
|
4925 | |||
4926 | /** |
||
4927 | * Shifts a specified value off the beginning of array. |
||
4928 | * |
||
4929 | * @return mixed |
||
4930 | * <p>(Mutable) A shifted element from the current array.</p> |
||
4931 | */ |
||
4932 | 5 | public function shift() |
|
4938 | |||
4939 | /** |
||
4940 | * Shuffle the current array. |
||
4941 | * |
||
4942 | * @param bool $secure <p>using a CSPRNG | @link https://paragonie.com/b/JvICXzh_jhLyt4y3</p> |
||
4943 | * @param array $array [optional] |
||
4944 | * |
||
4945 | * @return static |
||
4946 | * <p>(Immutable)</p> |
||
4947 | * |
||
4948 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
4949 | * @psalm-return static<TKey,T> |
||
4950 | * |
||
4951 | * @noinspection BadExceptionsProcessingInspection |
||
4952 | * @noinspection RandomApiMigrationInspection |
||
4953 | * @noinspection NonSecureShuffleUsageInspection |
||
4954 | */ |
||
4955 | 2 | public function shuffle(bool $secure = false, array $array = null): self |
|
4993 | |||
4994 | /** |
||
4995 | * Count the values from the current array. |
||
4996 | * |
||
4997 | * alias: for "Arrayy->count()" |
||
4998 | * |
||
4999 | * @param int $mode |
||
5000 | * |
||
5001 | * @return int |
||
5002 | */ |
||
5003 | 20 | public function size(int $mode = \COUNT_NORMAL): int |
|
5007 | |||
5008 | /** |
||
5009 | * Checks whether array has exactly $size items. |
||
5010 | * |
||
5011 | * @param int $size |
||
5012 | * |
||
5013 | * @return bool |
||
5014 | */ |
||
5015 | 1 | View Code Duplication | public function sizeIs(int $size): bool |
5029 | |||
5030 | /** |
||
5031 | * Checks whether array has between $fromSize to $toSize items. $toSize can be |
||
5032 | * smaller than $fromSize. |
||
5033 | * |
||
5034 | * @param int $fromSize |
||
5035 | * @param int $toSize |
||
5036 | * |
||
5037 | * @return bool |
||
5038 | */ |
||
5039 | 1 | public function sizeIsBetween(int $fromSize, int $toSize): bool |
|
5059 | |||
5060 | /** |
||
5061 | * Checks whether array has more than $size items. |
||
5062 | * |
||
5063 | * @param int $size |
||
5064 | * |
||
5065 | * @return bool |
||
5066 | */ |
||
5067 | 1 | View Code Duplication | public function sizeIsGreaterThan(int $size): bool |
5081 | |||
5082 | /** |
||
5083 | * Checks whether array has less than $size items. |
||
5084 | * |
||
5085 | * @param int $size |
||
5086 | * |
||
5087 | * @return bool |
||
5088 | */ |
||
5089 | 1 | View Code Duplication | public function sizeIsLessThan(int $size): bool |
5103 | |||
5104 | /** |
||
5105 | * Counts all elements in an array, or something in an object. |
||
5106 | * |
||
5107 | * <p> |
||
5108 | * For objects, if you have SPL installed, you can hook into count() by implementing interface {@see Countable}. |
||
5109 | * The interface has exactly one method, {@see Countable::count()}, which returns the return value for the count() |
||
5110 | * function. Please see the {@see Array} section of the manual for a detailed explanation of how arrays are |
||
5111 | * implemented and used in PHP. |
||
5112 | * </p> |
||
5113 | * |
||
5114 | * @return int |
||
5115 | * <p> |
||
5116 | * The number of elements in var, which is |
||
5117 | * typically an array, since anything else will have one |
||
5118 | * element. |
||
5119 | * </p> |
||
5120 | * <p> |
||
5121 | * If var is not an array or an object with |
||
5122 | * implemented Countable interface, |
||
5123 | * 1 will be returned. |
||
5124 | * There is one exception, if var is &null;, |
||
5125 | * 0 will be returned. |
||
5126 | * </p> |
||
5127 | * <p> |
||
5128 | * Caution: count may return 0 for a variable that isn't set, |
||
5129 | * but it may also return 0 for a variable that has been initialized with an |
||
5130 | * empty array. Use isset to test if a variable is set. |
||
5131 | * </p> |
||
5132 | */ |
||
5133 | 10 | public function sizeRecursive(): int |
|
5137 | |||
5138 | /** |
||
5139 | * Extract a slice of the array. |
||
5140 | * |
||
5141 | * @param int $offset <p>Slice begin index.</p> |
||
5142 | * @param int|null $length <p>Length of the slice.</p> |
||
5143 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
5144 | * |
||
5145 | * @return static |
||
5146 | * <p>(Immutable) A slice of the original array with length $length.</p> |
||
5147 | * |
||
5148 | * @psalm-return static<TKey,T> |
||
5149 | * @psalm-mutation-free |
||
5150 | */ |
||
5151 | 5 | public function slice(int $offset, int $length = null, bool $preserveKeys = false) |
|
5164 | |||
5165 | /** |
||
5166 | * Sort the current array and optional you can keep the keys. |
||
5167 | * |
||
5168 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5169 | * @param int $strategy <p>sort_flags => use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5170 | * <strong>SORT_NATURAL</strong></p> |
||
5171 | * @param bool $keepKeys |
||
5172 | * |
||
5173 | * @return static |
||
5174 | * <p>(Mutable) Return this Arrayy object.</p> |
||
5175 | * |
||
5176 | * @psalm-return static<TKey,T> |
||
5177 | */ |
||
5178 | 20 | public function sort( |
|
5192 | |||
5193 | /** |
||
5194 | * Sort the current array and optional you can keep the keys. |
||
5195 | * |
||
5196 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5197 | * @param int $strategy <p>sort_flags => use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5198 | * <strong>SORT_NATURAL</strong></p> |
||
5199 | * @param bool $keepKeys |
||
5200 | * |
||
5201 | * @return static |
||
5202 | * <p>(Immutable) Return this Arrayy object.</p> |
||
5203 | * |
||
5204 | * @psalm-return static<TKey,T> |
||
5205 | */ |
||
5206 | 12 | public function sortImmutable( |
|
5222 | |||
5223 | /** |
||
5224 | * Sort the current array by key. |
||
5225 | * |
||
5226 | * @see http://php.net/manual/en/function.ksort.php |
||
5227 | * @see http://php.net/manual/en/function.krsort.php |
||
5228 | * |
||
5229 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5230 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5231 | * <strong>SORT_NATURAL</strong></p> |
||
5232 | * |
||
5233 | * @return $this |
||
5234 | * <p>(Mutable) Return this Arrayy object.</p> |
||
5235 | * |
||
5236 | * @psalm-return static<TKey,T> |
||
5237 | */ |
||
5238 | 18 | public function sortKeys( |
|
5248 | |||
5249 | /** |
||
5250 | * Sort the current array by key. |
||
5251 | * |
||
5252 | * @see http://php.net/manual/en/function.ksort.php |
||
5253 | * @see http://php.net/manual/en/function.krsort.php |
||
5254 | * |
||
5255 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5256 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5257 | * <strong>SORT_NATURAL</strong></p> |
||
5258 | * |
||
5259 | * @return $this |
||
5260 | * <p>(Immutable) Return this Arrayy object.</p> |
||
5261 | * |
||
5262 | * @psalm-return static<TKey,T> |
||
5263 | * @psalm-mutation-free |
||
5264 | */ |
||
5265 | 8 | public function sortKeysImmutable( |
|
5278 | |||
5279 | /** |
||
5280 | * Sort the current array by value. |
||
5281 | * |
||
5282 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5283 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5284 | * <strong>SORT_NATURAL</strong></p> |
||
5285 | * |
||
5286 | * @return static |
||
5287 | * <p>(Mutable)</p> |
||
5288 | * |
||
5289 | * @psalm-return static<TKey,T> |
||
5290 | */ |
||
5291 | 1 | public function sortValueKeepIndex( |
|
5297 | |||
5298 | /** |
||
5299 | * Sort the current array by value. |
||
5300 | * |
||
5301 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5302 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5303 | * <strong>SORT_NATURAL</strong></p> |
||
5304 | * |
||
5305 | * @return static |
||
5306 | * <p>(Mutable)</p> |
||
5307 | * |
||
5308 | * @psalm-return static<TKey,T> |
||
5309 | */ |
||
5310 | 1 | public function sortValueNewIndex($direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
5314 | |||
5315 | /** |
||
5316 | * Sort a array by value, by a closure or by a property. |
||
5317 | * |
||
5318 | * - If the sorter is null, the array is sorted naturally. |
||
5319 | * - Associative (string) keys will be maintained, but numeric keys will be re-indexed. |
||
5320 | * |
||
5321 | * @param callable|string|null $sorter |
||
5322 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or |
||
5323 | * <strong>SORT_DESC</strong></p> |
||
5324 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5325 | * <strong>SORT_NATURAL</strong></p> |
||
5326 | * |
||
5327 | * @return static |
||
5328 | * <p>(Immutable)</p> |
||
5329 | * |
||
5330 | * @psalm-return static<TKey,T> |
||
5331 | * @psalm-mutation-free |
||
5332 | */ |
||
5333 | 1 | public function sorter($sorter = null, $direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
5374 | |||
5375 | /** |
||
5376 | * @param int $offset |
||
5377 | * @param int|null $length |
||
5378 | * @param array $replacement |
||
5379 | * |
||
5380 | * @return static |
||
5381 | * <p>(Immutable)</p> |
||
5382 | * |
||
5383 | * @psalm-param array<mixed,mixed>|array<mixed,T> $replacement |
||
5384 | * @psalm-return static<TKey,T> |
||
5385 | * @psalm-mutation-free |
||
5386 | */ |
||
5387 | 1 | public function splice(int $offset, int $length = null, $replacement = []): self |
|
5404 | |||
5405 | /** |
||
5406 | * Split an array in the given amount of pieces. |
||
5407 | * |
||
5408 | * @param int $numberOfPieces |
||
5409 | * @param bool $keepKeys |
||
5410 | * |
||
5411 | * @return static |
||
5412 | * <p>(Immutable)</p> |
||
5413 | * |
||
5414 | * @psalm-return static<TKey,T> |
||
5415 | * @psalm-mutation-free |
||
5416 | */ |
||
5417 | 1 | public function split(int $numberOfPieces = 2, bool $keepKeys = false): self |
|
5436 | |||
5437 | /** |
||
5438 | * Stripe all empty items. |
||
5439 | * |
||
5440 | * @return static |
||
5441 | * <p>(Immutable)</p> |
||
5442 | * |
||
5443 | * @psalm-return static<TKey,T> |
||
5444 | * @psalm-mutation-free |
||
5445 | */ |
||
5446 | 1 | public function stripEmpty(): self |
|
5458 | |||
5459 | /** |
||
5460 | * Swap two values between positions by key. |
||
5461 | * |
||
5462 | * @param int|string $swapA <p>a key in the array</p> |
||
5463 | * @param int|string $swapB <p>a key in the array</p> |
||
5464 | * |
||
5465 | * @return static |
||
5466 | * <p>(Immutable)</p> |
||
5467 | * |
||
5468 | * @psalm-return static<TKey,T> |
||
5469 | * @psalm-mutation-free |
||
5470 | */ |
||
5471 | 1 | public function swap($swapA, $swapB): self |
|
5483 | |||
5484 | /** |
||
5485 | * Get the current array from the "Arrayy"-object. |
||
5486 | * alias for "getArray()" |
||
5487 | * |
||
5488 | * @param bool $convertAllArrayyElements <p> |
||
5489 | * Convert all Child-"Arrayy" objects also to arrays. |
||
5490 | * </p> |
||
5491 | * @param bool $preserveKeys <p> |
||
5492 | * e.g.: A generator maybe return the same key more then once, |
||
5493 | * so maybe you will ignore the keys. |
||
5494 | * </p> |
||
5495 | * |
||
5496 | * @return array |
||
5497 | * |
||
5498 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
5499 | * @psalm-mutation-free |
||
5500 | */ |
||
5501 | 893 | public function toArray( |
|
5526 | |||
5527 | /** |
||
5528 | * Get the current array from the "Arrayy"-object as list. |
||
5529 | * |
||
5530 | * @param bool $convertAllArrayyElements <p> |
||
5531 | * Convert all Child-"Arrayy" objects also to arrays. |
||
5532 | * </p> |
||
5533 | * |
||
5534 | * @return array |
||
5535 | * |
||
5536 | * @psalm-return array<int,mixed>|array<int,T> |
||
5537 | * @psalm-mutation-free |
||
5538 | */ |
||
5539 | 1 | public function toList(bool $convertAllArrayyElements = false): array |
|
5546 | |||
5547 | /** |
||
5548 | * Convert the current array to JSON. |
||
5549 | * |
||
5550 | * @param int $options [optional] <p>e.g. JSON_PRETTY_PRINT</p> |
||
5551 | * @param int $depth [optional] <p>Set the maximum depth. Must be greater than zero.</p> |
||
5552 | * |
||
5553 | * @return string |
||
5554 | */ |
||
5555 | 7 | public function toJson(int $options = 0, int $depth = 512): string |
|
5564 | |||
5565 | /** |
||
5566 | * @param string[]|null $items |
||
5567 | * @param string[] $helper |
||
5568 | * |
||
5569 | * @return static |
||
5570 | * |
||
5571 | * @psalm-return static<TKey,T> |
||
5572 | */ |
||
5573 | 1 | public function toPermutation(array $items = null, array $helper = []): self |
|
5607 | |||
5608 | /** |
||
5609 | * Implodes array to a string with specified separator. |
||
5610 | * |
||
5611 | * @param string $separator [optional] <p>The element's separator.</p> |
||
5612 | * |
||
5613 | * @return string |
||
5614 | * <p>The string representation of array, separated by ",".</p> |
||
5615 | */ |
||
5616 | 19 | public function toString(string $separator = ','): string |
|
5620 | |||
5621 | /** |
||
5622 | * Return a duplicate free copy of the current array. |
||
5623 | * |
||
5624 | * @return $this |
||
5625 | * <p>(Mutable)</p> |
||
5626 | * |
||
5627 | * @psalm-return static<TKey,T> |
||
5628 | */ |
||
5629 | 13 | public function unique(): self |
|
5651 | |||
5652 | /** |
||
5653 | * Return a duplicate free copy of the current array. (with the old keys) |
||
5654 | * |
||
5655 | * @return $this |
||
5656 | * <p>(Mutable)</p> |
||
5657 | * |
||
5658 | * @psalm-return static<TKey,T> |
||
5659 | */ |
||
5660 | 11 | public function uniqueKeepIndex(): self |
|
5686 | |||
5687 | /** |
||
5688 | * alias: for "Arrayy->unique()" |
||
5689 | * |
||
5690 | * @return static |
||
5691 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
5692 | * |
||
5693 | * @see Arrayy::unique() |
||
5694 | * |
||
5695 | * @psalm-return static<TKey,T> |
||
5696 | */ |
||
5697 | 10 | public function uniqueNewIndex(): self |
|
5701 | |||
5702 | /** |
||
5703 | * Prepends one or more values to the beginning of array at once. |
||
5704 | * |
||
5705 | * @param array ...$args |
||
5706 | * |
||
5707 | * @return $this |
||
5708 | * <p>(Mutable) Return this Arrayy object, with prepended elements to the beginning of array.</p> |
||
5709 | * |
||
5710 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$args |
||
5711 | * @psalm-return static<TKey,T> |
||
5712 | */ |
||
5713 | 4 | public function unshift(...$args): self |
|
5721 | |||
5722 | /** |
||
5723 | * Tests whether the given closure return something valid for all elements of this array. |
||
5724 | * |
||
5725 | * @param \Closure $closure the predicate |
||
5726 | * |
||
5727 | * @return bool |
||
5728 | * <p>TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.</p> |
||
5729 | */ |
||
5730 | 1 | View Code Duplication | public function validate(\Closure $closure): bool |
5740 | |||
5741 | /** |
||
5742 | * Get all values from a array. |
||
5743 | * |
||
5744 | * @return static |
||
5745 | * <p>(Immutable)</p> |
||
5746 | * |
||
5747 | * @psalm-return static<TKey,T> |
||
5748 | * @psalm-mutation-free |
||
5749 | */ |
||
5750 | 2 | public function values(): self |
|
5763 | |||
5764 | /** |
||
5765 | * Apply the given function to every element in the array, discarding the results. |
||
5766 | * |
||
5767 | * @param callable $callable |
||
5768 | * @param bool $recursive <p>Whether array will be walked recursively or no</p> |
||
5769 | * |
||
5770 | * @return $this |
||
5771 | * <p>(Mutable) Return this Arrayy object, with modified elements.</p> |
||
5772 | * |
||
5773 | * @psalm-return static<TKey,T> |
||
5774 | */ |
||
5775 | 12 | public function walk($callable, bool $recursive = false): self |
|
5787 | |||
5788 | /** |
||
5789 | * Returns a collection of matching items. |
||
5790 | * |
||
5791 | * @param string $keyOrPropertyOrMethod the property or method to evaluate |
||
5792 | * @param mixed $value the value to match |
||
5793 | * |
||
5794 | * @throws \InvalidArgumentException if property or method is not defined |
||
5795 | * |
||
5796 | * @return static |
||
5797 | * |
||
5798 | * @psalm-param T $value |
||
5799 | * @psalm-return static<TKey,T> |
||
5800 | */ |
||
5801 | 1 | public function where(string $keyOrPropertyOrMethod, $value): self |
|
5814 | |||
5815 | /** |
||
5816 | * Convert an array into a object. |
||
5817 | * |
||
5818 | * @param array $array |
||
5819 | * |
||
5820 | * @return \stdClass |
||
5821 | * |
||
5822 | * @psalm-param array<mixed,mixed> $array |
||
5823 | */ |
||
5824 | 4 | final protected static function arrayToObject(array $array = []): \stdClass |
|
5843 | |||
5844 | /** |
||
5845 | * @param array|\Generator|null $input <p> |
||
5846 | * An array containing keys to return. |
||
5847 | * </p> |
||
5848 | * @param mixed|null $search_values [optional] <p> |
||
5849 | * If specified, then only keys containing these values are returned. |
||
5850 | * </p> |
||
5851 | * @param bool $strict [optional] <p> |
||
5852 | * Determines if strict comparison (===) should be used during the |
||
5853 | * search. |
||
5854 | * </p> |
||
5855 | * |
||
5856 | * @return array |
||
5857 | * <p>an array of all the keys in input</p> |
||
5858 | * |
||
5859 | * @psalm-param array<mixed,mixed>|\Generator<TKey,T>|null $input |
||
5860 | * @psalm-return array<TKey|mixed> |
||
5861 | * @psalm-mutation-free |
||
5862 | */ |
||
5863 | 11 | protected function array_keys_recursive( |
|
5924 | |||
5925 | /** |
||
5926 | * @param mixed $path |
||
5927 | * @param callable $callable |
||
5928 | * @param array|null $currentOffset |
||
5929 | * |
||
5930 | * @return void |
||
5931 | * |
||
5932 | * @psalm-param array<mixed,mixed>|array<TKey,T>|null $currentOffset |
||
5933 | * @psalm-mutation-free |
||
5934 | */ |
||
5935 | 4 | protected function callAtPath($path, $callable, &$currentOffset = null) |
|
5964 | |||
5965 | /** |
||
5966 | * Extracts the value of the given property or method from the object. |
||
5967 | * |
||
5968 | * @param static $object <p>The object to extract the value from.</p> |
||
5969 | * @param string $keyOrPropertyOrMethod <p>The property or method for which the |
||
5970 | * value should be extracted.</p> |
||
5971 | * |
||
5972 | * @throws \InvalidArgumentException if the method or property is not defined |
||
5973 | * |
||
5974 | * @return mixed |
||
5975 | * <p>The value extracted from the specified property or method.</p> |
||
5976 | * |
||
5977 | * @psalm-param self<TKey,T> $object |
||
5978 | */ |
||
5979 | 2 | final protected function extractValue(self $object, string $keyOrPropertyOrMethod) |
|
6001 | |||
6002 | /** |
||
6003 | * create a fallback for array |
||
6004 | * |
||
6005 | * 1. use the current array, if it's a array |
||
6006 | * 2. fallback to empty array, if there is nothing |
||
6007 | * 3. call "getArray()" on object, if there is a "Arrayy"-object |
||
6008 | * 4. call "createFromObject()" on object, if there is a "\Traversable"-object |
||
6009 | * 5. call "__toArray()" on object, if the method exists |
||
6010 | * 6. cast a string or object with "__toString()" into an array |
||
6011 | * 7. throw a "InvalidArgumentException"-Exception |
||
6012 | * |
||
6013 | * @param mixed $data |
||
6014 | * |
||
6015 | * @throws \InvalidArgumentException |
||
6016 | * |
||
6017 | * @return array |
||
6018 | * |
||
6019 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
6020 | */ |
||
6021 | 1100 | protected function fallbackForArray(&$data): array |
|
6031 | |||
6032 | /** |
||
6033 | * @param bool $preserveKeys <p> |
||
6034 | * e.g.: A generator maybe return the same key more then once, |
||
6035 | * so maybe you will ignore the keys. |
||
6036 | * </p> |
||
6037 | * |
||
6038 | * @return bool |
||
6039 | * |
||
6040 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
6041 | * @psalm-mutation-free :/ |
||
6042 | */ |
||
6043 | 1014 | protected function generatorToArray(bool $preserveKeys = true) |
|
6054 | |||
6055 | /** |
||
6056 | * Get correct PHP constant for direction. |
||
6057 | * |
||
6058 | * @param int|string $direction |
||
6059 | * |
||
6060 | * @return int |
||
6061 | * @psalm-mutation-free |
||
6062 | */ |
||
6063 | 43 | protected function getDirection($direction): int |
|
6085 | |||
6086 | /** |
||
6087 | * @return TypeCheckPhpDoc[] |
||
6088 | * |
||
6089 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
6090 | */ |
||
6091 | 16 | protected function getPropertiesFromPhpDoc() |
|
6116 | |||
6117 | /** |
||
6118 | * @param mixed $glue |
||
6119 | * @param mixed $pieces |
||
6120 | * @param bool $useKeys |
||
6121 | * |
||
6122 | * @return string |
||
6123 | * @psalm-mutation-free |
||
6124 | */ |
||
6125 | 36 | protected function implode_recursive( |
|
6158 | |||
6159 | /** |
||
6160 | * @param mixed $needle <p> |
||
6161 | * The searched value. |
||
6162 | * </p> |
||
6163 | * <p> |
||
6164 | * If needle is a string, the comparison is done |
||
6165 | * in a case-sensitive manner. |
||
6166 | * </p> |
||
6167 | * @param array|\Generator|null $haystack <p> |
||
6168 | * The array. |
||
6169 | * </p> |
||
6170 | * @param bool $strict [optional] <p> |
||
6171 | * If the third parameter strict is set to true |
||
6172 | * then the in_array function will also check the |
||
6173 | * types of the |
||
6174 | * needle in the haystack. |
||
6175 | * </p> |
||
6176 | * |
||
6177 | * @return bool |
||
6178 | * <p>true if needle is found in the array, false otherwise</p> |
||
6179 | * |
||
6180 | * @psalm-param array<mixed,mixed>|\Generator<TKey,T>|null $haystack |
||
6181 | * @psalm-mutation-free |
||
6182 | */ |
||
6183 | 19 | protected function in_array_recursive($needle, $haystack = null, $strict = true): bool |
|
6208 | |||
6209 | /** |
||
6210 | * @param mixed $data |
||
6211 | * |
||
6212 | * @return array|null |
||
6213 | * |
||
6214 | * @psalm-return array<mixed,mixed>|array<TKey,T>|null |
||
6215 | */ |
||
6216 | 1100 | protected function internalGetArray(&$data) |
|
6267 | |||
6268 | /** |
||
6269 | * Internal mechanics of remove method. |
||
6270 | * |
||
6271 | * @param mixed $key |
||
6272 | * |
||
6273 | * @return bool |
||
6274 | */ |
||
6275 | 18 | protected function internalRemove($key): bool |
|
6308 | |||
6309 | /** |
||
6310 | * Internal mechanic of set method. |
||
6311 | * |
||
6312 | * @param int|string|null $key |
||
6313 | * @param mixed $value |
||
6314 | * @param bool $checkProperties |
||
6315 | * |
||
6316 | * @return bool |
||
6317 | */ |
||
6318 | 962 | protected function internalSet( |
|
6371 | |||
6372 | /** |
||
6373 | * Convert a object into an array. |
||
6374 | * |
||
6375 | * @param mixed|object $object |
||
6376 | * |
||
6377 | * @return array|mixed |
||
6378 | * |
||
6379 | * @psalm-mutation-free |
||
6380 | */ |
||
6381 | 5 | protected static function objectToArray($object) |
|
6394 | |||
6395 | /** |
||
6396 | * @param array $data |
||
6397 | * @param bool $checkPropertiesInConstructor |
||
6398 | * |
||
6399 | * @return void |
||
6400 | * |
||
6401 | * @psalm-param array<mixed,T> $data |
||
6402 | */ |
||
6403 | 1098 | protected function setInitialValuesAndProperties(array &$data, bool $checkPropertiesInConstructor) |
|
6448 | |||
6449 | /** |
||
6450 | * sorting keys |
||
6451 | * |
||
6452 | * @param array $elements |
||
6453 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
6454 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
6455 | * <strong>SORT_NATURAL</strong></p> |
||
6456 | * |
||
6457 | * @return $this |
||
6458 | * <p>(Mutable) Return this Arrayy object.</p> |
||
6459 | * |
||
6460 | * @psalm-param array<mixed,mixed>|array<mixed|TKey,T> $elements |
||
6461 | * @psalm-return static<TKey,T> |
||
6462 | */ |
||
6463 | 18 | protected function sorterKeys( |
|
6484 | |||
6485 | /** |
||
6486 | * @param array $elements <p>Warning: used as reference</p> |
||
6487 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
6488 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
6489 | * <strong>SORT_NATURAL</strong></p> |
||
6490 | * @param bool $keepKeys |
||
6491 | * |
||
6492 | * @return $this |
||
6493 | * <p>(Mutable) Return this Arrayy object.</p> |
||
6494 | * |
||
6495 | * @psalm-param array<mixed,mixed>|array<mixed|TKey,T> $elements |
||
6496 | * @psalm-return static<TKey,T> |
||
6497 | */ |
||
6498 | 24 | protected function sorting(array &$elements, $direction = \SORT_ASC, int $strategy = \SORT_REGULAR, bool $keepKeys = false): self |
|
6528 | |||
6529 | /** |
||
6530 | * @param int|string|null $key |
||
6531 | * @param mixed $value |
||
6532 | * |
||
6533 | * @return void |
||
6534 | */ |
||
6535 | 87 | private function checkType($key, $value) |
|
6553 | } |
||
6554 |
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..