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 |
||
26 | class Arrayy extends \ArrayObject implements \IteratorAggregate, \ArrayAccess, \Serializable, \JsonSerializable, \Countable |
||
27 | { |
||
28 | const ARRAYY_HELPER_TYPES_FOR_ALL_PROPERTIES = '!!!!Arrayy_Helper_Types_For_All_Properties!!!!'; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | * |
||
33 | * @psalm-var array<TKey,T> |
||
34 | */ |
||
35 | protected $array = []; |
||
36 | |||
37 | /** |
||
38 | * @var \Arrayy\ArrayyRewindableGenerator|null |
||
39 | * |
||
40 | * @psalm-var \Arrayy\ArrayyRewindableGenerator<TKey,T>|null |
||
41 | */ |
||
42 | protected $generator; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | * |
||
47 | * @psalm-var class-string<\Arrayy\ArrayyIterator> |
||
48 | */ |
||
49 | protected $iteratorClass = ArrayyIterator::class; |
||
50 | |||
51 | /** |
||
52 | * @var string |
||
53 | */ |
||
54 | protected $pathSeparator = '.'; |
||
55 | |||
56 | /** |
||
57 | * @var bool |
||
58 | */ |
||
59 | protected $checkPropertyTypes = false; |
||
60 | |||
61 | /** |
||
62 | * @var bool |
||
63 | */ |
||
64 | protected $checkForMissingPropertiesInConstructor = false; |
||
65 | |||
66 | /** |
||
67 | * @var bool |
||
68 | */ |
||
69 | protected $checkPropertiesMismatchInConstructor = false; |
||
70 | |||
71 | /** |
||
72 | * @var bool |
||
73 | */ |
||
74 | protected $checkPropertiesMismatch = true; |
||
75 | |||
76 | /** |
||
77 | * @var array<TypeCheckInterface>|\Arrayy\Type\TypeInterface|TypeCheckArray<TypeCheckInterface> |
||
78 | */ |
||
79 | protected $properties = []; |
||
80 | |||
81 | /** |
||
82 | * Initializes |
||
83 | * |
||
84 | * @param mixed $data <p> |
||
85 | * Should be an array or a generator, otherwise it will try |
||
86 | * to convert it into an array. |
||
87 | * </p> |
||
88 | * @param string $iteratorClass optional <p> |
||
89 | * You can overwrite the ArrayyIterator, but mostly you don't |
||
90 | * need this option. |
||
91 | * </p> |
||
92 | * @param bool $checkPropertiesInConstructor optional <p> |
||
93 | * You need to extend the "Arrayy"-class and you need to set |
||
94 | * the $checkPropertiesMismatchInConstructor class property |
||
95 | * to |
||
96 | * true, otherwise this option didn't not work anyway. |
||
97 | * </p> |
||
98 | * |
||
99 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
100 | */ |
||
101 | 1066 | public function __construct( |
|
102 | $data = [], |
||
103 | string $iteratorClass = ArrayyIterator::class, |
||
104 | bool $checkPropertiesInConstructor = true |
||
105 | ) { |
||
106 | 1066 | $data = $this->fallbackForArray($data); |
|
107 | |||
108 | // used only for serialize + unserialize, all other methods are overwritten |
||
109 | 1064 | parent::__construct([], 0, $iteratorClass); |
|
110 | |||
111 | 1064 | $this->setInitialValuesAndProperties($data, $checkPropertiesInConstructor); |
|
112 | |||
113 | 1057 | $this->setIteratorClass($iteratorClass); |
|
114 | 1057 | } |
|
115 | |||
116 | /** |
||
117 | * Call object as function. |
||
118 | * |
||
119 | * @param mixed $key |
||
120 | * |
||
121 | * @return mixed |
||
122 | */ |
||
123 | 1 | public function __invoke($key = null) |
|
124 | { |
||
125 | 1 | if ($key !== null) { |
|
126 | 1 | $this->generatorToArray(); |
|
127 | |||
128 | 1 | return $this->array[$key] ?? false; |
|
129 | } |
||
130 | |||
131 | return $this->getArray(); |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * Whether or not an element exists by key. |
||
136 | * |
||
137 | * @param mixed $key |
||
138 | * |
||
139 | * @return bool |
||
140 | * <p>True is the key/index exists, otherwise false.</p> |
||
141 | */ |
||
142 | public function __isset($key): bool |
||
146 | |||
147 | /** |
||
148 | * Assigns a value to the specified element. |
||
149 | * |
||
150 | * @param mixed $key |
||
151 | * @param mixed $value |
||
152 | * |
||
153 | * @return void |
||
154 | */ |
||
155 | 2 | public function __set($key, $value) |
|
156 | { |
||
157 | 2 | $this->internalSet($key, $value); |
|
158 | 2 | } |
|
159 | |||
160 | /** |
||
161 | * magic to string |
||
162 | * |
||
163 | * @return string |
||
164 | */ |
||
165 | 15 | public function __toString(): string |
|
166 | { |
||
167 | 15 | return $this->toString(); |
|
168 | } |
||
169 | |||
170 | /** |
||
171 | * Unset element by key. |
||
172 | * |
||
173 | * @param mixed $key |
||
174 | */ |
||
175 | public function __unset($key) |
||
176 | { |
||
177 | $this->internalRemove($key); |
||
178 | } |
||
179 | |||
180 | /** |
||
181 | * Get a value by key. |
||
182 | * |
||
183 | * @param mixed $key |
||
184 | * |
||
185 | * @return mixed |
||
186 | * <p>Get a Value from the current array.</p> |
||
187 | */ |
||
188 | 4 | public function &__get($key) |
|
189 | { |
||
190 | 4 | $return = $this->get($key); |
|
191 | |||
192 | 4 | if (\is_array($return) === true) { |
|
193 | return static::create($return, $this->iteratorClass, false); |
||
194 | } |
||
195 | |||
196 | 4 | return $return; |
|
197 | } |
||
198 | |||
199 | /** |
||
200 | * alias: for "Arrayy->append()" |
||
201 | * |
||
202 | * @param mixed $value |
||
203 | * |
||
204 | * @return static |
||
205 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
206 | * |
||
207 | * @see Arrayy::append() |
||
208 | */ |
||
209 | 3 | public function add($value) |
|
210 | { |
||
211 | 3 | return $this->append($value); |
|
212 | } |
||
213 | |||
214 | /** |
||
215 | * Append a (key) + value to the current array. |
||
216 | * |
||
217 | * @param mixed $value |
||
218 | * @param mixed $key |
||
219 | * |
||
220 | * @return static |
||
221 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
222 | */ |
||
223 | 13 | public function append($value, $key = null): self |
|
224 | { |
||
225 | 13 | $this->generatorToArray(); |
|
226 | |||
227 | 13 | if ($this->properties !== []) { |
|
228 | 4 | $this->checkType($key, $value); |
|
229 | } |
||
230 | |||
231 | 12 | if ($key !== null) { |
|
232 | if ( |
||
233 | isset($this->array[$key]) |
||
234 | && |
||
235 | \is_array($this->array[$key]) === true |
||
236 | ) { |
||
237 | $this->array[$key][] = $value; |
||
238 | } else { |
||
239 | $this->array[$key] = $value; |
||
240 | } |
||
241 | } else { |
||
242 | 12 | $this->array[] = $value; |
|
243 | } |
||
244 | |||
245 | 12 | return $this; |
|
246 | } |
||
247 | |||
248 | /** |
||
249 | * Sort the entries by value. |
||
250 | * |
||
251 | * @param int $sort_flags [optional] <p> |
||
252 | * You may modify the behavior of the sort using the optional |
||
253 | * parameter sort_flags, for details |
||
254 | * see sort. |
||
255 | * </p> |
||
256 | * |
||
257 | * @return static |
||
258 | * <p>(Mutable) Return this Arrayy object.</p> |
||
259 | */ |
||
260 | 4 | public function asort(int $sort_flags = 0): self |
|
268 | |||
269 | /** |
||
270 | * Counts all elements in an array, or something in an object. |
||
271 | * |
||
272 | * <p> |
||
273 | * For objects, if you have SPL installed, you can hook into count() by implementing interface {@see Countable}. |
||
274 | * The interface has exactly one method, {@see Countable::count()}, which returns the return value for the count() |
||
275 | * function. Please see the {@see Array} section of the manual for a detailed explanation of how arrays are |
||
276 | * implemented and used in PHP. |
||
277 | * </p> |
||
278 | * |
||
279 | * @see http://php.net/manual/en/function.count.php |
||
280 | * |
||
281 | * @param int $mode [optional] If the optional mode parameter is set to |
||
282 | * COUNT_RECURSIVE (or 1), count |
||
283 | * will recursively count the array. This is particularly useful for |
||
284 | * counting all the elements of a multidimensional array. count does not detect infinite recursion. |
||
285 | * |
||
286 | * @return int |
||
287 | * <p> |
||
288 | * The number of elements in var, which is |
||
289 | * typically an array, since anything else will have one |
||
290 | * element. |
||
291 | * </p> |
||
292 | * <p> |
||
293 | * If var is not an array or an object with |
||
294 | * implemented Countable interface, |
||
295 | * 1 will be returned. |
||
296 | * There is one exception, if var is &null;, |
||
297 | * 0 will be returned. |
||
298 | * </p> |
||
299 | * <p> |
||
300 | * Caution: count may return 0 for a variable that isn't set, |
||
301 | * but it may also return 0 for a variable that has been initialized with an |
||
302 | * empty array. Use isset to test if a variable is set. |
||
303 | * </p> |
||
304 | */ |
||
305 | 145 | public function count(int $mode = \COUNT_NORMAL): int |
|
317 | |||
318 | /** |
||
319 | * Exchange the array for another one. |
||
320 | * |
||
321 | * @param array|static $data |
||
322 | * |
||
323 | * @return array |
||
324 | * |
||
325 | * @psalm-param array<TKey,T>|self<TKey,T> $data |
||
326 | * @psalm-return array<TKey,T> |
||
327 | */ |
||
328 | 1 | public function exchangeArray($data): array |
|
334 | |||
335 | /** |
||
336 | * Creates a copy of the ArrayyObject. |
||
337 | * |
||
338 | * @return array |
||
339 | * |
||
340 | * @psalm-return array<TKey,T> |
||
341 | */ |
||
342 | 5 | public function getArrayCopy(): array |
|
348 | |||
349 | /** |
||
350 | * Returns a new iterator, thus implementing the \Iterator interface. |
||
351 | * |
||
352 | * @return \Iterator<mixed, mixed> |
||
|
|||
353 | * <p>An iterator for the values in the array.</p> |
||
354 | */ |
||
355 | 24 | public function getIterator(): \Iterator |
|
369 | |||
370 | /** |
||
371 | * Gets the iterator classname for the ArrayObject. |
||
372 | * |
||
373 | * @return string |
||
374 | * |
||
375 | * @psalm-return class-string |
||
376 | */ |
||
377 | 23 | public function getIteratorClass(): string |
|
381 | |||
382 | /** |
||
383 | * Sort the entries by key |
||
384 | * |
||
385 | * @param int $sort_flags [optional] <p> |
||
386 | * You may modify the behavior of the sort using the optional |
||
387 | * parameter sort_flags, for details |
||
388 | * see sort. |
||
389 | * </p> |
||
390 | * |
||
391 | * @return static |
||
392 | * <p>(Mutable) Return this Arrayy object.</p> |
||
393 | */ |
||
394 | 4 | public function ksort(int $sort_flags = 0): self |
|
402 | |||
403 | /** |
||
404 | * Sort an array using a case insensitive "natural order" algorithm |
||
405 | * |
||
406 | * @return static |
||
407 | * <p>(Mutable) Return this Arrayy object.</p> |
||
408 | */ |
||
409 | public function natcasesort(): self |
||
417 | |||
418 | /** |
||
419 | * Sort entries using a "natural order" algorithm |
||
420 | * |
||
421 | * @return static |
||
422 | * <p>(Mutable) Return this Arrayy object.</p> |
||
423 | */ |
||
424 | 1 | public function natsort(): self |
|
432 | |||
433 | /** |
||
434 | * Whether or not an offset exists. |
||
435 | * |
||
436 | * @param bool|int|string $offset |
||
437 | * |
||
438 | * @return bool |
||
439 | * |
||
440 | * @noinspection PhpSillyAssignmentInspection |
||
441 | */ |
||
442 | 130 | public function offsetExists($offset): bool |
|
499 | |||
500 | /** |
||
501 | * Returns the value at specified offset. |
||
502 | * |
||
503 | * @param int|string $offset |
||
504 | * |
||
505 | * @return mixed |
||
506 | * <p>Will return null if the offset did not exists.</p> |
||
507 | */ |
||
508 | 101 | public function offsetGet($offset) |
|
512 | |||
513 | /** |
||
514 | * Assigns a value to the specified offset + check the type. |
||
515 | * |
||
516 | * @param int|string|null $offset |
||
517 | * @param mixed $value |
||
518 | * |
||
519 | * @return void |
||
520 | */ |
||
521 | 21 | public function offsetSet($offset, $value) |
|
539 | |||
540 | /** |
||
541 | * Unset an offset. |
||
542 | * |
||
543 | * @param int|string $offset |
||
544 | * |
||
545 | * @return void |
||
546 | */ |
||
547 | 12 | public function offsetUnset($offset) |
|
584 | |||
585 | /** |
||
586 | * Serialize the current "Arrayy"-object. |
||
587 | * |
||
588 | * @return string |
||
589 | */ |
||
590 | 2 | public function serialize(): string |
|
600 | |||
601 | /** |
||
602 | * Sets the iterator classname for the current "Arrayy"-object. |
||
603 | * |
||
604 | * @param string $iteratorClass |
||
605 | * |
||
606 | * @throws \InvalidArgumentException |
||
607 | * |
||
608 | * @return void |
||
609 | * |
||
610 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
611 | */ |
||
612 | 1057 | public function setIteratorClass($iteratorClass) |
|
631 | |||
632 | /** |
||
633 | * Sort the entries with a user-defined comparison function and maintain key association. |
||
634 | * |
||
635 | * @param callable $function |
||
636 | * |
||
637 | * @throws \InvalidArgumentException |
||
638 | * |
||
639 | * @return static |
||
640 | * <p>(Mutable) Return this Arrayy object.</p> |
||
641 | */ |
||
642 | View Code Duplication | public function uasort($function): self |
|
654 | |||
655 | /** |
||
656 | * Sort the entries by keys using a user-defined comparison function. |
||
657 | * |
||
658 | * @param callable $function |
||
659 | * |
||
660 | * @throws \InvalidArgumentException |
||
661 | * |
||
662 | * @return static |
||
663 | * <p>(Mutable) Return this Arrayy object.</p> |
||
664 | */ |
||
665 | 5 | public function uksort($function): self |
|
669 | |||
670 | /** |
||
671 | * Unserialize an string and return the instance of the "Arrayy"-class. |
||
672 | * |
||
673 | * @param string $string |
||
674 | * |
||
675 | * @return static |
||
676 | */ |
||
677 | 2 | public function unserialize($string): self |
|
687 | |||
688 | /** |
||
689 | * Append a (key) + values to the current array. |
||
690 | * |
||
691 | * @param array $values |
||
692 | * @param mixed $key |
||
693 | * |
||
694 | * @return static |
||
695 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
696 | * |
||
697 | * @psalm-param array<mixed,T> $values |
||
698 | * @psalm-param TKey|null $key |
||
699 | */ |
||
700 | 1 | public function appendArrayValues(array $values, $key = null) |
|
726 | |||
727 | /** |
||
728 | * Add a suffix to each key. |
||
729 | * |
||
730 | * @param mixed $prefix |
||
731 | * |
||
732 | * @return static |
||
733 | * <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> |
||
734 | */ |
||
735 | 10 | View Code Duplication | public function appendToEachKey($prefix): self |
754 | |||
755 | /** |
||
756 | * Add a prefix to each value. |
||
757 | * |
||
758 | * @param mixed $prefix |
||
759 | * |
||
760 | * @return static |
||
761 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
||
762 | */ |
||
763 | 10 | View Code Duplication | public function appendToEachValue($prefix): self |
782 | |||
783 | /** |
||
784 | * Sort an array in reverse order and maintain index association. |
||
785 | * |
||
786 | * @return static |
||
787 | * <p>(Mutable) Return this Arrayy object.</p> |
||
788 | */ |
||
789 | 10 | public function arsort(): self |
|
797 | |||
798 | /** |
||
799 | * Iterate over the current array and execute a callback for each loop. |
||
800 | * |
||
801 | * @param \Closure $closure |
||
802 | * |
||
803 | * @return static |
||
804 | * <p>(Immutable)</p> |
||
805 | */ |
||
806 | 2 | public function at(\Closure $closure): self |
|
820 | |||
821 | /** |
||
822 | * Returns the average value of the current array. |
||
823 | * |
||
824 | * @param int $decimals <p>The number of decimal-numbers to return.</p> |
||
825 | * |
||
826 | * @return float|int |
||
827 | * <p>The average value.</p> |
||
828 | */ |
||
829 | 10 | public function average($decimals = 0) |
|
843 | |||
844 | /** |
||
845 | * Changes all keys in an array. |
||
846 | * |
||
847 | * @param int $case [optional] <p> Either <strong>CASE_UPPER</strong><br /> |
||
848 | * or <strong>CASE_LOWER</strong> (default)</p> |
||
849 | * |
||
850 | * @return static |
||
851 | * <p>(Immutable)</p> |
||
852 | */ |
||
853 | 1 | public function changeKeyCase(int $case = \CASE_LOWER): self |
|
880 | |||
881 | /** |
||
882 | * Change the path separator of the array wrapper. |
||
883 | * |
||
884 | * By default, the separator is: "." |
||
885 | * |
||
886 | * @param string $separator <p>Separator to set.</p> |
||
887 | * |
||
888 | * @return static |
||
889 | * <p>Mutable</p> |
||
890 | */ |
||
891 | 11 | public function changeSeparator($separator): self |
|
897 | |||
898 | /** |
||
899 | * Create a chunked version of the current array. |
||
900 | * |
||
901 | * @param int $size <p>Size of each chunk.</p> |
||
902 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
903 | * |
||
904 | * @return static |
||
905 | * <p>(Immutable) A new array of chunks from the original array.</p> |
||
906 | */ |
||
907 | 5 | public function chunk($size, $preserveKeys = false): self |
|
915 | |||
916 | /** |
||
917 | * Clean all falsy values from the current array. |
||
918 | * |
||
919 | * @return static |
||
920 | * <p>(Immutable)</p> |
||
921 | */ |
||
922 | 8 | public function clean(): self |
|
930 | |||
931 | /** |
||
932 | * WARNING!!! -> Clear the current array. |
||
933 | * |
||
934 | * @return static |
||
935 | * <p>(Mutable) Return this Arrayy object, with an empty array.</p> |
||
936 | */ |
||
937 | 5 | public function clear(): self |
|
944 | |||
945 | /** |
||
946 | * Check if an item is in the current array. |
||
947 | * |
||
948 | * @param float|int|string $value |
||
949 | * @param bool $recursive |
||
950 | * @param bool $strict |
||
951 | * |
||
952 | * @return bool |
||
953 | */ |
||
954 | 23 | public function contains($value, bool $recursive = false, bool $strict = true): bool |
|
975 | |||
976 | /** |
||
977 | * Check if an (case-insensitive) string is in the current array. |
||
978 | * |
||
979 | * @param string $value |
||
980 | * @param bool $recursive |
||
981 | * |
||
982 | * @return bool |
||
983 | */ |
||
984 | 26 | public function containsCaseInsensitive($value, $recursive = false): bool |
|
1009 | |||
1010 | /** |
||
1011 | * Check if the given key/index exists in the array. |
||
1012 | * |
||
1013 | * @param int|string $key <p>key/index to search for</p> |
||
1014 | * |
||
1015 | * @return bool |
||
1016 | * <p>Returns true if the given key/index exists in the array, false otherwise.</p> |
||
1017 | */ |
||
1018 | 4 | public function containsKey($key): bool |
|
1022 | |||
1023 | /** |
||
1024 | * Check if all given needles are present in the array as key/index. |
||
1025 | * |
||
1026 | * @param array $needles <p>The keys you are searching for.</p> |
||
1027 | * @param bool $recursive |
||
1028 | * |
||
1029 | * @return bool |
||
1030 | * <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p> |
||
1031 | * |
||
1032 | * @psalm-param array<mixed,mixed>|array<TKey> $needles |
||
1033 | */ |
||
1034 | 2 | public function containsKeys(array $needles, $recursive = false): bool |
|
1062 | |||
1063 | /** |
||
1064 | * Check if all given needles are present in the array as key/index. |
||
1065 | * |
||
1066 | * @param array $needles <p>The keys you are searching for.</p> |
||
1067 | * |
||
1068 | * @return bool |
||
1069 | * <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p> |
||
1070 | * |
||
1071 | * @psalm-param array<mixed,mixed>|array<TKey> $needles |
||
1072 | */ |
||
1073 | 1 | public function containsKeysRecursive(array $needles): bool |
|
1077 | |||
1078 | /** |
||
1079 | * alias: for "Arrayy->contains()" |
||
1080 | * |
||
1081 | * @param float|int|string $value |
||
1082 | * |
||
1083 | * @return bool |
||
1084 | * |
||
1085 | * @see Arrayy::contains() |
||
1086 | */ |
||
1087 | 9 | public function containsValue($value): bool |
|
1091 | |||
1092 | /** |
||
1093 | * alias: for "Arrayy->contains($value, true)" |
||
1094 | * |
||
1095 | * @param float|int|string $value |
||
1096 | * |
||
1097 | * @return bool |
||
1098 | * |
||
1099 | * @see Arrayy::contains() |
||
1100 | */ |
||
1101 | 18 | public function containsValueRecursive($value): bool |
|
1105 | |||
1106 | /** |
||
1107 | * Check if all given needles are present in the array. |
||
1108 | * |
||
1109 | * @param array $needles |
||
1110 | * |
||
1111 | * @return bool |
||
1112 | * <p>Returns true if all the given values exists in the array, false otherwise.</p> |
||
1113 | * |
||
1114 | * @psalm-param array<mixed>|array<T> $needles |
||
1115 | */ |
||
1116 | 1 | public function containsValues(array $needles): bool |
|
1122 | |||
1123 | /** |
||
1124 | * Counts all the values of an array |
||
1125 | * |
||
1126 | * @see http://php.net/manual/en/function.array-count-values.php |
||
1127 | * |
||
1128 | * @return static |
||
1129 | * <p> |
||
1130 | * (Immutable) |
||
1131 | * An associative Arrayy-object of values from input as |
||
1132 | * keys and their count as value. |
||
1133 | * </p> |
||
1134 | */ |
||
1135 | 7 | public function countValues(): self |
|
1139 | |||
1140 | /** |
||
1141 | * Creates an Arrayy object. |
||
1142 | * |
||
1143 | * @param mixed $data |
||
1144 | * @param string $iteratorClass |
||
1145 | * @param bool $checkPropertiesInConstructor |
||
1146 | * |
||
1147 | * @return static |
||
1148 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1149 | * |
||
1150 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
1151 | */ |
||
1152 | 670 | public static function create( |
|
1163 | |||
1164 | /** |
||
1165 | * WARNING: Creates an Arrayy object by reference. |
||
1166 | * |
||
1167 | * @param array $array |
||
1168 | * |
||
1169 | * @return static |
||
1170 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1171 | * |
||
1172 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1173 | */ |
||
1174 | 1 | public function createByReference(array &$array = []): self |
|
1182 | |||
1183 | /** |
||
1184 | * Create an new instance from a callable function which will return an Generator. |
||
1185 | * |
||
1186 | * @param callable $generatorFunction |
||
1187 | * |
||
1188 | * @return static |
||
1189 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1190 | * |
||
1191 | * @psalm-param callable():\Generator<TKey,T> $generatorFunction |
||
1192 | */ |
||
1193 | 5 | public static function createFromGeneratorFunction(callable $generatorFunction): self |
|
1197 | |||
1198 | /** |
||
1199 | * Create an new instance filled with a copy of values from a "Generator"-object. |
||
1200 | * |
||
1201 | * @param \Generator $generator |
||
1202 | * |
||
1203 | * @return static |
||
1204 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1205 | * |
||
1206 | * @psalm-param \Generator<TKey,T> $generator |
||
1207 | */ |
||
1208 | 4 | public static function createFromGeneratorImmutable(\Generator $generator): self |
|
1212 | |||
1213 | /** |
||
1214 | * Create an new Arrayy object via JSON. |
||
1215 | * |
||
1216 | * @param string $json |
||
1217 | * |
||
1218 | * @return static |
||
1219 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1220 | */ |
||
1221 | 5 | public static function createFromJson(string $json): self |
|
1225 | |||
1226 | /** |
||
1227 | * Create an new instance filled with values from an object that is iterable. |
||
1228 | * |
||
1229 | * @param \Traversable $object <p>iterable object</p> |
||
1230 | * |
||
1231 | * @return static |
||
1232 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1233 | * |
||
1234 | * @psalm-param \Traversable<TKey,T> $object |
||
1235 | */ |
||
1236 | 4 | public static function createFromObject(\Traversable $object): self |
|
1253 | |||
1254 | /** |
||
1255 | * Create an new instance filled with values from an object. |
||
1256 | * |
||
1257 | * @param object $object |
||
1258 | * |
||
1259 | * @return static |
||
1260 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1261 | */ |
||
1262 | 5 | public static function createFromObjectVars($object): self |
|
1266 | |||
1267 | /** |
||
1268 | * Create an new Arrayy object via string. |
||
1269 | * |
||
1270 | * @param string $str <p>The input string.</p> |
||
1271 | * @param string|null $delimiter <p>The boundary string.</p> |
||
1272 | * @param string|null $regEx <p>Use the $delimiter or the $regEx, so if $pattern is null, $delimiter will be |
||
1273 | * used.</p> |
||
1274 | * |
||
1275 | * @return static |
||
1276 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1277 | */ |
||
1278 | 10 | public static function createFromString(string $str, string $delimiter = null, string $regEx = null): self |
|
1307 | |||
1308 | /** |
||
1309 | * Create an new instance filled with a copy of values from a "Traversable"-object. |
||
1310 | * |
||
1311 | * @param \Traversable $traversable |
||
1312 | * |
||
1313 | * @return static |
||
1314 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1315 | * |
||
1316 | * @psalm-param \Traversable<TKey,T> $traversable |
||
1317 | */ |
||
1318 | 1 | public static function createFromTraversableImmutable(\Traversable $traversable): self |
|
1322 | |||
1323 | /** |
||
1324 | * Create an new instance containing a range of elements. |
||
1325 | * |
||
1326 | * @param mixed $low <p>First value of the sequence.</p> |
||
1327 | * @param mixed $high <p>The sequence is ended upon reaching the end value.</p> |
||
1328 | * @param int $step <p>Used as the increment between elements in the sequence.</p> |
||
1329 | * |
||
1330 | * @return static |
||
1331 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
1332 | */ |
||
1333 | 2 | public static function createWithRange($low, $high, int $step = 1): self |
|
1337 | |||
1338 | /** |
||
1339 | * Gets the element of the array at the current internal iterator position. |
||
1340 | * |
||
1341 | * @return false|mixed |
||
1342 | */ |
||
1343 | public function current() |
||
1347 | |||
1348 | /** |
||
1349 | * Custom sort by index via "uksort". |
||
1350 | * |
||
1351 | * @see http://php.net/manual/en/function.uksort.php |
||
1352 | * |
||
1353 | * @param callable $function |
||
1354 | * |
||
1355 | * @throws \InvalidArgumentException |
||
1356 | * |
||
1357 | * @return static |
||
1358 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1359 | */ |
||
1360 | 5 | public function customSortKeys(callable $function): self |
|
1368 | |||
1369 | /** |
||
1370 | * Custom sort by value via "usort". |
||
1371 | * |
||
1372 | * @see http://php.net/manual/en/function.usort.php |
||
1373 | * |
||
1374 | * @param callable $function |
||
1375 | * |
||
1376 | * @throws \InvalidArgumentException |
||
1377 | * |
||
1378 | * @return static |
||
1379 | * <p>(Mutable) Return this Arrayy object.</p> |
||
1380 | */ |
||
1381 | 6 | View Code Duplication | public function customSortValues($function): self |
1393 | |||
1394 | /** |
||
1395 | * Delete the given key or keys. |
||
1396 | * |
||
1397 | * @param int|int[]|string|string[] $keyOrKeys |
||
1398 | * |
||
1399 | * @return void |
||
1400 | */ |
||
1401 | 4 | public function delete($keyOrKeys) |
|
1409 | |||
1410 | /** |
||
1411 | * Return values that are only in the current array. |
||
1412 | * |
||
1413 | * @param array ...$array |
||
1414 | * |
||
1415 | * @return static |
||
1416 | * <p>(Immutable)</p> |
||
1417 | * |
||
1418 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
1419 | */ |
||
1420 | 13 | public function diff(...$array): self |
|
1428 | |||
1429 | /** |
||
1430 | * Return values that are only in the current array. |
||
1431 | * |
||
1432 | * @param array ...$array |
||
1433 | * |
||
1434 | * @return static |
||
1435 | * <p>(Immutable)</p> |
||
1436 | * |
||
1437 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
1438 | */ |
||
1439 | 8 | public function diffKey(...$array): self |
|
1447 | |||
1448 | /** |
||
1449 | * Return values and Keys that are only in the current array. |
||
1450 | * |
||
1451 | * @param array $array |
||
1452 | * |
||
1453 | * @return static |
||
1454 | * <p>(Immutable)</p> |
||
1455 | * |
||
1456 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1457 | */ |
||
1458 | 8 | public function diffKeyAndValue(array $array = []): self |
|
1466 | |||
1467 | /** |
||
1468 | * Return values that are only in the current multi-dimensional array. |
||
1469 | * |
||
1470 | * @param array $array |
||
1471 | * @param array|null $helperVariableForRecursion <p>(only for internal usage)</p> |
||
1472 | * |
||
1473 | * @return static |
||
1474 | * <p>(Immutable)</p> |
||
1475 | * |
||
1476 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1477 | * @psalm-param null|array<TKey,T> $helperVariableForRecursion |
||
1478 | */ |
||
1479 | 1 | public function diffRecursive(array $array = [], $helperVariableForRecursion = null): self |
|
1514 | |||
1515 | /** |
||
1516 | * Return values that are only in the new $array. |
||
1517 | * |
||
1518 | * @param array $array |
||
1519 | * |
||
1520 | * @return static |
||
1521 | * <p>(Immutable)</p> |
||
1522 | * |
||
1523 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1524 | */ |
||
1525 | 8 | public function diffReverse(array $array = []): self |
|
1533 | |||
1534 | /** |
||
1535 | * Divide an array into two arrays. One with keys and the other with values. |
||
1536 | * |
||
1537 | * @return static |
||
1538 | * <p>(Immutable)</p> |
||
1539 | */ |
||
1540 | 1 | public function divide(): self |
|
1551 | |||
1552 | /** |
||
1553 | * Iterate over the current array and modify the array's value. |
||
1554 | * |
||
1555 | * @param \Closure $closure |
||
1556 | * |
||
1557 | * @return static |
||
1558 | * <p>(Immutable)</p> |
||
1559 | */ |
||
1560 | 5 | View Code Duplication | public function each(\Closure $closure): self |
1575 | |||
1576 | /** |
||
1577 | * Sets the internal iterator to the last element in the array and returns this element. |
||
1578 | * |
||
1579 | * @return mixed |
||
1580 | */ |
||
1581 | public function end() |
||
1585 | |||
1586 | /** |
||
1587 | * Check if a value is in the current array using a closure. |
||
1588 | * |
||
1589 | * @param \Closure $closure |
||
1590 | * |
||
1591 | * @return bool |
||
1592 | * <p>Returns true if the given value is found, false otherwise.</p> |
||
1593 | */ |
||
1594 | 4 | public function exists(\Closure $closure): bool |
|
1609 | |||
1610 | /** |
||
1611 | * Fill the array until "$num" with "$default" values. |
||
1612 | * |
||
1613 | * @param int $num |
||
1614 | * @param mixed $default |
||
1615 | * |
||
1616 | * @return static |
||
1617 | * <p>(Immutable)</p> |
||
1618 | */ |
||
1619 | 8 | public function fillWithDefaults(int $num, $default = null): self |
|
1642 | |||
1643 | /** |
||
1644 | * Find all items in an array that pass the truth test. |
||
1645 | * |
||
1646 | * @param \Closure|null $closure [optional] <p> |
||
1647 | * The callback function to use |
||
1648 | * </p> |
||
1649 | * <p> |
||
1650 | * If no callback is supplied, all entries of |
||
1651 | * input equal to false (see |
||
1652 | * converting to |
||
1653 | * boolean) will be removed. |
||
1654 | * </p> |
||
1655 | * @param int $flag [optional] <p> |
||
1656 | * Flag determining what arguments are sent to <i>callback</i>: |
||
1657 | * </p><ul> |
||
1658 | * <li> |
||
1659 | * <b>ARRAY_FILTER_USE_KEY</b> [1] - pass key as the only argument |
||
1660 | * to <i>callback</i> instead of the value</span> |
||
1661 | * </li> |
||
1662 | * <li> |
||
1663 | * <b>ARRAY_FILTER_USE_BOTH</b> [2] - pass both value and key as |
||
1664 | * arguments to <i>callback</i> instead of the value</span> |
||
1665 | * </li> |
||
1666 | * </ul> |
||
1667 | * |
||
1668 | * @return static |
||
1669 | * <p>(Immutable)</p> |
||
1670 | */ |
||
1671 | 12 | public function filter($closure = null, int $flag = \ARRAY_FILTER_USE_BOTH) |
|
1683 | |||
1684 | /** |
||
1685 | * Filters an array of objects (or a numeric array of associative arrays) based on the value of a particular |
||
1686 | * property within that. |
||
1687 | * |
||
1688 | * @param string $property |
||
1689 | * @param string|string[] $value |
||
1690 | * @param string $comparisonOp |
||
1691 | * <p> |
||
1692 | * 'eq' (equals),<br /> |
||
1693 | * 'gt' (greater),<br /> |
||
1694 | * 'gte' || 'ge' (greater or equals),<br /> |
||
1695 | * 'lt' (less),<br /> |
||
1696 | * 'lte' || 'le' (less or equals),<br /> |
||
1697 | * 'ne' (not equals),<br /> |
||
1698 | * 'contains',<br /> |
||
1699 | * 'notContains',<br /> |
||
1700 | * 'newer' (via strtotime),<br /> |
||
1701 | * 'older' (via strtotime),<br /> |
||
1702 | * </p> |
||
1703 | * |
||
1704 | * @return static |
||
1705 | * <p>(Immutable)</p> |
||
1706 | */ |
||
1707 | 1 | public function filterBy(string $property, $value, string $comparisonOp = null): self |
|
1776 | |||
1777 | /** |
||
1778 | * Find the first item in an array that passes the truth test, |
||
1779 | * otherwise return false |
||
1780 | * |
||
1781 | * @param \Closure $closure |
||
1782 | * |
||
1783 | * @return false|mixed |
||
1784 | * <p>Return false if we did not find the value.</p> |
||
1785 | */ |
||
1786 | 8 | View Code Duplication | public function find(\Closure $closure) |
1796 | |||
1797 | /** |
||
1798 | * find by ... |
||
1799 | * |
||
1800 | * @param string $property |
||
1801 | * @param string|string[] $value |
||
1802 | * @param string $comparisonOp |
||
1803 | * |
||
1804 | * @return static |
||
1805 | * <p>(Immutable)</p> |
||
1806 | */ |
||
1807 | 1 | public function findBy(string $property, $value, string $comparisonOp = 'eq'): self |
|
1811 | |||
1812 | /** |
||
1813 | * Get the first value from the current array. |
||
1814 | * |
||
1815 | * @return mixed |
||
1816 | * <p>Return null if there wasn't a element.</p> |
||
1817 | */ |
||
1818 | 21 | public function first() |
|
1827 | |||
1828 | /** |
||
1829 | * Get the first key from the current array. |
||
1830 | * |
||
1831 | * @return mixed |
||
1832 | * <p>Return null if there wasn't a element.</p> |
||
1833 | */ |
||
1834 | 28 | public function firstKey() |
|
1840 | |||
1841 | /** |
||
1842 | * Get the first value(s) from the current array. |
||
1843 | * And will return an empty array if there was no first entry. |
||
1844 | * |
||
1845 | * @param int|null $number <p>How many values you will take?</p> |
||
1846 | * |
||
1847 | * @return static |
||
1848 | * <p>(Immutable)</p> |
||
1849 | */ |
||
1850 | 37 | View Code Duplication | public function firstsImmutable(int $number = null): self |
1867 | |||
1868 | /** |
||
1869 | * Get the first value(s) from the current array. |
||
1870 | * And will return an empty array if there was no first entry. |
||
1871 | * |
||
1872 | * @param int|null $number <p>How many values you will take?</p> |
||
1873 | * |
||
1874 | * @return static |
||
1875 | * <p>(Immutable)</p> |
||
1876 | */ |
||
1877 | 3 | View Code Duplication | public function firstsKeys(int $number = null): self |
1894 | |||
1895 | /** |
||
1896 | * Get and rmove the first value(s) from the current array. |
||
1897 | * And will return an empty array if there was no first entry. |
||
1898 | * |
||
1899 | * @param int|null $number <p>How many values you will take?</p> |
||
1900 | * |
||
1901 | * @return static |
||
1902 | * <p>(Mutable)</p> |
||
1903 | */ |
||
1904 | 34 | public function firstsMutable(int $number = null): self |
|
1917 | |||
1918 | /** |
||
1919 | * Exchanges all keys with their associated values in an array. |
||
1920 | * |
||
1921 | * @return static |
||
1922 | * <p>(Immutable)</p> |
||
1923 | */ |
||
1924 | 1 | public function flip(): self |
|
1932 | |||
1933 | /** |
||
1934 | * Get a value from an array (optional using dot-notation). |
||
1935 | * |
||
1936 | * @param mixed $key <p>The key to look for.</p> |
||
1937 | * @param mixed $fallback <p>Value to fallback to.</p> |
||
1938 | * @param array $array <p>The array to get from, if it's set to "null" we use the current array from the |
||
1939 | * class.</p> |
||
1940 | * |
||
1941 | * @return mixed|static |
||
1942 | * |
||
1943 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
1944 | */ |
||
1945 | 172 | public function get($key, $fallback = null, array $array = null) |
|
2037 | |||
2038 | /** |
||
2039 | * alias: for "Arrayy->getArray()" |
||
2040 | * |
||
2041 | * @return array |
||
2042 | * |
||
2043 | * @see Arrayy::getArray() |
||
2044 | * |
||
2045 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
2046 | */ |
||
2047 | 1 | public function getAll(): array |
|
2051 | |||
2052 | /** |
||
2053 | * Get the current array from the "Arrayy"-object. |
||
2054 | * |
||
2055 | * @param bool $convertAllArrayyElements |
||
2056 | * |
||
2057 | * @return array |
||
2058 | * |
||
2059 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
2060 | */ |
||
2061 | 859 | public function getArray($convertAllArrayyElements = false): array |
|
2082 | |||
2083 | /** |
||
2084 | * Returns the values from a single column of the input array, identified by |
||
2085 | * the $columnKey, can be used to extract data-columns from multi-arrays. |
||
2086 | * |
||
2087 | * Info: Optionally, you may provide an $indexKey to index the values in the returned |
||
2088 | * array by the values from the $indexKey column in the input array. |
||
2089 | * |
||
2090 | * @param mixed $columnKey |
||
2091 | * @param mixed $indexKey |
||
2092 | * |
||
2093 | * @return static |
||
2094 | * <p>(Immutable)</p> |
||
2095 | */ |
||
2096 | 1 | public function getColumn($columnKey = null, $indexKey = null): self |
|
2104 | |||
2105 | /** |
||
2106 | * Get the current array from the "Arrayy"-object as generator. |
||
2107 | * |
||
2108 | * @return \Generator |
||
2109 | * |
||
2110 | * @psalm-return \Generator<mixed,T>|\Generator<TKey,T> |
||
2111 | */ |
||
2112 | 942 | public function getGenerator(): \Generator |
|
2120 | |||
2121 | /** |
||
2122 | * alias: for "Arrayy->keys()" |
||
2123 | * |
||
2124 | * @return static |
||
2125 | * <p>(Immutable)</p> |
||
2126 | * |
||
2127 | * @see Arrayy::keys() |
||
2128 | */ |
||
2129 | 2 | public function getKeys() |
|
2133 | |||
2134 | /** |
||
2135 | * Get the current array from the "Arrayy"-object as object. |
||
2136 | * |
||
2137 | * @return \stdClass |
||
2138 | */ |
||
2139 | 4 | public function getObject(): \stdClass |
|
2143 | |||
2144 | /** |
||
2145 | * alias: for "Arrayy->randomImmutable()" |
||
2146 | * |
||
2147 | * @return static |
||
2148 | * <p>(Immutable)</p> |
||
2149 | * |
||
2150 | * @see Arrayy::randomImmutable() |
||
2151 | */ |
||
2152 | 4 | public function getRandom(): self |
|
2156 | |||
2157 | /** |
||
2158 | * alias: for "Arrayy->randomKey()" |
||
2159 | * |
||
2160 | * @return mixed |
||
2161 | * <p>Get a key/index or null if there wasn't a key/index.</p> |
||
2162 | * |
||
2163 | * @see Arrayy::randomKey() |
||
2164 | */ |
||
2165 | 3 | public function getRandomKey() |
|
2169 | |||
2170 | /** |
||
2171 | * alias: for "Arrayy->randomKeys()" |
||
2172 | * |
||
2173 | * @param int $number |
||
2174 | * |
||
2175 | * @return static |
||
2176 | * <p>(Immutable)</p> |
||
2177 | * |
||
2178 | * @see Arrayy::randomKeys() |
||
2179 | */ |
||
2180 | 8 | public function getRandomKeys(int $number): self |
|
2184 | |||
2185 | /** |
||
2186 | * alias: for "Arrayy->randomValue()" |
||
2187 | * |
||
2188 | * @return mixed |
||
2189 | * <p>Get a random value or null if there wasn't a value.</p> |
||
2190 | * |
||
2191 | * @see Arrayy::randomValue() |
||
2192 | */ |
||
2193 | 3 | public function getRandomValue() |
|
2197 | |||
2198 | /** |
||
2199 | * alias: for "Arrayy->randomValues()" |
||
2200 | * |
||
2201 | * @param int $number |
||
2202 | * |
||
2203 | * @return static |
||
2204 | * <p>(Immutable)</p> |
||
2205 | * |
||
2206 | * @see Arrayy::randomValues() |
||
2207 | */ |
||
2208 | 6 | public function getRandomValues(int $number): self |
|
2212 | |||
2213 | /** |
||
2214 | * Gets all values. |
||
2215 | * |
||
2216 | * @return static |
||
2217 | * <p>The values of all elements in this array, in the order they |
||
2218 | * appear in the array.</p> |
||
2219 | */ |
||
2220 | 4 | public function getValues() |
|
2230 | |||
2231 | /** |
||
2232 | * Gets all values via Generator. |
||
2233 | * |
||
2234 | * @return \Generator |
||
2235 | * <p>The values of all elements in this array, in the order they |
||
2236 | * appear in the array as Generator.</p> |
||
2237 | * |
||
2238 | * @psalm-return \Generator<TKey,T> |
||
2239 | */ |
||
2240 | 4 | public function getValuesYield(): \Generator |
|
2244 | |||
2245 | /** |
||
2246 | * Group values from a array according to the results of a closure. |
||
2247 | * |
||
2248 | * @param callable|string $grouper <p>A callable function name.</p> |
||
2249 | * @param bool $saveKeys |
||
2250 | * |
||
2251 | * @return static |
||
2252 | * <p>(Immutable)</p> |
||
2253 | */ |
||
2254 | 4 | public function group($grouper, bool $saveKeys = false): self |
|
2295 | |||
2296 | /** |
||
2297 | * Check if an array has a given key. |
||
2298 | * |
||
2299 | * @param mixed $key |
||
2300 | * |
||
2301 | * @return bool |
||
2302 | */ |
||
2303 | 23 | public function has($key): bool |
|
2314 | |||
2315 | /** |
||
2316 | * Check if an array has a given value. |
||
2317 | * |
||
2318 | * INFO: if you need to search recursive please use ```contains()``` |
||
2319 | * |
||
2320 | * @param mixed $value |
||
2321 | * |
||
2322 | * @return bool |
||
2323 | */ |
||
2324 | 1 | public function hasValue($value): bool |
|
2328 | |||
2329 | /** |
||
2330 | * Implodes the values of this array. |
||
2331 | * |
||
2332 | * @param string $glue |
||
2333 | * |
||
2334 | * @return string |
||
2335 | */ |
||
2336 | 28 | public function implode(string $glue = ''): string |
|
2340 | |||
2341 | /** |
||
2342 | * Implodes the keys of this array. |
||
2343 | * |
||
2344 | * @param string $glue |
||
2345 | * |
||
2346 | * @return string |
||
2347 | */ |
||
2348 | 8 | public function implodeKeys(string $glue = ''): string |
|
2352 | |||
2353 | /** |
||
2354 | * Given a list and an iterate-function that returns |
||
2355 | * a key for each element in the list (or a property name), |
||
2356 | * returns an object with an index of each item. |
||
2357 | * |
||
2358 | * @param mixed $key |
||
2359 | * |
||
2360 | * @return static |
||
2361 | * <p>(Immutable)</p> |
||
2362 | */ |
||
2363 | 4 | public function indexBy($key): self |
|
2380 | |||
2381 | /** |
||
2382 | * alias: for "Arrayy->searchIndex()" |
||
2383 | * |
||
2384 | * @param mixed $value <p>The value to search for.</p> |
||
2385 | * |
||
2386 | * @return false|mixed |
||
2387 | * |
||
2388 | * @see Arrayy::searchIndex() |
||
2389 | */ |
||
2390 | 4 | public function indexOf($value) |
|
2394 | |||
2395 | /** |
||
2396 | * Get everything but the last..$to items. |
||
2397 | * |
||
2398 | * @param int $to |
||
2399 | * |
||
2400 | * @return static |
||
2401 | * <p>(Immutable)</p> |
||
2402 | */ |
||
2403 | 12 | public function initial(int $to = 1): self |
|
2407 | |||
2408 | /** |
||
2409 | * Return an array with all elements found in input array. |
||
2410 | * |
||
2411 | * @param array $search |
||
2412 | * @param bool $keepKeys |
||
2413 | * |
||
2414 | * @return static |
||
2415 | * <p>(Immutable)</p> |
||
2416 | * |
||
2417 | * @psalm-param array<mixed,mixed>|array<TKey,T> $search |
||
2418 | */ |
||
2419 | 4 | public function intersection(array $search, bool $keepKeys = false): self |
|
2441 | |||
2442 | /** |
||
2443 | * Return an array with all elements found in input array. |
||
2444 | * |
||
2445 | * @param array ...$array |
||
2446 | * |
||
2447 | * @return static |
||
2448 | * <p>(Immutable)</p> |
||
2449 | * |
||
2450 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
2451 | */ |
||
2452 | 1 | public function intersectionMulti(...$array): self |
|
2460 | |||
2461 | /** |
||
2462 | * Return a boolean flag which indicates whether the two input arrays have any common elements. |
||
2463 | * |
||
2464 | * @param array $search |
||
2465 | * |
||
2466 | * @return bool |
||
2467 | * |
||
2468 | * @psalm-param array<mixed,mixed>|array<TKey,T> $search |
||
2469 | */ |
||
2470 | 1 | public function intersects(array $search): bool |
|
2474 | |||
2475 | /** |
||
2476 | * Invoke a function on all of an array's values. |
||
2477 | * |
||
2478 | * @param callable $callable |
||
2479 | * @param mixed $arguments |
||
2480 | * |
||
2481 | * @return static |
||
2482 | * <p>(Immutable)</p> |
||
2483 | */ |
||
2484 | 1 | public function invoke($callable, $arguments = []): self |
|
2508 | |||
2509 | /** |
||
2510 | * Check whether array is associative or not. |
||
2511 | * |
||
2512 | * @param bool $recursive |
||
2513 | * |
||
2514 | * @return bool |
||
2515 | * <p>Returns true if associative, false otherwise.</p> |
||
2516 | */ |
||
2517 | 15 | View Code Duplication | public function isAssoc(bool $recursive = false): bool |
2531 | |||
2532 | /** |
||
2533 | * Check if a given key or keys are empty. |
||
2534 | * |
||
2535 | * @param int|int[]|string|string[]|null $keys |
||
2536 | * |
||
2537 | * @return bool |
||
2538 | * <p>Returns true if empty, false otherwise.</p> |
||
2539 | */ |
||
2540 | 38 | public function isEmpty($keys = null): bool |
|
2558 | |||
2559 | /** |
||
2560 | * Check if the current array is equal to the given "$array" or not. |
||
2561 | * |
||
2562 | * @param array $array |
||
2563 | * |
||
2564 | * @return bool |
||
2565 | * |
||
2566 | * @psalm-param array<mixed,mixed> $array |
||
2567 | */ |
||
2568 | 1 | public function isEqual(array $array): bool |
|
2572 | |||
2573 | /** |
||
2574 | * Check if the current array is a multi-array. |
||
2575 | * |
||
2576 | * @return bool |
||
2577 | */ |
||
2578 | 22 | public function isMultiArray(): bool |
|
2586 | |||
2587 | /** |
||
2588 | * Check whether array is numeric or not. |
||
2589 | * |
||
2590 | * @return bool |
||
2591 | * <p>Returns true if numeric, false otherwise.</p> |
||
2592 | */ |
||
2593 | 5 | View Code Duplication | public function isNumeric(): bool |
2607 | |||
2608 | /** |
||
2609 | * Check if the current array is sequential [0, 1, 2, 3, 4, 5 ...] or not. |
||
2610 | * |
||
2611 | * @param bool $recursive |
||
2612 | * |
||
2613 | * @return bool |
||
2614 | */ |
||
2615 | 9 | public function isSequential(bool $recursive = false): bool |
|
2632 | |||
2633 | /** |
||
2634 | * @return array |
||
2635 | * |
||
2636 | * @psalm-return array<TKey,T> |
||
2637 | */ |
||
2638 | public function jsonSerialize(): array |
||
2642 | |||
2643 | /** |
||
2644 | * Gets the key/index of the element at the current internal iterator position. |
||
2645 | * |
||
2646 | * @return int|string|null |
||
2647 | */ |
||
2648 | public function key() |
||
2652 | |||
2653 | /** |
||
2654 | * Checks if the given key exists in the provided array. |
||
2655 | * |
||
2656 | * INFO: This method only use "array_key_exists()" if you want to use "dot"-notation, |
||
2657 | * then you need to use "Arrayy->offsetExists()". |
||
2658 | * |
||
2659 | * @param int|string $key the key to look for |
||
2660 | * |
||
2661 | * @return bool |
||
2662 | */ |
||
2663 | 127 | public function keyExists($key): bool |
|
2667 | |||
2668 | /** |
||
2669 | * Get all keys from the current array. |
||
2670 | * |
||
2671 | * @param bool $recursive [optional] <p> |
||
2672 | * Get all keys, also from all sub-arrays from an multi-dimensional array. |
||
2673 | * </p> |
||
2674 | * @param mixed|null $search_values [optional] <p> |
||
2675 | * If specified, then only keys containing these values are returned. |
||
2676 | * </p> |
||
2677 | * @param bool $strict [optional] <p> |
||
2678 | * Determines if strict comparison (===) should be used during the search. |
||
2679 | * </p> |
||
2680 | * |
||
2681 | * @return static |
||
2682 | * <p>(Immutable) An array of all the keys in input.</p> |
||
2683 | */ |
||
2684 | 29 | public function keys( |
|
2754 | |||
2755 | /** |
||
2756 | * Sort an array by key in reverse order. |
||
2757 | * |
||
2758 | * @param int $sort_flags [optional] <p> |
||
2759 | * You may modify the behavior of the sort using the optional |
||
2760 | * parameter sort_flags, for details |
||
2761 | * see sort. |
||
2762 | * </p> |
||
2763 | * |
||
2764 | * @return static |
||
2765 | * <p>(Mutable) Return this Arrayy object.</p> |
||
2766 | */ |
||
2767 | 4 | public function krsort(int $sort_flags = 0): self |
|
2775 | |||
2776 | /** |
||
2777 | * Get the last value from the current array. |
||
2778 | * |
||
2779 | * @return mixed |
||
2780 | * <p>Return null if there wasn't a element.</p> |
||
2781 | */ |
||
2782 | 17 | public function last() |
|
2791 | |||
2792 | /** |
||
2793 | * Get the last key from the current array. |
||
2794 | * |
||
2795 | * @return mixed |
||
2796 | * <p>Return null if there wasn't a element.</p> |
||
2797 | */ |
||
2798 | 21 | public function lastKey() |
|
2804 | |||
2805 | /** |
||
2806 | * Get the last value(s) from the current array. |
||
2807 | * |
||
2808 | * @param int|null $number |
||
2809 | * |
||
2810 | * @return static |
||
2811 | * <p>(Immutable)</p> |
||
2812 | */ |
||
2813 | 13 | public function lastsImmutable(int $number = null): self |
|
2844 | |||
2845 | /** |
||
2846 | * Get the last value(s) from the current array. |
||
2847 | * |
||
2848 | * @param int|null $number |
||
2849 | * |
||
2850 | * @return static |
||
2851 | * <p>(Mutable)</p> |
||
2852 | */ |
||
2853 | 13 | public function lastsMutable(int $number = null): self |
|
2882 | |||
2883 | /** |
||
2884 | * Count the values from the current array. |
||
2885 | * |
||
2886 | * alias: for "Arrayy->count()" |
||
2887 | * |
||
2888 | * @param int $mode |
||
2889 | * |
||
2890 | * @return int |
||
2891 | * |
||
2892 | * @see Arrayy::count() |
||
2893 | */ |
||
2894 | 20 | public function length(int $mode = \COUNT_NORMAL): int |
|
2898 | |||
2899 | /** |
||
2900 | * Apply the given function to the every element of the array, |
||
2901 | * collecting the results. |
||
2902 | * |
||
2903 | * @param callable $callable |
||
2904 | * @param bool $useKeyAsSecondParameter |
||
2905 | * @param mixed ...$arguments |
||
2906 | * |
||
2907 | * @return static |
||
2908 | * <p>(Immutable) Arrayy object with modified elements.</p> |
||
2909 | */ |
||
2910 | 5 | public function map(callable $callable, bool $useKeyAsSecondParameter = false, ...$arguments) |
|
2937 | |||
2938 | /** |
||
2939 | * Check if all items in current array match a truth test. |
||
2940 | * |
||
2941 | * @param \Closure $closure |
||
2942 | * |
||
2943 | * @return bool |
||
2944 | */ |
||
2945 | 15 | View Code Duplication | public function matches(\Closure $closure): bool |
2961 | |||
2962 | /** |
||
2963 | * Check if any item in the current array matches a truth test. |
||
2964 | * |
||
2965 | * @param \Closure $closure |
||
2966 | * |
||
2967 | * @return bool |
||
2968 | */ |
||
2969 | 14 | View Code Duplication | public function matchesAny(\Closure $closure): bool |
2985 | |||
2986 | /** |
||
2987 | * Get the max value from an array. |
||
2988 | * |
||
2989 | * @return mixed |
||
2990 | */ |
||
2991 | 10 | View Code Duplication | public function max() |
3010 | |||
3011 | /** |
||
3012 | * Merge the new $array into the current array. |
||
3013 | * |
||
3014 | * - keep key,value from the current array, also if the index is in the new $array |
||
3015 | * |
||
3016 | * @param array $array |
||
3017 | * @param bool $recursive |
||
3018 | * |
||
3019 | * @return static |
||
3020 | * <p>(Immutable)</p> |
||
3021 | * |
||
3022 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3023 | */ |
||
3024 | 25 | View Code Duplication | public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self |
3038 | |||
3039 | /** |
||
3040 | * Merge the new $array into the current array. |
||
3041 | * |
||
3042 | * - replace duplicate assoc-keys from the current array with the key,values from the new $array |
||
3043 | * - create new indexes |
||
3044 | * |
||
3045 | * @param array $array |
||
3046 | * @param bool $recursive |
||
3047 | * |
||
3048 | * @return static |
||
3049 | * <p>(Immutable)</p> |
||
3050 | * |
||
3051 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3052 | */ |
||
3053 | 16 | View Code Duplication | public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self |
3067 | |||
3068 | /** |
||
3069 | * Merge the the current array into the $array. |
||
3070 | * |
||
3071 | * - use key,value from the new $array, also if the index is in the current array |
||
3072 | * |
||
3073 | * @param array $array |
||
3074 | * @param bool $recursive |
||
3075 | * |
||
3076 | * @return static |
||
3077 | * <p>(Immutable)</p> |
||
3078 | * |
||
3079 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3080 | */ |
||
3081 | 16 | View Code Duplication | public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self |
3095 | |||
3096 | /** |
||
3097 | * Merge the current array into the new $array. |
||
3098 | * |
||
3099 | * - replace duplicate assoc-keys from new $array with the key,values from the current array |
||
3100 | * - create new indexes |
||
3101 | * |
||
3102 | * @param array $array |
||
3103 | * @param bool $recursive |
||
3104 | * |
||
3105 | * @return static |
||
3106 | * <p>(Immutable)</p> |
||
3107 | * |
||
3108 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3109 | */ |
||
3110 | 17 | View Code Duplication | public function mergePrependNewIndex(array $array = [], bool $recursive = false): self |
3124 | |||
3125 | /** |
||
3126 | * @return ArrayyMeta|static |
||
3127 | */ |
||
3128 | 15 | public static function meta() |
|
3132 | |||
3133 | /** |
||
3134 | * Get the min value from an array. |
||
3135 | * |
||
3136 | * @return mixed |
||
3137 | */ |
||
3138 | 10 | View Code Duplication | public function min() |
3157 | |||
3158 | /** |
||
3159 | * Get the most used value from the array. |
||
3160 | * |
||
3161 | * @return mixed |
||
3162 | * <p>Return null if there wasn't a element.</p> |
||
3163 | */ |
||
3164 | 3 | public function mostUsedValue() |
|
3168 | |||
3169 | /** |
||
3170 | * Get the most used value from the array. |
||
3171 | * |
||
3172 | * @param int|null $number <p>How many values you will take?</p> |
||
3173 | * |
||
3174 | * @return static |
||
3175 | * <p>(Immutable)</p> |
||
3176 | */ |
||
3177 | 3 | public function mostUsedValues(int $number = null): self |
|
3181 | |||
3182 | /** |
||
3183 | * Move an array element to a new index. |
||
3184 | * |
||
3185 | * cherry-picked from: http://stackoverflow.com/questions/12624153/move-an-array-element-to-a-new-index-in-php |
||
3186 | * |
||
3187 | * @param int|string $from |
||
3188 | * @param int $to |
||
3189 | * |
||
3190 | * @return static |
||
3191 | * <p>(Immutable)</p> |
||
3192 | */ |
||
3193 | 1 | public function moveElement($from, $to): self |
|
3226 | |||
3227 | /** |
||
3228 | * Move an array element to the first place. |
||
3229 | * |
||
3230 | * INFO: Instead of "Arrayy->moveElement()" this method will NOT |
||
3231 | * loss the keys of an indexed array. |
||
3232 | * |
||
3233 | * @param int|string $key |
||
3234 | * |
||
3235 | * @return static |
||
3236 | * <p>(Immutable)</p> |
||
3237 | */ |
||
3238 | 1 | View Code Duplication | public function moveElementToFirstPlace($key): self |
3254 | |||
3255 | /** |
||
3256 | * Move an array element to the last place. |
||
3257 | * |
||
3258 | * INFO: Instead of "Arrayy->moveElement()" this method will NOT |
||
3259 | * loss the keys of an indexed array. |
||
3260 | * |
||
3261 | * @param int|string $key |
||
3262 | * |
||
3263 | * @return static |
||
3264 | * <p>(Immutable)</p> |
||
3265 | */ |
||
3266 | 1 | View Code Duplication | public function moveElementToLastPlace($key): self |
3282 | |||
3283 | /** |
||
3284 | * Moves the internal iterator position to the next element and returns this element. |
||
3285 | * |
||
3286 | * @return mixed |
||
3287 | */ |
||
3288 | public function next() |
||
3292 | |||
3293 | /** |
||
3294 | * Get the next nth keys and values from the array. |
||
3295 | * |
||
3296 | * @param int $step |
||
3297 | * @param int $offset |
||
3298 | * |
||
3299 | * @return static |
||
3300 | */ |
||
3301 | 1 | public function nth(int $step, int $offset = 0): self |
|
3320 | |||
3321 | /** |
||
3322 | * Get a subset of the items from the given array. |
||
3323 | * |
||
3324 | * @param mixed[] $keys |
||
3325 | * |
||
3326 | * @return static |
||
3327 | * <p>(Immutable)</p> |
||
3328 | */ |
||
3329 | 1 | public function only(array $keys): self |
|
3339 | |||
3340 | /** |
||
3341 | * Pad array to the specified size with a given value. |
||
3342 | * |
||
3343 | * @param int $size <p>Size of the result array.</p> |
||
3344 | * @param mixed $value <p>Empty value by default.</p> |
||
3345 | * |
||
3346 | * @return static |
||
3347 | * <p>(Immutable) Arrayy object padded to $size with $value.</p> |
||
3348 | */ |
||
3349 | 5 | public function pad(int $size, $value): self |
|
3357 | |||
3358 | /** |
||
3359 | * Partitions this array in two array according to a predicate. |
||
3360 | * Keys are preserved in the resulting array. |
||
3361 | * |
||
3362 | * @param \Closure $closure |
||
3363 | * <p>The predicate on which to partition.</p> |
||
3364 | * |
||
3365 | * @return array<int, static> |
||
3366 | * <p>An array with two elements. The first element contains the array |
||
3367 | * of elements where the predicate returned TRUE, the second element |
||
3368 | * contains the array of elements where the predicate returned FALSE.</p> |
||
3369 | */ |
||
3370 | 1 | public function partition(\Closure $closure): array |
|
3386 | |||
3387 | /** |
||
3388 | * Pop a specified value off the end of the current array. |
||
3389 | * |
||
3390 | * @return mixed |
||
3391 | * <p>(Mutable) The popped element from the current array.</p> |
||
3392 | */ |
||
3393 | 5 | public function pop() |
|
3399 | |||
3400 | /** |
||
3401 | * Prepend a (key) + value to the current array. |
||
3402 | * |
||
3403 | * @param mixed $value |
||
3404 | * @param mixed $key |
||
3405 | * |
||
3406 | * @return static |
||
3407 | * <p>(Mutable) Return this Arrayy object, with the prepended value.</p> |
||
3408 | */ |
||
3409 | 11 | public function prepend($value, $key = null) |
|
3425 | |||
3426 | /** |
||
3427 | * Add a suffix to each key. |
||
3428 | * |
||
3429 | * @param mixed $suffix |
||
3430 | * |
||
3431 | * @return static |
||
3432 | * <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> |
||
3433 | */ |
||
3434 | 10 | View Code Duplication | public function prependToEachKey($suffix): self |
3460 | |||
3461 | /** |
||
3462 | * Add a suffix to each value. |
||
3463 | * |
||
3464 | * @param mixed $suffix |
||
3465 | * |
||
3466 | * @return static |
||
3467 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
||
3468 | */ |
||
3469 | 10 | View Code Duplication | public function prependToEachValue($suffix): self |
3497 | |||
3498 | /** |
||
3499 | * Return the value of a given key and |
||
3500 | * delete the key. |
||
3501 | * |
||
3502 | * @param int|int[]|string|string[]|null $keyOrKeys |
||
3503 | * @param mixed $fallback |
||
3504 | * |
||
3505 | * @return mixed |
||
3506 | */ |
||
3507 | 1 | public function pull($keyOrKeys = null, $fallback = null) |
|
3529 | |||
3530 | /** |
||
3531 | * Push one or more values onto the end of array at once. |
||
3532 | * |
||
3533 | * @param array ...$args |
||
3534 | * |
||
3535 | * @return static |
||
3536 | * <p>(Mutable) Return this Arrayy object, with pushed elements to the end of array.</p> |
||
3537 | * |
||
3538 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
3539 | * |
||
3540 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$args |
||
3541 | */ |
||
3542 | 5 | public function push(...$args) |
|
3560 | |||
3561 | /** |
||
3562 | * Get a random value from the current array. |
||
3563 | * |
||
3564 | * @param int|null $number <p>How many values you will take?</p> |
||
3565 | * |
||
3566 | * @return static |
||
3567 | * <p>(Immutable)</p> |
||
3568 | */ |
||
3569 | 19 | public function randomImmutable(int $number = null): self |
|
3602 | |||
3603 | /** |
||
3604 | * Pick a random key/index from the keys of this array. |
||
3605 | * |
||
3606 | * @throws \RangeException If array is empty |
||
3607 | * |
||
3608 | * @return mixed |
||
3609 | * <p>Get a key/index or null if there wasn't a key/index.</p> |
||
3610 | */ |
||
3611 | 4 | public function randomKey() |
|
3621 | |||
3622 | /** |
||
3623 | * Pick a given number of random keys/indexes out of this array. |
||
3624 | * |
||
3625 | * @param int $number <p>The number of keys/indexes (should be <= \count($this->array))</p> |
||
3626 | * |
||
3627 | * @throws \RangeException If array is empty |
||
3628 | * |
||
3629 | * @return static |
||
3630 | * <p>(Immutable)</p> |
||
3631 | */ |
||
3632 | 13 | public function randomKeys(int $number): self |
|
3660 | |||
3661 | /** |
||
3662 | * Get a random value from the current array. |
||
3663 | * |
||
3664 | * @param int|null $number <p>How many values you will take?</p> |
||
3665 | * |
||
3666 | * @return static |
||
3667 | * <p>(Mutable)</p> |
||
3668 | */ |
||
3669 | 17 | public function randomMutable(int $number = null): self |
|
3694 | |||
3695 | /** |
||
3696 | * Pick a random value from the values of this array. |
||
3697 | * |
||
3698 | * @return mixed |
||
3699 | * <p>Get a random value or null if there wasn't a value.</p> |
||
3700 | */ |
||
3701 | 4 | public function randomValue() |
|
3711 | |||
3712 | /** |
||
3713 | * Pick a given number of random values out of this array. |
||
3714 | * |
||
3715 | * @param int $number |
||
3716 | * |
||
3717 | * @return static |
||
3718 | * <p>(Mutable)</p> |
||
3719 | */ |
||
3720 | 7 | public function randomValues(int $number): self |
|
3724 | |||
3725 | /** |
||
3726 | * Get a random value from an array, with the ability to skew the results. |
||
3727 | * |
||
3728 | * Example: randomWeighted(['foo' => 1, 'bar' => 2]) has a 66% chance of returning bar. |
||
3729 | * |
||
3730 | * @param array $array |
||
3731 | * @param int|null $number <p>How many values you will take?</p> |
||
3732 | * |
||
3733 | * @return static |
||
3734 | * <p>(Immutable)</p> |
||
3735 | * |
||
3736 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
3737 | */ |
||
3738 | 9 | public function randomWeighted(array $array, int $number = null): self |
|
3753 | |||
3754 | /** |
||
3755 | * Reduce the current array via callable e.g. anonymous-function. |
||
3756 | * |
||
3757 | * @param callable $callable |
||
3758 | * @param mixed $init |
||
3759 | * |
||
3760 | * @return static |
||
3761 | * <p>(Immutable)</p> |
||
3762 | */ |
||
3763 | 18 | public function reduce($callable, $init = []): self |
|
3793 | |||
3794 | /** |
||
3795 | * @param bool $unique |
||
3796 | * |
||
3797 | * @return static |
||
3798 | * <p>(Immutable)</p> |
||
3799 | */ |
||
3800 | 14 | public function reduce_dimension(bool $unique = true): self |
|
3819 | |||
3820 | /** |
||
3821 | * Create a numerically re-indexed Arrayy object. |
||
3822 | * |
||
3823 | * @return static |
||
3824 | * <p>(Mutable) Return this Arrayy object, with re-indexed array-elements.</p> |
||
3825 | */ |
||
3826 | 9 | public function reindex(): self |
|
3834 | |||
3835 | /** |
||
3836 | * Return all items that fail the truth test. |
||
3837 | * |
||
3838 | * @param \Closure $closure |
||
3839 | * |
||
3840 | * @return static |
||
3841 | * <p>(Immutable)</p> |
||
3842 | */ |
||
3843 | 1 | View Code Duplication | public function reject(\Closure $closure): self |
3860 | |||
3861 | /** |
||
3862 | * Remove a value from the current array (optional using dot-notation). |
||
3863 | * |
||
3864 | * @param mixed $key |
||
3865 | * |
||
3866 | * @return static |
||
3867 | * <p>(Mutable)</p> |
||
3868 | */ |
||
3869 | 18 | public function remove($key) |
|
3892 | |||
3893 | /** |
||
3894 | * alias: for "Arrayy->removeValue()" |
||
3895 | * |
||
3896 | * @param mixed $element |
||
3897 | * |
||
3898 | * @return static |
||
3899 | */ |
||
3900 | 8 | public function removeElement($element) |
|
3904 | |||
3905 | /** |
||
3906 | * Remove the first value from the current array. |
||
3907 | * |
||
3908 | * @return static |
||
3909 | * <p>(Immutable)</p> |
||
3910 | */ |
||
3911 | 7 | View Code Duplication | public function removeFirst(): self |
3923 | |||
3924 | /** |
||
3925 | * Remove the last value from the current array. |
||
3926 | * |
||
3927 | * @return static |
||
3928 | * <p>(Immutable)</p> |
||
3929 | */ |
||
3930 | 7 | View Code Duplication | public function removeLast(): self |
3942 | |||
3943 | /** |
||
3944 | * Removes a particular value from an array (numeric or associative). |
||
3945 | * |
||
3946 | * @param mixed $value |
||
3947 | * |
||
3948 | * @return static |
||
3949 | * <p>(Immutable)</p> |
||
3950 | */ |
||
3951 | 8 | public function removeValue($value): self |
|
3974 | |||
3975 | /** |
||
3976 | * Generate array of repeated arrays. |
||
3977 | * |
||
3978 | * @param int $times <p>How many times has to be repeated.</p> |
||
3979 | * |
||
3980 | * @return static |
||
3981 | * <p>(Immutable)</p> |
||
3982 | */ |
||
3983 | 1 | public function repeat($times): self |
|
3995 | |||
3996 | /** |
||
3997 | * Replace a key with a new key/value pair. |
||
3998 | * |
||
3999 | * @param mixed $replace |
||
4000 | * @param mixed $key |
||
4001 | * @param mixed $value |
||
4002 | * |
||
4003 | * @return static |
||
4004 | * <p>(Immutable)</p> |
||
4005 | */ |
||
4006 | 2 | public function replace($replace, $key, $value): self |
|
4013 | |||
4014 | /** |
||
4015 | * Create an array using the current array as values and the other array as keys. |
||
4016 | * |
||
4017 | * @param array $keys <p>An array of keys.</p> |
||
4018 | * |
||
4019 | * @return static |
||
4020 | * <p>(Immutable) Arrayy object with keys from the other array.</p> |
||
4021 | * |
||
4022 | * @psalm-param array<mixed,mixed>|array<mixed,TKey> $keys |
||
4023 | */ |
||
4024 | 2 | public function replaceAllKeys(array $keys): self |
|
4032 | |||
4033 | /** |
||
4034 | * Create an array using the current array as keys and the other array as values. |
||
4035 | * |
||
4036 | * @param array $array <p>An array o values.</p> |
||
4037 | * |
||
4038 | * @return static |
||
4039 | * <p>(Immutable) Arrayy object with values from the other array.</p> |
||
4040 | * |
||
4041 | * @psalm-param array<mixed,T> $array |
||
4042 | */ |
||
4043 | 2 | public function replaceAllValues(array $array): self |
|
4051 | |||
4052 | /** |
||
4053 | * Replace the keys in an array with another set. |
||
4054 | * |
||
4055 | * @param array $keys <p>An array of keys matching the array's size</p> |
||
4056 | * |
||
4057 | * @return static |
||
4058 | * <p>(Immutable)</p> |
||
4059 | * |
||
4060 | * @psalm-param array<mixed,mixed>|array<mixed,TKey> $keys |
||
4061 | */ |
||
4062 | 1 | public function replaceKeys(array $keys): self |
|
4073 | |||
4074 | /** |
||
4075 | * Replace the first matched value in an array. |
||
4076 | * |
||
4077 | * @param mixed $search <p>The value to replace.</p> |
||
4078 | * @param mixed $replacement <p>The value to replace.</p> |
||
4079 | * |
||
4080 | * @return static |
||
4081 | * <p>(Immutable)</p> |
||
4082 | */ |
||
4083 | 3 | public function replaceOneValue($search, $replacement = ''): self |
|
4098 | |||
4099 | /** |
||
4100 | * Replace values in the current array. |
||
4101 | * |
||
4102 | * @param mixed $search <p>The value to replace.</p> |
||
4103 | * @param mixed $replacement <p>What to replace it with.</p> |
||
4104 | * |
||
4105 | * @return static |
||
4106 | * <p>(Immutable)</p> |
||
4107 | */ |
||
4108 | 1 | public function replaceValues($search, $replacement = ''): self |
|
4116 | |||
4117 | /** |
||
4118 | * Get the last elements from index $from until the end of this array. |
||
4119 | * |
||
4120 | * @param int $from |
||
4121 | * |
||
4122 | * @return static |
||
4123 | * <p>(Immutable)</p> |
||
4124 | */ |
||
4125 | 15 | View Code Duplication | public function rest(int $from = 1): self |
4135 | |||
4136 | /** |
||
4137 | * Return the array in the reverse order. |
||
4138 | * |
||
4139 | * @return static |
||
4140 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4141 | */ |
||
4142 | 9 | public function reverse(): self |
|
4150 | |||
4151 | /** |
||
4152 | * Sort an array in reverse order. |
||
4153 | * |
||
4154 | * @param int $sort_flags [optional] <p> |
||
4155 | * You may modify the behavior of the sort using the optional |
||
4156 | * parameter sort_flags, for details |
||
4157 | * see sort. |
||
4158 | * </p> |
||
4159 | * |
||
4160 | * @return static |
||
4161 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4162 | */ |
||
4163 | 4 | public function rsort(int $sort_flags = 0): self |
|
4171 | |||
4172 | /** |
||
4173 | * Search for the first index of the current array via $value. |
||
4174 | * |
||
4175 | * @param mixed $value |
||
4176 | * |
||
4177 | * @return false|float|int|string |
||
4178 | * <p>Will return <b>FALSE</b> if the value can't be found.</p> |
||
4179 | */ |
||
4180 | 21 | public function searchIndex($value) |
|
4190 | |||
4191 | /** |
||
4192 | * Search for the value of the current array via $index. |
||
4193 | * |
||
4194 | * @param mixed $index |
||
4195 | * |
||
4196 | * @return static |
||
4197 | * <p>(Immutable) Will return a empty Arrayy if the value wasn't found.</p> |
||
4198 | */ |
||
4199 | 9 | public function searchValue($index): self |
|
4229 | |||
4230 | /** |
||
4231 | * Set a value for the current array (optional using dot-notation). |
||
4232 | * |
||
4233 | * @param string $key <p>The key to set.</p> |
||
4234 | * @param mixed $value <p>Its value.</p> |
||
4235 | * |
||
4236 | * @return static |
||
4237 | * <p>(Mutable)</p> |
||
4238 | */ |
||
4239 | 18 | public function set($key, $value): self |
|
4247 | |||
4248 | /** |
||
4249 | * Get a value from a array and set it if it was not. |
||
4250 | * |
||
4251 | * WARNING: this method only set the value, if the $key is not already set |
||
4252 | * |
||
4253 | * @param mixed $key <p>The key</p> |
||
4254 | * @param mixed $fallback <p>The default value to set if it isn't.</p> |
||
4255 | * |
||
4256 | * @return mixed |
||
4257 | * <p>(Mutable)</p> |
||
4258 | */ |
||
4259 | 11 | public function setAndGet($key, $fallback = null) |
|
4270 | |||
4271 | /** |
||
4272 | * Shifts a specified value off the beginning of array. |
||
4273 | * |
||
4274 | * @return mixed |
||
4275 | * <p>(Mutable) A shifted element from the current array.</p> |
||
4276 | */ |
||
4277 | 5 | public function shift() |
|
4283 | |||
4284 | /** |
||
4285 | * Shuffle the current array. |
||
4286 | * |
||
4287 | * @param bool $secure <p>using a CSPRNG | @link https://paragonie.com/b/JvICXzh_jhLyt4y3</p> |
||
4288 | * @param array $array [optional] |
||
4289 | * |
||
4290 | * @return static |
||
4291 | * <p>(Immutable)</p> |
||
4292 | * |
||
4293 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
4294 | */ |
||
4295 | 2 | public function shuffle(bool $secure = false, array $array = null): self |
|
4338 | |||
4339 | /** |
||
4340 | * Count the values from the current array. |
||
4341 | * |
||
4342 | * alias: for "Arrayy->count()" |
||
4343 | * |
||
4344 | * @param int $mode |
||
4345 | * |
||
4346 | * @return int |
||
4347 | */ |
||
4348 | 20 | public function size(int $mode = \COUNT_NORMAL): int |
|
4352 | |||
4353 | /** |
||
4354 | * Checks whether array has exactly $size items. |
||
4355 | * |
||
4356 | * @param int $size |
||
4357 | * |
||
4358 | * @return bool |
||
4359 | */ |
||
4360 | 1 | View Code Duplication | public function sizeIs(int $size): bool |
4374 | |||
4375 | /** |
||
4376 | * Checks whether array has between $fromSize to $toSize items. $toSize can be |
||
4377 | * smaller than $fromSize. |
||
4378 | * |
||
4379 | * @param int $fromSize |
||
4380 | * @param int $toSize |
||
4381 | * |
||
4382 | * @return bool |
||
4383 | */ |
||
4384 | 1 | public function sizeIsBetween(int $fromSize, int $toSize): bool |
|
4404 | |||
4405 | /** |
||
4406 | * Checks whether array has more than $size items. |
||
4407 | * |
||
4408 | * @param int $size |
||
4409 | * |
||
4410 | * @return bool |
||
4411 | */ |
||
4412 | 1 | View Code Duplication | public function sizeIsGreaterThan(int $size): bool |
4426 | |||
4427 | /** |
||
4428 | * Checks whether array has less than $size items. |
||
4429 | * |
||
4430 | * @param int $size |
||
4431 | * |
||
4432 | * @return bool |
||
4433 | */ |
||
4434 | 1 | View Code Duplication | public function sizeIsLessThan(int $size): bool |
4448 | |||
4449 | /** |
||
4450 | * Counts all elements in an array, or something in an object. |
||
4451 | * |
||
4452 | * <p> |
||
4453 | * For objects, if you have SPL installed, you can hook into count() by implementing interface {@see Countable}. |
||
4454 | * The interface has exactly one method, {@see Countable::count()}, which returns the return value for the count() |
||
4455 | * function. Please see the {@see Array} section of the manual for a detailed explanation of how arrays are |
||
4456 | * implemented and used in PHP. |
||
4457 | * </p> |
||
4458 | * |
||
4459 | * @return int |
||
4460 | * <p> |
||
4461 | * The number of elements in var, which is |
||
4462 | * typically an array, since anything else will have one |
||
4463 | * element. |
||
4464 | * </p> |
||
4465 | * <p> |
||
4466 | * If var is not an array or an object with |
||
4467 | * implemented Countable interface, |
||
4468 | * 1 will be returned. |
||
4469 | * There is one exception, if var is &null;, |
||
4470 | * 0 will be returned. |
||
4471 | * </p> |
||
4472 | * <p> |
||
4473 | * Caution: count may return 0 for a variable that isn't set, |
||
4474 | * but it may also return 0 for a variable that has been initialized with an |
||
4475 | * empty array. Use isset to test if a variable is set. |
||
4476 | * </p> |
||
4477 | */ |
||
4478 | 10 | public function sizeRecursive(): int |
|
4482 | |||
4483 | /** |
||
4484 | * Extract a slice of the array. |
||
4485 | * |
||
4486 | * @param int $offset <p>Slice begin index.</p> |
||
4487 | * @param int|null $length <p>Length of the slice.</p> |
||
4488 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
4489 | * |
||
4490 | * @return static |
||
4491 | * <p>A slice of the original array with length $length.</p> |
||
4492 | */ |
||
4493 | 5 | public function slice(int $offset, int $length = null, bool $preserveKeys = false) |
|
4506 | |||
4507 | /** |
||
4508 | * Sort the current array and optional you can keep the keys. |
||
4509 | * |
||
4510 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
4511 | * @param int $strategy <p>sort_flags => use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
4512 | * <strong>SORT_NATURAL</strong></p> |
||
4513 | * @param bool $keepKeys |
||
4514 | * |
||
4515 | * @return static |
||
4516 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4517 | */ |
||
4518 | 20 | public function sort($direction = \SORT_ASC, int $strategy = \SORT_REGULAR, bool $keepKeys = false): self |
|
4529 | |||
4530 | /** |
||
4531 | * Sort the current array by key. |
||
4532 | * |
||
4533 | * @see http://php.net/manual/en/function.ksort.php |
||
4534 | * @see http://php.net/manual/en/function.krsort.php |
||
4535 | * |
||
4536 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
4537 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
4538 | * <strong>SORT_NATURAL</strong></p> |
||
4539 | * |
||
4540 | * @return static |
||
4541 | * <p>(Mutable) Return this Arrayy object.</p> |
||
4542 | */ |
||
4543 | 18 | public function sortKeys($direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
4551 | |||
4552 | /** |
||
4553 | * Sort the current array by value. |
||
4554 | * |
||
4555 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
4556 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
4557 | * <strong>SORT_NATURAL</strong></p> |
||
4558 | * |
||
4559 | * @return static |
||
4560 | * <p>(Mutable)</p> |
||
4561 | */ |
||
4562 | 1 | public function sortValueKeepIndex($direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
4566 | |||
4567 | /** |
||
4568 | * Sort the current array by value. |
||
4569 | * |
||
4570 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
4571 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
4572 | * <strong>SORT_NATURAL</strong></p> |
||
4573 | * |
||
4574 | * @return static |
||
4575 | * <p>(Mutable)</p> |
||
4576 | */ |
||
4577 | 1 | public function sortValueNewIndex($direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
4581 | |||
4582 | /** |
||
4583 | * Sort a array by value, by a closure or by a property. |
||
4584 | * |
||
4585 | * - If the sorter is null, the array is sorted naturally. |
||
4586 | * - Associative (string) keys will be maintained, but numeric keys will be re-indexed. |
||
4587 | * |
||
4588 | * @param callable|string|null $sorter |
||
4589 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or |
||
4590 | * <strong>SORT_DESC</strong></p> |
||
4591 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
4592 | * <strong>SORT_NATURAL</strong></p> |
||
4593 | * |
||
4594 | * @return static |
||
4595 | * <p>(Immutable)</p> |
||
4596 | */ |
||
4597 | 1 | public function sorter($sorter = null, $direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
4634 | |||
4635 | /** |
||
4636 | * @param int $offset |
||
4637 | * @param int|null $length |
||
4638 | * @param array $replacement |
||
4639 | * |
||
4640 | * @return static |
||
4641 | * <p>(Immutable)</p> |
||
4642 | * |
||
4643 | * @psalm-param array<mixed,mixed>|array<mixed,T> $replacement |
||
4644 | */ |
||
4645 | 1 | public function splice(int $offset, int $length = null, $replacement = []): self |
|
4662 | |||
4663 | /** |
||
4664 | * Split an array in the given amount of pieces. |
||
4665 | * |
||
4666 | * @param int $numberOfPieces |
||
4667 | * @param bool $keepKeys |
||
4668 | * |
||
4669 | * @return static |
||
4670 | * <p>(Immutable)</p> |
||
4671 | */ |
||
4672 | 1 | public function split(int $numberOfPieces = 2, bool $keepKeys = false): self |
|
4691 | |||
4692 | /** |
||
4693 | * Stripe all empty items. |
||
4694 | * |
||
4695 | * @return static |
||
4696 | * <p>(Immutable)</p> |
||
4697 | */ |
||
4698 | 1 | public function stripEmpty(): self |
|
4710 | |||
4711 | /** |
||
4712 | * Swap two values between positions by key. |
||
4713 | * |
||
4714 | * @param int|string $swapA <p>a key in the array</p> |
||
4715 | * @param int|string $swapB <p>a key in the array</p> |
||
4716 | * |
||
4717 | * @return static |
||
4718 | * <p>(Immutable)</p> |
||
4719 | */ |
||
4720 | 1 | public function swap($swapA, $swapB): self |
|
4732 | |||
4733 | /** |
||
4734 | * alias: for "Arrayy->getArray()" |
||
4735 | * |
||
4736 | * @param bool $convertAllArrayyElements |
||
4737 | * |
||
4738 | * @return array |
||
4739 | * |
||
4740 | * @see Arrayy::getArray() |
||
4741 | * |
||
4742 | * @psalm-return array<array-key,mixed> |
||
4743 | */ |
||
4744 | 241 | public function toArray(bool $convertAllArrayyElements = false): array |
|
4748 | |||
4749 | /** |
||
4750 | * Convert the current array to JSON. |
||
4751 | * |
||
4752 | * @param int $options [optional] <p>e.g. JSON_PRETTY_PRINT</p> |
||
4753 | * @param int $depth [optional] <p>Set the maximum depth. Must be greater than zero.</p> |
||
4754 | * |
||
4755 | * @return string |
||
4756 | */ |
||
4757 | 7 | public function toJson(int $options = 0, int $depth = 512): string |
|
4766 | |||
4767 | /** |
||
4768 | * @param string[]|null $items |
||
4769 | * @param string[] $helper |
||
4770 | * |
||
4771 | * @return static |
||
4772 | */ |
||
4773 | 1 | public function toPermutation(array $items = null, array $helper = []): self |
|
4807 | |||
4808 | /** |
||
4809 | * Implodes array to a string with specified separator. |
||
4810 | * |
||
4811 | * @param string $separator [optional] <p>The element's separator.</p> |
||
4812 | * |
||
4813 | * @return string |
||
4814 | * <p>The string representation of array, separated by ",".</p> |
||
4815 | */ |
||
4816 | 19 | public function toString(string $separator = ','): string |
|
4820 | |||
4821 | /** |
||
4822 | * Return a duplicate free copy of the current array. |
||
4823 | * |
||
4824 | * @return static |
||
4825 | * <p>(Mutable)</p> |
||
4826 | */ |
||
4827 | 13 | public function unique(): self |
|
4845 | |||
4846 | /** |
||
4847 | * Return a duplicate free copy of the current array. (with the old keys) |
||
4848 | * |
||
4849 | * @return static |
||
4850 | * <p>(Mutable)</p> |
||
4851 | */ |
||
4852 | 11 | public function uniqueKeepIndex(): self |
|
4880 | |||
4881 | /** |
||
4882 | * alias: for "Arrayy->unique()" |
||
4883 | * |
||
4884 | * @return static |
||
4885 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
4886 | * |
||
4887 | * @see Arrayy::unique() |
||
4888 | */ |
||
4889 | 10 | public function uniqueNewIndex(): self |
|
4893 | |||
4894 | /** |
||
4895 | * Prepends one or more values to the beginning of array at once. |
||
4896 | * |
||
4897 | * @param array ...$args |
||
4898 | * |
||
4899 | * @return static |
||
4900 | * <p>(Mutable) Return this Arrayy object, with prepended elements to the beginning of array.</p> |
||
4901 | * |
||
4902 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$args |
||
4903 | */ |
||
4904 | 4 | public function unshift(...$args): self |
|
4912 | |||
4913 | /** |
||
4914 | * Tests whether the given closure retrun something valid for all elements of this array. |
||
4915 | * |
||
4916 | * @param \Closure $closure the predicate |
||
4917 | * |
||
4918 | * @return bool |
||
4919 | * <p>TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.</p> |
||
4920 | */ |
||
4921 | 1 | View Code Duplication | public function validate(\Closure $closure): bool |
4931 | |||
4932 | /** |
||
4933 | * Get all values from a array. |
||
4934 | * |
||
4935 | * @return static |
||
4936 | * <p>(Immutable)</p> |
||
4937 | */ |
||
4938 | 2 | public function values(): self |
|
4951 | |||
4952 | /** |
||
4953 | * Apply the given function to every element in the array, discarding the results. |
||
4954 | * |
||
4955 | * @param callable $callable |
||
4956 | * @param bool $recursive <p>Whether array will be walked recursively or no</p> |
||
4957 | * |
||
4958 | * @return static |
||
4959 | * <p>(Mutable) Return this Arrayy object, with modified elements.</p> |
||
4960 | */ |
||
4961 | 12 | public function walk($callable, bool $recursive = false): self |
|
4973 | |||
4974 | /** |
||
4975 | * Returns a collection of matching items. |
||
4976 | * |
||
4977 | * @param string $keyOrPropertyOrMethod the property or method to evaluate |
||
4978 | * @param mixed $value the value to match |
||
4979 | * |
||
4980 | * @throws \InvalidArgumentException if property or method is not defined |
||
4981 | * |
||
4982 | * @return static |
||
4983 | * |
||
4984 | * @psalm-return static<T> |
||
4985 | */ |
||
4986 | 1 | public function where(string $keyOrPropertyOrMethod, $value): self |
|
4999 | |||
5000 | /** |
||
5001 | * Convert an array into a object. |
||
5002 | * |
||
5003 | * @param array $array |
||
5004 | * |
||
5005 | * @return \stdClass |
||
5006 | * |
||
5007 | * @psalm-param array<mixed,mixed> $array |
||
5008 | */ |
||
5009 | 4 | final protected static function arrayToObject(array $array = []): \stdClass |
|
5028 | |||
5029 | /** |
||
5030 | * @param array|\Generator|null $input <p> |
||
5031 | * An array containing keys to return. |
||
5032 | * </p> |
||
5033 | * @param mixed|null $search_values [optional] <p> |
||
5034 | * If specified, then only keys containing these values are returned. |
||
5035 | * </p> |
||
5036 | * @param bool $strict [optional] <p> |
||
5037 | * Determines if strict comparison (===) should be used during the |
||
5038 | * search. |
||
5039 | * </p> |
||
5040 | * |
||
5041 | * @return array |
||
5042 | * <p>an array of all the keys in input</p> |
||
5043 | * |
||
5044 | * @psalm-param array<mixed,mixed>|\Generator<TKey,T>|null $input |
||
5045 | * @psalm-return array<TKey|mixed> |
||
5046 | */ |
||
5047 | 11 | protected function array_keys_recursive( |
|
5108 | |||
5109 | /** |
||
5110 | * @param mixed $path |
||
5111 | * @param callable $callable |
||
5112 | * @param array|null $currentOffset |
||
5113 | * |
||
5114 | * @return void |
||
5115 | * |
||
5116 | * @psalm-param array<mixed,mixed>|array<TKey,T>|null $currentOffset |
||
5117 | */ |
||
5118 | 4 | protected function callAtPath($path, $callable, &$currentOffset = null) |
|
5147 | |||
5148 | /** |
||
5149 | * Extracts the value of the given property or method from the object. |
||
5150 | * |
||
5151 | * @param static $object <p>The object to extract the value from.</p> |
||
5152 | * @param string $keyOrPropertyOrMethod <p>The property or method for which the |
||
5153 | * value should be extracted.</p> |
||
5154 | * |
||
5155 | * @throws \InvalidArgumentException if the method or property is not defined |
||
5156 | * |
||
5157 | * @return mixed |
||
5158 | * <p>The value extracted from the specified property or method.</p> |
||
5159 | * |
||
5160 | * @psalm-param self<TKey,T> $object |
||
5161 | */ |
||
5162 | 2 | final protected function extractValue(self $object, string $keyOrPropertyOrMethod) |
|
5184 | |||
5185 | /** |
||
5186 | * create a fallback for array |
||
5187 | * |
||
5188 | * 1. use the current array, if it's a array |
||
5189 | * 2. fallback to empty array, if there is nothing |
||
5190 | * 3. call "getArray()" on object, if there is a "Arrayy"-object |
||
5191 | * 4. call "createFromObject()" on object, if there is a "\Traversable"-object |
||
5192 | * 5. call "__toArray()" on object, if the method exists |
||
5193 | * 6. cast a string or object with "__toString()" into an array |
||
5194 | * 7. throw a "InvalidArgumentException"-Exception |
||
5195 | * |
||
5196 | * @param mixed $data |
||
5197 | * |
||
5198 | * @throws \InvalidArgumentException |
||
5199 | * |
||
5200 | * @return array |
||
5201 | * |
||
5202 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
5203 | */ |
||
5204 | 1066 | protected function fallbackForArray(&$data): array |
|
5214 | |||
5215 | /** |
||
5216 | * @return bool |
||
5217 | * |
||
5218 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
5219 | */ |
||
5220 | 982 | protected function generatorToArray() |
|
5231 | |||
5232 | /** |
||
5233 | * Get correct PHP constant for direction. |
||
5234 | * |
||
5235 | * @param int|string $direction |
||
5236 | * |
||
5237 | * @return int |
||
5238 | */ |
||
5239 | 39 | protected function getDirection($direction): int |
|
5261 | |||
5262 | /** |
||
5263 | * @return TypeCheckPhpDoc[] |
||
5264 | * |
||
5265 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
5266 | */ |
||
5267 | 16 | protected function getPropertiesFromPhpDoc() |
|
5292 | |||
5293 | /** |
||
5294 | * @param mixed $glue |
||
5295 | * @param mixed $pieces |
||
5296 | * @param bool $useKeys |
||
5297 | * |
||
5298 | * @return string |
||
5299 | */ |
||
5300 | 36 | protected function implode_recursive($glue = '', $pieces = [], bool $useKeys = false): string |
|
5330 | |||
5331 | /** |
||
5332 | * @param mixed $needle <p> |
||
5333 | * The searched value. |
||
5334 | * </p> |
||
5335 | * <p> |
||
5336 | * If needle is a string, the comparison is done |
||
5337 | * in a case-sensitive manner. |
||
5338 | * </p> |
||
5339 | * @param array|\Generator|null $haystack <p> |
||
5340 | * The array. |
||
5341 | * </p> |
||
5342 | * @param bool $strict [optional] <p> |
||
5343 | * If the third parameter strict is set to true |
||
5344 | * then the in_array function will also check the |
||
5345 | * types of the |
||
5346 | * needle in the haystack. |
||
5347 | * </p> |
||
5348 | * |
||
5349 | * @return bool |
||
5350 | * <p>true if needle is found in the array, false otherwise</p> |
||
5351 | * |
||
5352 | * @psalm-param array<mixed,mixed>|\Generator<TKey,T>|null $haystack |
||
5353 | */ |
||
5354 | 18 | protected function in_array_recursive($needle, $haystack = null, $strict = true): bool |
|
5379 | |||
5380 | /** |
||
5381 | * @param mixed $data |
||
5382 | * |
||
5383 | * @return array|null |
||
5384 | * |
||
5385 | * @psalm-return array<mixed,mixed>|array<TKey,T>|null |
||
5386 | */ |
||
5387 | 1066 | protected function internalGetArray(&$data) |
|
5435 | |||
5436 | /** |
||
5437 | * Internal mechanics of remove method. |
||
5438 | * |
||
5439 | * @param mixed $key |
||
5440 | * |
||
5441 | * @return bool |
||
5442 | */ |
||
5443 | 18 | protected function internalRemove($key): bool |
|
5476 | |||
5477 | /** |
||
5478 | * Internal mechanic of set method. |
||
5479 | * |
||
5480 | * @param int|string|null $key |
||
5481 | * @param mixed $value |
||
5482 | * @param bool $checkProperties |
||
5483 | * |
||
5484 | * @return bool |
||
5485 | */ |
||
5486 | 938 | protected function internalSet( |
|
5532 | |||
5533 | /** |
||
5534 | * Convert a object into an array. |
||
5535 | * |
||
5536 | * @param object $object |
||
5537 | * |
||
5538 | * @return mixed |
||
5539 | */ |
||
5540 | 5 | protected static function objectToArray($object) |
|
5552 | |||
5553 | /** |
||
5554 | * @param array $data |
||
5555 | * @param bool $checkPropertiesInConstructor |
||
5556 | * |
||
5557 | * @return void |
||
5558 | * |
||
5559 | * @psalm-param array<mixed,T> $data |
||
5560 | */ |
||
5561 | 1064 | protected function setInitialValuesAndProperties(array &$data, bool $checkPropertiesInConstructor) |
|
5603 | |||
5604 | /** |
||
5605 | * sorting keys |
||
5606 | * |
||
5607 | * @param array $elements |
||
5608 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5609 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5610 | * <strong>SORT_NATURAL</strong></p> |
||
5611 | * |
||
5612 | * @return static |
||
5613 | * <p>(Mutable) Return this Arrayy object.</p> |
||
5614 | * |
||
5615 | * @psalm-param array<mixed,mixed>|array<mixed|TKey,T> $elements |
||
5616 | */ |
||
5617 | 18 | protected function sorterKeys(array &$elements, $direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
5635 | |||
5636 | /** |
||
5637 | * @param array $elements <p>Warning: used as reference</p> |
||
5638 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
5639 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
5640 | * <strong>SORT_NATURAL</strong></p> |
||
5641 | * @param bool $keepKeys |
||
5642 | * |
||
5643 | * @return static |
||
5644 | * <p>(Mutable) Return this Arrayy object.</p> |
||
5645 | * |
||
5646 | * @psalm-param array<mixed> $elements |
||
5647 | */ |
||
5648 | 20 | protected function sorting(array &$elements, $direction = \SORT_ASC, int $strategy = \SORT_REGULAR, bool $keepKeys = false): self |
|
5678 | |||
5679 | /** |
||
5680 | * @param int|string|null $key |
||
5681 | * @param mixed $value |
||
5682 | * |
||
5683 | * @return void |
||
5684 | */ |
||
5685 | 87 | private function checkType($key, $value) |
|
5703 | } |
||
5704 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.