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