Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Arrayy often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Arrayy, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 27 | class Arrayy extends \ArrayObject implements \IteratorAggregate, \ArrayAccess, \Serializable, \JsonSerializable, \Countable |
||
| 28 | { |
||
| 29 | const ARRAYY_HELPER_TYPES_FOR_ALL_PROPERTIES = '!!!!Arrayy_Helper_Types_For_All_Properties!!!!'; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var array |
||
| 33 | * |
||
| 34 | * @psalm-var array<mixed,mixed>|array<TKey,T> |
||
| 35 | */ |
||
| 36 | protected $array = []; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var \Arrayy\ArrayyRewindableGenerator|null |
||
| 40 | * |
||
| 41 | * @psalm-var \Arrayy\ArrayyRewindableGenerator<TKey,T>|null |
||
| 42 | */ |
||
| 43 | protected $generator; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @var string |
||
| 47 | * |
||
| 48 | * @psalm-var class-string<\Arrayy\ArrayyIterator> |
||
| 49 | */ |
||
| 50 | protected $iteratorClass = ArrayyIterator::class; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var string |
||
| 54 | */ |
||
| 55 | protected $pathSeparator = '.'; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var bool |
||
| 59 | */ |
||
| 60 | protected $checkPropertyTypes = false; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @var bool |
||
| 64 | */ |
||
| 65 | protected $checkForMissingPropertiesInConstructor = false; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @var bool |
||
| 69 | */ |
||
| 70 | protected $checkPropertiesMismatchInConstructor = false; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @var bool |
||
| 74 | */ |
||
| 75 | protected $checkPropertiesMismatch = true; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @var array<int|string,TypeCheckInterface>|TypeCheckArray<int|string,TypeCheckInterface>|TypeInterface |
||
| 79 | */ |
||
| 80 | protected $properties = []; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Initializes |
||
| 84 | * |
||
| 85 | * @param mixed $data <p> |
||
| 86 | * Should be an array or a generator, otherwise it will try |
||
| 87 | * to convert it into an array. |
||
| 88 | * </p> |
||
| 89 | * @param string $iteratorClass optional <p> |
||
| 90 | * You can overwrite the ArrayyIterator, but mostly you don't |
||
| 91 | * need this option. |
||
| 92 | * </p> |
||
| 93 | * @param bool $checkPropertiesInConstructor optional <p> |
||
| 94 | * You need to extend the "Arrayy"-class and you need to set |
||
| 95 | * the $checkPropertiesMismatchInConstructor class property |
||
| 96 | * to |
||
| 97 | * true, otherwise this option didn't not work anyway. |
||
| 98 | * </p> |
||
| 99 | * |
||
| 100 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
| 101 | */ |
||
| 102 | 1167 | public function __construct( |
|
| 119 | |||
| 120 | /** |
||
| 121 | * @return void |
||
| 122 | */ |
||
| 123 | 50 | public function __clone() |
|
| 133 | |||
| 134 | /** |
||
| 135 | * Call object as function. |
||
| 136 | * |
||
| 137 | * @param mixed $key |
||
| 138 | * |
||
| 139 | * @return mixed |
||
| 140 | */ |
||
| 141 | 1 | public function __invoke($key = null) |
|
| 151 | |||
| 152 | /** |
||
| 153 | * Whether or not an element exists by key. |
||
| 154 | * |
||
| 155 | * @param mixed $key |
||
| 156 | * |
||
| 157 | * @return bool |
||
| 158 | * <p>True is the key/index exists, otherwise false.</p> |
||
| 159 | */ |
||
| 160 | public function __isset($key): bool |
||
| 164 | |||
| 165 | /** |
||
| 166 | * Assigns a value to the specified element. |
||
| 167 | * |
||
| 168 | * @param mixed $key |
||
| 169 | * @param mixed $value |
||
| 170 | * |
||
| 171 | * @return void |
||
| 172 | */ |
||
| 173 | 2 | public function __set($key, $value) |
|
| 177 | |||
| 178 | /** |
||
| 179 | * magic to string |
||
| 180 | * |
||
| 181 | * @return string |
||
| 182 | */ |
||
| 183 | 15 | public function __toString(): string |
|
| 187 | |||
| 188 | /** |
||
| 189 | * Unset element by key. |
||
| 190 | * |
||
| 191 | * @param mixed $key |
||
| 192 | */ |
||
| 193 | public function __unset($key) |
||
| 197 | |||
| 198 | /** |
||
| 199 | * Get a value by key. |
||
| 200 | * |
||
| 201 | * @param mixed $key |
||
| 202 | * |
||
| 203 | * @return mixed |
||
| 204 | * <p>Get a Value from the current array.</p> |
||
| 205 | */ |
||
| 206 | 4 | public function &__get($key) |
|
| 216 | |||
| 217 | /** |
||
| 218 | * 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 | 4 | 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 | 16 | public function append($value, $key = null): self |
|
| 247 | { |
||
| 248 | 16 | $this->generatorToArray(); |
|
| 249 | |||
| 250 | 16 | if ($this->properties !== []) { |
|
| 251 | 4 | $this->checkType($key, $value); |
|
| 252 | } |
||
| 253 | |||
| 254 | 15 | if ($key !== null) { |
|
| 255 | if ( |
||
| 256 | 2 | isset($this->array[$key]) |
|
| 257 | && |
||
| 258 | 2 | \is_array($this->array[$key]) === true |
|
| 259 | ) { |
||
| 260 | $this->array[$key][] = $value; |
||
| 261 | } else { |
||
| 262 | 2 | $this->array[$key] = $value; |
|
| 263 | } |
||
| 264 | } else { |
||
| 265 | 13 | $this->array[] = $value; |
|
| 266 | } |
||
| 267 | |||
| 268 | 15 | return $this; |
|
| 269 | } |
||
| 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 | 147 | 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<mixed,mixed>|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<mixed,mixed>|array<TKey,T> |
||
| 394 | */ |
||
| 395 | 6 | 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 | 26 | 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 | 25 | 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 | 135 | public function offsetExists($offset): bool |
|
| 576 | { |
||
| 577 | 135 | $this->generatorToArray(); |
|
| 578 | |||
| 579 | 135 | if ($this->array === []) { |
|
| 580 | 7 | return false; |
|
| 581 | } |
||
| 582 | |||
| 583 | // php cast "bool"-index into "int"-index |
||
| 584 | 129 | if ((bool) $offset === $offset) { |
|
| 585 | 1 | $offset = (int) $offset; |
|
| 586 | } |
||
| 587 | |||
| 588 | /** @var int|string $offset - hint for phpstan */ |
||
| 589 | 129 | $offset = $offset; |
|
| 590 | |||
| 591 | 129 | $tmpReturn = $this->keyExists($offset); |
|
| 592 | |||
| 593 | if ( |
||
| 594 | 129 | $tmpReturn === true |
|
| 595 | || |
||
| 596 | 129 | \strpos((string) $offset, $this->pathSeparator) === false |
|
| 597 | ) { |
||
| 598 | 126 | return $tmpReturn; |
|
| 599 | } |
||
| 600 | |||
| 601 | 4 | $offsetExists = false; |
|
| 602 | |||
| 603 | /** |
||
| 604 | * https://github.com/vimeo/psalm/issues/2536 |
||
| 605 | * |
||
| 606 | * @psalm-suppress PossiblyInvalidArgument |
||
| 607 | * @psalm-suppress InvalidScalarArgument |
||
| 608 | */ |
||
| 609 | View Code Duplication | if ( |
|
| 610 | 4 | $this->pathSeparator |
|
| 611 | && |
||
| 612 | 4 | (string) $offset === $offset |
|
| 613 | && |
||
| 614 | 4 | \strpos($offset, $this->pathSeparator) !== false |
|
| 615 | ) { |
||
| 616 | 4 | $explodedPath = \explode($this->pathSeparator, (string) $offset); |
|
| 617 | 4 | if ($explodedPath !== false) { |
|
| 618 | /** @var string $lastOffset - helper for phpstan */ |
||
| 619 | 4 | $lastOffset = \array_pop($explodedPath); |
|
| 620 | 4 | $containerPath = \implode($this->pathSeparator, $explodedPath); |
|
| 621 | |||
| 622 | /** |
||
| 623 | * @psalm-suppress MissingClosureReturnType |
||
| 624 | * @psalm-suppress MissingClosureParamType |
||
| 625 | */ |
||
| 626 | 4 | $this->callAtPath( |
|
| 627 | 4 | $containerPath, |
|
| 628 | static function ($container) use ($lastOffset, &$offsetExists) { |
||
| 629 | 4 | $offsetExists = \array_key_exists($lastOffset, $container); |
|
| 630 | 4 | } |
|
| 631 | ); |
||
| 632 | } |
||
| 633 | } |
||
| 634 | |||
| 635 | 4 | return $offsetExists; |
|
| 636 | } |
||
| 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 | 104 | 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 | 20 | public function offsetSet($offset, $value) |
|
| 677 | |||
| 678 | /** |
||
| 679 | * Unset an offset. |
||
| 680 | * |
||
| 681 | * @param int|string $offset |
||
| 682 | * |
||
| 683 | * @return void |
||
| 684 | * <p>(Mutable) Return nothing.</p> |
||
| 685 | */ |
||
| 686 | 25 | public function offsetUnset($offset) |
|
| 737 | |||
| 738 | /** |
||
| 739 | * Serialize the current "Arrayy"-object. |
||
| 740 | * |
||
| 741 | * @return string |
||
| 742 | */ |
||
| 743 | 2 | public function serialize(): string |
|
| 753 | |||
| 754 | /** |
||
| 755 | * Sets the iterator classname for the current "Arrayy"-object. |
||
| 756 | * |
||
| 757 | * @param string $iteratorClass |
||
| 758 | * |
||
| 759 | * @throws \InvalidArgumentException |
||
| 760 | * |
||
| 761 | * @return void |
||
| 762 | * |
||
| 763 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
| 764 | */ |
||
| 765 | 1158 | public function setIteratorClass($iteratorClass) |
|
| 787 | |||
| 788 | /** |
||
| 789 | * Sort the entries with a user-defined comparison function and maintain key association. |
||
| 790 | * |
||
| 791 | * @param callable $function |
||
| 792 | * |
||
| 793 | * @throws \InvalidArgumentException |
||
| 794 | * |
||
| 795 | * @return $this |
||
| 796 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 797 | * |
||
| 798 | * @psalm-return static<TKey,T> |
||
| 799 | */ |
||
| 800 | 8 | View Code Duplication | public function uasort($function): self |
| 812 | |||
| 813 | /** |
||
| 814 | * Sort the entries with a user-defined comparison function and maintain key association. |
||
| 815 | * |
||
| 816 | * @param callable $function |
||
| 817 | * |
||
| 818 | * @throws \InvalidArgumentException |
||
| 819 | * |
||
| 820 | * @return $this |
||
| 821 | * <p>(Immutable) Return this Arrayy object.</p> |
||
| 822 | * |
||
| 823 | * @psalm-return static<TKey,T> |
||
| 824 | * @psalm-mutation-free |
||
| 825 | */ |
||
| 826 | 4 | public function uasortImmutable($function): self |
|
| 837 | |||
| 838 | /** |
||
| 839 | * Sort the entries by keys using a user-defined comparison function. |
||
| 840 | * |
||
| 841 | * @param callable $function |
||
| 842 | * |
||
| 843 | * @throws \InvalidArgumentException |
||
| 844 | * |
||
| 845 | * @return static |
||
| 846 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 847 | * |
||
| 848 | * @psalm-return static<TKey,T> |
||
| 849 | */ |
||
| 850 | 5 | public function uksort($function): self |
|
| 854 | |||
| 855 | /** |
||
| 856 | * Sort the entries by keys using a user-defined comparison function. |
||
| 857 | * |
||
| 858 | * @param callable $function |
||
| 859 | * |
||
| 860 | * @throws \InvalidArgumentException |
||
| 861 | * |
||
| 862 | * @return static |
||
| 863 | * <p>(Immutable) Return this Arrayy object.</p> |
||
| 864 | * |
||
| 865 | * @psalm-return static<TKey,T> |
||
| 866 | * @psalm-mutation-free |
||
| 867 | */ |
||
| 868 | 1 | public function uksortImmutable($function): self |
|
| 872 | |||
| 873 | /** |
||
| 874 | * Unserialize an string and return the instance of the "Arrayy"-class. |
||
| 875 | * |
||
| 876 | * @param string $string |
||
| 877 | * |
||
| 878 | * @return $this |
||
| 879 | * |
||
| 880 | * @psalm-return static<TKey,T> |
||
| 881 | */ |
||
| 882 | 2 | public function unserialize($string): self |
|
| 892 | |||
| 893 | /** |
||
| 894 | * Append a (key) + values to the current array. |
||
| 895 | * |
||
| 896 | * @param array $values |
||
| 897 | * @param mixed $key |
||
| 898 | * |
||
| 899 | * @return $this |
||
| 900 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
| 901 | * |
||
| 902 | * @psalm-param array<mixed,T> $values |
||
| 903 | * @psalm-param TKey|null $key |
||
| 904 | * @psalm-return static<TKey,T> |
||
| 905 | */ |
||
| 906 | 1 | public function appendArrayValues(array $values, $key = null) |
|
| 932 | |||
| 933 | /** |
||
| 934 | * Add a suffix to each key. |
||
| 935 | * |
||
| 936 | * @param mixed $prefix |
||
| 937 | * |
||
| 938 | * @return static |
||
| 939 | * <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> |
||
| 940 | * |
||
| 941 | * @psalm-return static<TKey,T> |
||
| 942 | * @psalm-mutation-free |
||
| 943 | */ |
||
| 944 | 10 | View Code Duplication | public function appendToEachKey($prefix): self |
| 963 | |||
| 964 | /** |
||
| 965 | * Add a prefix to each value. |
||
| 966 | * |
||
| 967 | * @param mixed $prefix |
||
| 968 | * |
||
| 969 | * @return static |
||
| 970 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
||
| 971 | * |
||
| 972 | * @psalm-return static<TKey,T> |
||
| 973 | * @psalm-mutation-free |
||
| 974 | */ |
||
| 975 | 10 | View Code Duplication | public function appendToEachValue($prefix): self |
| 994 | |||
| 995 | /** |
||
| 996 | * Sort an array in reverse order and maintain index association. |
||
| 997 | * |
||
| 998 | * @return $this |
||
| 999 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 1000 | * |
||
| 1001 | * @psalm-return static<TKey,T> |
||
| 1002 | */ |
||
| 1003 | 4 | public function arsort(): self |
|
| 1011 | |||
| 1012 | /** |
||
| 1013 | * Sort an array in reverse order and maintain index association. |
||
| 1014 | * |
||
| 1015 | * @return $this |
||
| 1016 | * <p>(Immutable) Return this Arrayy object.</p> |
||
| 1017 | * |
||
| 1018 | * @psalm-return static<TKey,T> |
||
| 1019 | * @psalm-mutation-free |
||
| 1020 | */ |
||
| 1021 | 10 | public function arsortImmutable(): self |
|
| 1031 | |||
| 1032 | /** |
||
| 1033 | * Iterate over the current array and execute a callback for each loop. |
||
| 1034 | * |
||
| 1035 | * @param \Closure $closure |
||
| 1036 | * |
||
| 1037 | * @return static |
||
| 1038 | * <p>(Immutable)</p> |
||
| 1039 | * |
||
| 1040 | * @psalm-return static<TKey,T> |
||
| 1041 | * @psalm-mutation-free |
||
| 1042 | */ |
||
| 1043 | 2 | public function at(\Closure $closure): self |
|
| 1057 | |||
| 1058 | /** |
||
| 1059 | * Returns the average value of the current array. |
||
| 1060 | * |
||
| 1061 | * @param int $decimals <p>The number of decimal-numbers to return.</p> |
||
| 1062 | * |
||
| 1063 | * @return float|int |
||
| 1064 | * <p>The average value.</p> |
||
| 1065 | * @psalm-mutation-free |
||
| 1066 | */ |
||
| 1067 | 10 | public function average($decimals = 0) |
|
| 1081 | |||
| 1082 | /** |
||
| 1083 | * Changes all keys in an array. |
||
| 1084 | * |
||
| 1085 | * @param int $case [optional] <p> Either <strong>CASE_UPPER</strong><br /> |
||
| 1086 | * or <strong>CASE_LOWER</strong> (default)</p> |
||
| 1087 | * |
||
| 1088 | * @return static |
||
| 1089 | * <p>(Immutable)</p> |
||
| 1090 | * |
||
| 1091 | * @psalm-return static<TKey,T> |
||
| 1092 | * @psalm-mutation-free |
||
| 1093 | */ |
||
| 1094 | 1 | public function changeKeyCase(int $case = \CASE_LOWER): self |
|
| 1121 | |||
| 1122 | /** |
||
| 1123 | * Change the path separator of the array wrapper. |
||
| 1124 | * |
||
| 1125 | * By default, the separator is: "." |
||
| 1126 | * |
||
| 1127 | * @param string $separator <p>Separator to set.</p> |
||
| 1128 | * |
||
| 1129 | * @return $this |
||
| 1130 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 1131 | * |
||
| 1132 | * @psalm-return static<TKey,T> |
||
| 1133 | */ |
||
| 1134 | 11 | public function changeSeparator($separator): self |
|
| 1140 | |||
| 1141 | /** |
||
| 1142 | * Create a chunked version of the current array. |
||
| 1143 | * |
||
| 1144 | * @param int $size <p>Size of each chunk.</p> |
||
| 1145 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
| 1146 | * |
||
| 1147 | * @return static |
||
| 1148 | * <p>(Immutable) A new array of chunks from the original array.</p> |
||
| 1149 | * |
||
| 1150 | * @psalm-return static<TKey,T> |
||
| 1151 | * @psalm-mutation-free |
||
| 1152 | */ |
||
| 1153 | 5 | public function chunk($size, $preserveKeys = false): self |
|
| 1161 | |||
| 1162 | /** |
||
| 1163 | * Clean all falsy values from the current array. |
||
| 1164 | * |
||
| 1165 | * @return static |
||
| 1166 | * <p>(Immutable)</p> |
||
| 1167 | * |
||
| 1168 | * @psalm-return static<TKey,T> |
||
| 1169 | * @psalm-mutation-free |
||
| 1170 | */ |
||
| 1171 | 8 | public function clean(): self |
|
| 1179 | |||
| 1180 | /** |
||
| 1181 | * WARNING!!! -> Clear the current full array or a $key of it. |
||
| 1182 | * |
||
| 1183 | * @param int|int[]|string|string[]|null $key |
||
| 1184 | * |
||
| 1185 | * @return $this |
||
| 1186 | * <p>(Mutable) Return this Arrayy object, with an empty array.</p> |
||
| 1187 | * |
||
| 1188 | * @psalm-return static<TKey,T> |
||
| 1189 | */ |
||
| 1190 | 10 | public function clear($key = null): self |
|
| 1209 | |||
| 1210 | /** |
||
| 1211 | * Check if an item is in the current array. |
||
| 1212 | * |
||
| 1213 | * @param float|int|string $value |
||
| 1214 | * @param bool $recursive |
||
| 1215 | * @param bool $strict |
||
| 1216 | * |
||
| 1217 | * @return bool |
||
| 1218 | * @psalm-mutation-free |
||
| 1219 | */ |
||
| 1220 | 23 | public function contains($value, bool $recursive = false, bool $strict = true): bool |
|
| 1241 | |||
| 1242 | /** |
||
| 1243 | * Check if an (case-insensitive) string is in the current array. |
||
| 1244 | * |
||
| 1245 | * @param mixed $value |
||
| 1246 | * @param bool $recursive |
||
| 1247 | * |
||
| 1248 | * @return bool |
||
| 1249 | * @psalm-mutation-free |
||
| 1250 | * |
||
| 1251 | * @psalm-suppress InvalidCast - hack for int|float|bool support |
||
| 1252 | */ |
||
| 1253 | 26 | public function containsCaseInsensitive($value, $recursive = false): bool |
|
| 1282 | |||
| 1283 | /** |
||
| 1284 | * Check if the given key/index exists in the array. |
||
| 1285 | * |
||
| 1286 | * @param int|string $key <p>key/index to search for</p> |
||
| 1287 | * |
||
| 1288 | * @return bool |
||
| 1289 | * <p>Returns true if the given key/index exists in the array, false otherwise.</p> |
||
| 1290 | * |
||
| 1291 | * @psalm-mutation-free |
||
| 1292 | */ |
||
| 1293 | 4 | public function containsKey($key): bool |
|
| 1297 | |||
| 1298 | /** |
||
| 1299 | * Check if all given needles are present in the array as key/index. |
||
| 1300 | * |
||
| 1301 | * @param array $needles <p>The keys you are searching for.</p> |
||
| 1302 | * @param bool $recursive |
||
| 1303 | * |
||
| 1304 | * @return bool |
||
| 1305 | * <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p> |
||
| 1306 | * |
||
| 1307 | * @psalm-param array<mixed,mixed>|array<TKey> $needles |
||
| 1308 | * @psalm-mutation-free |
||
| 1309 | */ |
||
| 1310 | 2 | public function containsKeys(array $needles, $recursive = false): bool |
|
| 1338 | |||
| 1339 | /** |
||
| 1340 | * Check if all given needles are present in the array as key/index. |
||
| 1341 | * |
||
| 1342 | * @param array $needles <p>The keys you are searching for.</p> |
||
| 1343 | * |
||
| 1344 | * @return bool |
||
| 1345 | * <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p> |
||
| 1346 | * |
||
| 1347 | * @psalm-param array<mixed,mixed>|array<TKey> $needles |
||
| 1348 | * @psalm-mutation-free |
||
| 1349 | */ |
||
| 1350 | 1 | public function containsKeysRecursive(array $needles): bool |
|
| 1354 | |||
| 1355 | /** |
||
| 1356 | * alias: for "Arrayy->contains()" |
||
| 1357 | * |
||
| 1358 | * @param float|int|string $value |
||
| 1359 | * |
||
| 1360 | * @return bool |
||
| 1361 | * |
||
| 1362 | * @see Arrayy::contains() |
||
| 1363 | * @psalm-mutation-free |
||
| 1364 | */ |
||
| 1365 | 9 | public function containsValue($value): bool |
|
| 1369 | |||
| 1370 | /** |
||
| 1371 | * alias: for "Arrayy->contains($value, true)" |
||
| 1372 | * |
||
| 1373 | * @param float|int|string $value |
||
| 1374 | * |
||
| 1375 | * @return bool |
||
| 1376 | * |
||
| 1377 | * @see Arrayy::contains() |
||
| 1378 | * @psalm-mutation-free |
||
| 1379 | */ |
||
| 1380 | 18 | public function containsValueRecursive($value): bool |
|
| 1384 | |||
| 1385 | /** |
||
| 1386 | * Check if all given needles are present in the array. |
||
| 1387 | * |
||
| 1388 | * @param array $needles |
||
| 1389 | * |
||
| 1390 | * @return bool |
||
| 1391 | * <p>Returns true if all the given values exists in the array, false otherwise.</p> |
||
| 1392 | * |
||
| 1393 | * @psalm-param array<mixed>|array<T> $needles |
||
| 1394 | * @psalm-mutation-free |
||
| 1395 | */ |
||
| 1396 | 1 | public function containsValues(array $needles): bool |
|
| 1402 | |||
| 1403 | /** |
||
| 1404 | * Counts all the values of an array |
||
| 1405 | * |
||
| 1406 | * @see http://php.net/manual/en/function.array-count-values.php |
||
| 1407 | * |
||
| 1408 | * @return static |
||
| 1409 | * <p> |
||
| 1410 | * (Immutable) |
||
| 1411 | * An associative Arrayy-object of values from input as |
||
| 1412 | * keys and their count as value. |
||
| 1413 | * </p> |
||
| 1414 | * |
||
| 1415 | * @psalm-return static<TKey,T> |
||
| 1416 | * @psalm-mutation-free |
||
| 1417 | */ |
||
| 1418 | 7 | public function countValues(): self |
|
| 1422 | |||
| 1423 | /** |
||
| 1424 | * Creates an Arrayy object. |
||
| 1425 | * |
||
| 1426 | * @param mixed $data |
||
| 1427 | * @param string $iteratorClass |
||
| 1428 | * @param bool $checkPropertiesInConstructor |
||
| 1429 | * |
||
| 1430 | * @return static |
||
| 1431 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 1432 | * |
||
| 1433 | * @psalm-param class-string<\Arrayy\ArrayyIterator> $iteratorClass |
||
| 1434 | * |
||
| 1435 | * @psalm-mutation-free |
||
| 1436 | */ |
||
| 1437 | 690 | public static function create( |
|
| 1448 | |||
| 1449 | /** |
||
| 1450 | * Flatten an array with the given character as a key delimiter |
||
| 1451 | * |
||
| 1452 | * @param string $delimiter |
||
| 1453 | * @param string $prepend |
||
| 1454 | * @param array|null $items |
||
| 1455 | * |
||
| 1456 | * @return array |
||
| 1457 | */ |
||
| 1458 | 2 | public function flatten($delimiter = '.', $prepend = '', $items = null) |
|
| 1481 | |||
| 1482 | /** |
||
| 1483 | * WARNING: Creates an Arrayy object by reference. |
||
| 1484 | * |
||
| 1485 | * @param array $array |
||
| 1486 | * |
||
| 1487 | * @return $this |
||
| 1488 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 1489 | * |
||
| 1490 | * @psalm-param array<mixed,mixed>|array<array-key,mixed> $array |
||
| 1491 | */ |
||
| 1492 | 2 | public function createByReference(array &$array = []): self |
|
| 1500 | |||
| 1501 | /** |
||
| 1502 | * Create an new instance from a callable function which will return an Generator. |
||
| 1503 | * |
||
| 1504 | * @param callable $generatorFunction |
||
| 1505 | * |
||
| 1506 | * @return static |
||
| 1507 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 1508 | * |
||
| 1509 | * @psalm-param callable():\Generator<array-key,mixed> $generatorFunction |
||
| 1510 | * |
||
| 1511 | * @psalm-mutation-free |
||
| 1512 | */ |
||
| 1513 | 7 | public static function createFromGeneratorFunction(callable $generatorFunction): self |
|
| 1517 | |||
| 1518 | /** |
||
| 1519 | * Create an new instance filled with a copy of values from a "Generator"-object. |
||
| 1520 | * |
||
| 1521 | * @param \Generator $generator |
||
| 1522 | * |
||
| 1523 | * @return static |
||
| 1524 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 1525 | * |
||
| 1526 | * @psalm-param \Generator<array-key,mixed> $generator |
||
| 1527 | * |
||
| 1528 | * @psalm-mutation-free |
||
| 1529 | */ |
||
| 1530 | 4 | public static function createFromGeneratorImmutable(\Generator $generator): self |
|
| 1534 | |||
| 1535 | /** |
||
| 1536 | * Create an new Arrayy object via JSON. |
||
| 1537 | * |
||
| 1538 | * @param string $json |
||
| 1539 | * |
||
| 1540 | * @return static |
||
| 1541 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 1542 | * |
||
| 1543 | * @psalm-mutation-free |
||
| 1544 | */ |
||
| 1545 | 5 | public static function createFromJson(string $json): self |
|
| 1549 | |||
| 1550 | /** |
||
| 1551 | * Create an new Arrayy object via JSON. |
||
| 1552 | * |
||
| 1553 | * @param array $array |
||
| 1554 | * |
||
| 1555 | * @return static |
||
| 1556 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 1557 | * |
||
| 1558 | * @psalm-mutation-free |
||
| 1559 | */ |
||
| 1560 | 1 | public static function createFromArray(array $array): self |
|
| 1564 | |||
| 1565 | /** |
||
| 1566 | * Create an new instance filled with values from an object that is iterable. |
||
| 1567 | * |
||
| 1568 | * @param \Traversable $object <p>iterable object</p> |
||
| 1569 | * |
||
| 1570 | * @return static |
||
| 1571 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 1572 | * |
||
| 1573 | * @psalm-param \Traversable<array-key,mixed> $object |
||
| 1574 | * |
||
| 1575 | * @psalm-mutation-free |
||
| 1576 | */ |
||
| 1577 | 4 | public static function createFromObject(\Traversable $object): self |
|
| 1597 | |||
| 1598 | /** |
||
| 1599 | * Create an new instance filled with values from an object. |
||
| 1600 | * |
||
| 1601 | * @param object $object |
||
| 1602 | * |
||
| 1603 | * @return static |
||
| 1604 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 1605 | * |
||
| 1606 | * @psalm-mutation-free |
||
| 1607 | */ |
||
| 1608 | 5 | public static function createFromObjectVars($object): self |
|
| 1612 | |||
| 1613 | /** |
||
| 1614 | * Create an new Arrayy object via string. |
||
| 1615 | * |
||
| 1616 | * @param string $str <p>The input string.</p> |
||
| 1617 | * @param string|null $delimiter <p>The boundary string.</p> |
||
| 1618 | * @param string|null $regEx <p>Use the $delimiter or the $regEx, so if $pattern is null, $delimiter will be |
||
| 1619 | * used.</p> |
||
| 1620 | * |
||
| 1621 | * @return static |
||
| 1622 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 1623 | * |
||
| 1624 | * @psalm-mutation-free |
||
| 1625 | */ |
||
| 1626 | 10 | public static function createFromString(string $str, string $delimiter = null, string $regEx = null): self |
|
| 1658 | |||
| 1659 | /** |
||
| 1660 | * Create an new instance filled with a copy of values from a "Traversable"-object. |
||
| 1661 | * |
||
| 1662 | * @param \Traversable $traversable |
||
| 1663 | * |
||
| 1664 | * @return static |
||
| 1665 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 1666 | * |
||
| 1667 | * @psalm-param \Traversable<array-key,mixed> $traversable |
||
| 1668 | * |
||
| 1669 | * @psalm-mutation-free |
||
| 1670 | */ |
||
| 1671 | 1 | public static function createFromTraversableImmutable(\Traversable $traversable): self |
|
| 1675 | |||
| 1676 | /** |
||
| 1677 | * Create an new instance containing a range of elements. |
||
| 1678 | * |
||
| 1679 | * @param float|int|string $low <p>First value of the sequence.</p> |
||
| 1680 | * @param float|int|string $high <p>The sequence is ended upon reaching the end value.</p> |
||
| 1681 | * @param float|int $step <p>Used as the increment between elements in the sequence.</p> |
||
| 1682 | * |
||
| 1683 | * @return static |
||
| 1684 | * <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 1685 | * |
||
| 1686 | * @psalm-mutation-free |
||
| 1687 | */ |
||
| 1688 | 2 | public static function createWithRange($low, $high, $step = 1): self |
|
| 1692 | |||
| 1693 | /** |
||
| 1694 | * Gets the element of the array at the current internal iterator position. |
||
| 1695 | * |
||
| 1696 | * @return false|mixed |
||
| 1697 | */ |
||
| 1698 | public function current() |
||
| 1702 | |||
| 1703 | /** |
||
| 1704 | * Custom sort by index via "uksort". |
||
| 1705 | * |
||
| 1706 | * @see http://php.net/manual/en/function.uksort.php |
||
| 1707 | * |
||
| 1708 | * @param callable $function |
||
| 1709 | * |
||
| 1710 | * @throws \InvalidArgumentException |
||
| 1711 | * |
||
| 1712 | * @return $this |
||
| 1713 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 1714 | * |
||
| 1715 | * @psalm-return static<TKey,T> |
||
| 1716 | */ |
||
| 1717 | 5 | public function customSortKeys(callable $function): self |
|
| 1725 | |||
| 1726 | /** |
||
| 1727 | * Custom sort by index via "uksort". |
||
| 1728 | * |
||
| 1729 | * @see http://php.net/manual/en/function.uksort.php |
||
| 1730 | * |
||
| 1731 | * @param callable $function |
||
| 1732 | * |
||
| 1733 | * @throws \InvalidArgumentException |
||
| 1734 | * |
||
| 1735 | * @return $this |
||
| 1736 | * <p>(Immutable) Return this Arrayy object.</p> |
||
| 1737 | * |
||
| 1738 | * @psalm-return static<TKey,T> |
||
| 1739 | * @psalm-mutation-free |
||
| 1740 | */ |
||
| 1741 | 1 | public function customSortKeysImmutable(callable $function): self |
|
| 1754 | |||
| 1755 | /** |
||
| 1756 | * Custom sort by value via "usort". |
||
| 1757 | * |
||
| 1758 | * @see http://php.net/manual/en/function.usort.php |
||
| 1759 | * |
||
| 1760 | * @param callable $function |
||
| 1761 | * |
||
| 1762 | * @throws \InvalidArgumentException |
||
| 1763 | * |
||
| 1764 | * @return $this |
||
| 1765 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 1766 | * |
||
| 1767 | * @psalm-return static<TKey,T> |
||
| 1768 | */ |
||
| 1769 | 10 | View Code Duplication | public function customSortValues($function): self |
| 1781 | |||
| 1782 | /** |
||
| 1783 | * Custom sort by value via "usort". |
||
| 1784 | * |
||
| 1785 | * @see http://php.net/manual/en/function.usort.php |
||
| 1786 | * |
||
| 1787 | * @param callable $function |
||
| 1788 | * |
||
| 1789 | * @throws \InvalidArgumentException |
||
| 1790 | * |
||
| 1791 | * @return $this |
||
| 1792 | * <p>(Immutable) Return this Arrayy object.</p> |
||
| 1793 | * |
||
| 1794 | * @psalm-return static<TKey,T> |
||
| 1795 | * @psalm-mutation-free |
||
| 1796 | */ |
||
| 1797 | 4 | public function customSortValuesImmutable($function): self |
|
| 1808 | |||
| 1809 | /** |
||
| 1810 | * Delete the given key or keys. |
||
| 1811 | * |
||
| 1812 | * @param int|int[]|string|string[] $keyOrKeys |
||
| 1813 | * |
||
| 1814 | * @return void |
||
| 1815 | */ |
||
| 1816 | 9 | public function delete($keyOrKeys) |
|
| 1824 | |||
| 1825 | /** |
||
| 1826 | * Return values that are only in the current array. |
||
| 1827 | * |
||
| 1828 | * @param array ...$array |
||
| 1829 | * |
||
| 1830 | * @return static |
||
| 1831 | * <p>(Immutable)</p> |
||
| 1832 | * |
||
| 1833 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
| 1834 | * @psalm-return static<TKey,T> |
||
| 1835 | * @psalm-mutation-free |
||
| 1836 | */ |
||
| 1837 | 13 | public function diff(...$array): self |
|
| 1845 | |||
| 1846 | /** |
||
| 1847 | * Return values that are only in the current array. |
||
| 1848 | * |
||
| 1849 | * @param array ...$array |
||
| 1850 | * |
||
| 1851 | * @return static |
||
| 1852 | * <p>(Immutable)</p> |
||
| 1853 | * |
||
| 1854 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
| 1855 | * @psalm-return static<TKey,T> |
||
| 1856 | * @psalm-mutation-free |
||
| 1857 | */ |
||
| 1858 | 8 | public function diffKey(...$array): self |
|
| 1866 | |||
| 1867 | /** |
||
| 1868 | * Return values and Keys that are only in the current array. |
||
| 1869 | * |
||
| 1870 | * @param array $array |
||
| 1871 | * |
||
| 1872 | * @return static |
||
| 1873 | * <p>(Immutable)</p> |
||
| 1874 | * |
||
| 1875 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
| 1876 | * @psalm-return static<TKey,T> |
||
| 1877 | * @psalm-mutation-free |
||
| 1878 | */ |
||
| 1879 | 8 | public function diffKeyAndValue(array $array = []): self |
|
| 1887 | |||
| 1888 | /** |
||
| 1889 | * Return values that are only in the current multi-dimensional array. |
||
| 1890 | * |
||
| 1891 | * @param array $array |
||
| 1892 | * @param array|\Generator|null $helperVariableForRecursion <p>(only for internal usage)</p> |
||
| 1893 | * |
||
| 1894 | * @return static |
||
| 1895 | * <p>(Immutable)</p> |
||
| 1896 | * |
||
| 1897 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
| 1898 | * @psalm-param null|array<TKey,T>|\Generator<TKey,T> $helperVariableForRecursion |
||
| 1899 | * @psalm-return static<TKey,T> |
||
| 1900 | * @psalm-mutation-free |
||
| 1901 | */ |
||
| 1902 | 1 | public function diffRecursive(array $array = [], $helperVariableForRecursion = null): self |
|
| 1937 | |||
| 1938 | /** |
||
| 1939 | * Return values that are only in the new $array. |
||
| 1940 | * |
||
| 1941 | * @param array $array |
||
| 1942 | * |
||
| 1943 | * @return static |
||
| 1944 | * <p>(Immutable)</p> |
||
| 1945 | * |
||
| 1946 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
| 1947 | * @psalm-return static<TKey,T> |
||
| 1948 | * @psalm-mutation-free |
||
| 1949 | */ |
||
| 1950 | 8 | public function diffReverse(array $array = []): self |
|
| 1958 | |||
| 1959 | /** |
||
| 1960 | * Divide an array into two arrays. One with keys and the other with values. |
||
| 1961 | * |
||
| 1962 | * @return static |
||
| 1963 | * <p>(Immutable)</p> |
||
| 1964 | * |
||
| 1965 | * @psalm-return static<TKey,T> |
||
| 1966 | * @psalm-mutation-free |
||
| 1967 | */ |
||
| 1968 | 1 | public function divide(): self |
|
| 1979 | |||
| 1980 | /** |
||
| 1981 | * Iterate over the current array and modify the array's value. |
||
| 1982 | * |
||
| 1983 | * @param \Closure $closure |
||
| 1984 | * |
||
| 1985 | * @return static |
||
| 1986 | * <p>(Immutable)</p> |
||
| 1987 | * |
||
| 1988 | * @psalm-return static<TKey,T> |
||
| 1989 | * @psalm-mutation-free |
||
| 1990 | */ |
||
| 1991 | 5 | View Code Duplication | public function each(\Closure $closure): self |
| 2006 | |||
| 2007 | /** |
||
| 2008 | * Sets the internal iterator to the last element in the array and returns this element. |
||
| 2009 | * |
||
| 2010 | * @return mixed |
||
| 2011 | */ |
||
| 2012 | public function end() |
||
| 2016 | |||
| 2017 | /** |
||
| 2018 | * Check if a value is in the current array using a closure. |
||
| 2019 | * |
||
| 2020 | * @param \Closure $closure |
||
| 2021 | * |
||
| 2022 | * @return bool |
||
| 2023 | * <p>Returns true if the given value is found, false otherwise.</p> |
||
| 2024 | */ |
||
| 2025 | 4 | public function exists(\Closure $closure): bool |
|
| 2040 | |||
| 2041 | /** |
||
| 2042 | * Fill the array until "$num" with "$default" values. |
||
| 2043 | * |
||
| 2044 | * @param int $num |
||
| 2045 | * @param mixed $default |
||
| 2046 | * |
||
| 2047 | * @return static |
||
| 2048 | * <p>(Immutable)</p> |
||
| 2049 | * |
||
| 2050 | * @psalm-return static<TKey,T> |
||
| 2051 | * @psalm-mutation-free |
||
| 2052 | */ |
||
| 2053 | 8 | public function fillWithDefaults(int $num, $default = null): self |
|
| 2076 | |||
| 2077 | /** |
||
| 2078 | * Find all items in an array that pass the truth test. |
||
| 2079 | * |
||
| 2080 | * @param \Closure|null $closure [optional] <p> |
||
| 2081 | * The callback function to use |
||
| 2082 | * </p> |
||
| 2083 | * <p> |
||
| 2084 | * If no callback is supplied, all entries of |
||
| 2085 | * input equal to false (see |
||
| 2086 | * converting to |
||
| 2087 | * boolean) will be removed. |
||
| 2088 | * </p> |
||
| 2089 | * @param int $flag [optional] <p> |
||
| 2090 | * Flag determining what arguments are sent to <i>callback</i>: |
||
| 2091 | * </p><ul> |
||
| 2092 | * <li> |
||
| 2093 | * <b>ARRAY_FILTER_USE_KEY</b> [1] - pass key as the only argument |
||
| 2094 | * to <i>callback</i> instead of the value</span> |
||
| 2095 | * </li> |
||
| 2096 | * <li> |
||
| 2097 | * <b>ARRAY_FILTER_USE_BOTH</b> [2] - pass both value and key as |
||
| 2098 | * arguments to <i>callback</i> instead of the value</span> |
||
| 2099 | * </li> |
||
| 2100 | * </ul> |
||
| 2101 | * |
||
| 2102 | * @return static |
||
| 2103 | * <p>(Immutable)</p> |
||
| 2104 | * |
||
| 2105 | * @psalm-param \Closure(T=,TKey=):bool|\Closure(T=):bool $closure |
||
| 2106 | * @psalm-return static<TKey,T> |
||
| 2107 | * @psalm-mutation-free |
||
| 2108 | */ |
||
| 2109 | 12 | public function filter($closure = null, int $flag = \ARRAY_FILTER_USE_BOTH) |
|
| 2121 | |||
| 2122 | /** |
||
| 2123 | * Filters an array of objects (or a numeric array of associative arrays) based on the value of a particular |
||
| 2124 | * property within that. |
||
| 2125 | * |
||
| 2126 | * @param string $property |
||
| 2127 | * @param string|string[] $value |
||
| 2128 | * @param string $comparisonOp |
||
| 2129 | * <p> |
||
| 2130 | * 'eq' (equals),<br /> |
||
| 2131 | * 'gt' (greater),<br /> |
||
| 2132 | * 'gte' || 'ge' (greater or equals),<br /> |
||
| 2133 | * 'lt' (less),<br /> |
||
| 2134 | * 'lte' || 'le' (less or equals),<br /> |
||
| 2135 | * 'ne' (not equals),<br /> |
||
| 2136 | * 'contains',<br /> |
||
| 2137 | * 'notContains',<br /> |
||
| 2138 | * 'newer' (via strtotime),<br /> |
||
| 2139 | * 'older' (via strtotime),<br /> |
||
| 2140 | * </p> |
||
| 2141 | * |
||
| 2142 | * @return static |
||
| 2143 | * <p>(Immutable)</p> |
||
| 2144 | * |
||
| 2145 | * @psalm-return static<TKey,T> |
||
| 2146 | * @psalm-mutation-free |
||
| 2147 | * |
||
| 2148 | * @psalm-suppress MissingClosureReturnType |
||
| 2149 | * @psalm-suppress MissingClosureParamType |
||
| 2150 | */ |
||
| 2151 | 1 | public function filterBy( |
|
| 2223 | |||
| 2224 | /** |
||
| 2225 | * Find the first item in an array that passes the truth test, |
||
| 2226 | * otherwise return false |
||
| 2227 | * |
||
| 2228 | * @param \Closure $closure |
||
| 2229 | * |
||
| 2230 | * @return false|mixed |
||
| 2231 | * <p>Return false if we did not find the value.</p> |
||
| 2232 | */ |
||
| 2233 | 8 | View Code Duplication | public function find(\Closure $closure) |
| 2243 | |||
| 2244 | /** |
||
| 2245 | * find by ... |
||
| 2246 | * |
||
| 2247 | * @param string $property |
||
| 2248 | * @param string|string[] $value |
||
| 2249 | * @param string $comparisonOp |
||
| 2250 | * |
||
| 2251 | * @return static |
||
| 2252 | * <p>(Immutable)</p> |
||
| 2253 | * |
||
| 2254 | * @psalm-return static<TKey,T> |
||
| 2255 | * @psalm-mutation-free |
||
| 2256 | */ |
||
| 2257 | 1 | public function findBy(string $property, $value, string $comparisonOp = 'eq'): self |
|
| 2261 | |||
| 2262 | /** |
||
| 2263 | * Get the first value from the current array. |
||
| 2264 | * |
||
| 2265 | * @return mixed |
||
| 2266 | * <p>Return null if there wasn't a element.</p> |
||
| 2267 | */ |
||
| 2268 | 21 | public function first() |
|
| 2277 | |||
| 2278 | /** |
||
| 2279 | * Get the first key from the current array. |
||
| 2280 | * |
||
| 2281 | * @return mixed |
||
| 2282 | * <p>Return null if there wasn't a element.</p> |
||
| 2283 | * @psalm-mutation-free |
||
| 2284 | */ |
||
| 2285 | 28 | public function firstKey() |
|
| 2291 | |||
| 2292 | /** |
||
| 2293 | * Get the first value(s) from the current array. |
||
| 2294 | * And will return an empty array if there was no first entry. |
||
| 2295 | * |
||
| 2296 | * @param int|null $number <p>How many values you will take?</p> |
||
| 2297 | * |
||
| 2298 | * @return static |
||
| 2299 | * <p>(Immutable)</p> |
||
| 2300 | * |
||
| 2301 | * @psalm-return static<TKey,T> |
||
| 2302 | * @psalm-mutation-free |
||
| 2303 | */ |
||
| 2304 | 37 | View Code Duplication | public function firstsImmutable(int $number = null): self |
| 2321 | |||
| 2322 | /** |
||
| 2323 | * Get the first value(s) from the current array. |
||
| 2324 | * And will return an empty array if there was no first entry. |
||
| 2325 | * |
||
| 2326 | * @param int|null $number <p>How many values you will take?</p> |
||
| 2327 | * |
||
| 2328 | * @return static |
||
| 2329 | * <p>(Immutable)</p> |
||
| 2330 | * |
||
| 2331 | * @psalm-return static<TKey,T> |
||
| 2332 | * @psalm-mutation-free |
||
| 2333 | */ |
||
| 2334 | 3 | View Code Duplication | public function firstsKeys(int $number = null): self |
| 2351 | |||
| 2352 | /** |
||
| 2353 | * Get and rmove the first value(s) from the current array. |
||
| 2354 | * And will return an empty array if there was no first entry. |
||
| 2355 | * |
||
| 2356 | * @param int|null $number <p>How many values you will take?</p> |
||
| 2357 | * |
||
| 2358 | * @return $this |
||
| 2359 | * <p>(Mutable)</p> |
||
| 2360 | * |
||
| 2361 | * @psalm-return static<TKey,T> |
||
| 2362 | */ |
||
| 2363 | 34 | public function firstsMutable(int $number = null): self |
|
| 2376 | |||
| 2377 | /** |
||
| 2378 | * Exchanges all keys with their associated values in an array. |
||
| 2379 | * |
||
| 2380 | * @return static |
||
| 2381 | * <p>(Immutable)</p> |
||
| 2382 | * |
||
| 2383 | * @psalm-return static<TKey,T> |
||
| 2384 | * @psalm-mutation-free |
||
| 2385 | */ |
||
| 2386 | 1 | public function flip(): self |
|
| 2394 | |||
| 2395 | /** |
||
| 2396 | * Get a value from an array (optional using dot-notation). |
||
| 2397 | * |
||
| 2398 | * @param mixed $key <p>The key to look for.</p> |
||
| 2399 | * @param mixed $fallback <p>Value to fallback to.</p> |
||
| 2400 | * @param array $array <p>The array to get from, if it's set to "null" we use the current array from the |
||
| 2401 | * class.</p> |
||
| 2402 | * |
||
| 2403 | * @return mixed|static |
||
| 2404 | * |
||
| 2405 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
| 2406 | * @psalm-mutation-free |
||
| 2407 | */ |
||
| 2408 | 215 | public function get($key, $fallback = null, array $array = null) |
|
| 2500 | |||
| 2501 | /** |
||
| 2502 | * alias: for "Arrayy->toArray()" |
||
| 2503 | * |
||
| 2504 | * @return array |
||
| 2505 | * |
||
| 2506 | * @see Arrayy::getArray() |
||
| 2507 | * |
||
| 2508 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
| 2509 | */ |
||
| 2510 | 12 | public function getAll(): array |
|
| 2514 | |||
| 2515 | /** |
||
| 2516 | * Get the current array from the "Arrayy"-object. |
||
| 2517 | * |
||
| 2518 | * alias for "toArray()" |
||
| 2519 | * |
||
| 2520 | * @param bool $convertAllArrayyElements <p> |
||
| 2521 | * Convert all Child-"Arrayy" objects also to arrays. |
||
| 2522 | * </p> |
||
| 2523 | * @param bool $preserveKeys <p> |
||
| 2524 | * e.g.: A generator maybe return the same key more then once, |
||
| 2525 | * so maybe you will ignore the keys. |
||
| 2526 | * </p> |
||
| 2527 | * |
||
| 2528 | * @return array |
||
| 2529 | * |
||
| 2530 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
| 2531 | * @psalm-mutation-free |
||
| 2532 | * |
||
| 2533 | * @see Arrayy::toArray() |
||
| 2534 | */ |
||
| 2535 | 492 | public function getArray( |
|
| 2544 | |||
| 2545 | /** |
||
| 2546 | * Get the current array from the "Arrayy"-object as list. |
||
| 2547 | * |
||
| 2548 | * alias for "toList()" |
||
| 2549 | * |
||
| 2550 | * @param bool $convertAllArrayyElements <p> |
||
| 2551 | * Convert all Child-"Arrayy" objects also to arrays. |
||
| 2552 | * </p> |
||
| 2553 | * |
||
| 2554 | * @return array |
||
| 2555 | * |
||
| 2556 | * @psalm-return array<int,mixed>|array<int,T> |
||
| 2557 | * @psalm-mutation-free |
||
| 2558 | * |
||
| 2559 | * @see Arrayy::toList() |
||
| 2560 | */ |
||
| 2561 | 1 | public function getList(bool $convertAllArrayyElements = false): array |
|
| 2565 | |||
| 2566 | /** |
||
| 2567 | * Returns the values from a single column of the input array, identified by |
||
| 2568 | * the $columnKey, can be used to extract data-columns from multi-arrays. |
||
| 2569 | * |
||
| 2570 | * Info: Optionally, you may provide an $indexKey to index the values in the returned |
||
| 2571 | * array by the values from the $indexKey column in the input array. |
||
| 2572 | * |
||
| 2573 | * @param mixed $columnKey |
||
| 2574 | * @param mixed $indexKey |
||
| 2575 | * |
||
| 2576 | * @return static |
||
| 2577 | * <p>(Immutable)</p> |
||
| 2578 | * |
||
| 2579 | * @psalm-return static<TKey,T> |
||
| 2580 | * @psalm-mutation-free |
||
| 2581 | */ |
||
| 2582 | 1 | public function getColumn($columnKey = null, $indexKey = null): self |
|
| 2590 | |||
| 2591 | /** |
||
| 2592 | * Get the current array from the "Arrayy"-object as generator. |
||
| 2593 | * |
||
| 2594 | * @return \Generator |
||
| 2595 | * |
||
| 2596 | * @psalm-return \Generator<mixed,T>|\Generator<TKey,T> |
||
| 2597 | * @psalm-mutation-free |
||
| 2598 | */ |
||
| 2599 | 1010 | public function getGenerator(): \Generator |
|
| 2607 | |||
| 2608 | /** |
||
| 2609 | * alias: for "Arrayy->keys()" |
||
| 2610 | * |
||
| 2611 | * @return static |
||
| 2612 | * <p>(Immutable)</p> |
||
| 2613 | * |
||
| 2614 | * @see Arrayy::keys() |
||
| 2615 | * |
||
| 2616 | * @psalm-return static<array-key,TKey> |
||
| 2617 | * @psalm-mutation-free |
||
| 2618 | */ |
||
| 2619 | 2 | public function getKeys() |
|
| 2623 | |||
| 2624 | /** |
||
| 2625 | * Get the current array from the "Arrayy"-object as object. |
||
| 2626 | * |
||
| 2627 | * @return \stdClass |
||
| 2628 | */ |
||
| 2629 | 4 | public function getObject(): \stdClass |
|
| 2633 | |||
| 2634 | /** |
||
| 2635 | * alias: for "Arrayy->randomImmutable()" |
||
| 2636 | * |
||
| 2637 | * @return static |
||
| 2638 | * <p>(Immutable)</p> |
||
| 2639 | * |
||
| 2640 | * @see Arrayy::randomImmutable() |
||
| 2641 | * |
||
| 2642 | * @psalm-return static<int|array-key,T> |
||
| 2643 | */ |
||
| 2644 | 4 | public function getRandom(): self |
|
| 2648 | |||
| 2649 | /** |
||
| 2650 | * alias: for "Arrayy->randomKey()" |
||
| 2651 | * |
||
| 2652 | * @return mixed |
||
| 2653 | * <p>Get a key/index or null if there wasn't a key/index.</p> |
||
| 2654 | * |
||
| 2655 | * @see Arrayy::randomKey() |
||
| 2656 | */ |
||
| 2657 | 3 | public function getRandomKey() |
|
| 2661 | |||
| 2662 | /** |
||
| 2663 | * alias: for "Arrayy->randomKeys()" |
||
| 2664 | * |
||
| 2665 | * @param int $number |
||
| 2666 | * |
||
| 2667 | * @return static |
||
| 2668 | * <p>(Immutable)</p> |
||
| 2669 | * |
||
| 2670 | * @see Arrayy::randomKeys() |
||
| 2671 | * |
||
| 2672 | * @psalm-return static<TKey,T> |
||
| 2673 | */ |
||
| 2674 | 8 | public function getRandomKeys(int $number): self |
|
| 2678 | |||
| 2679 | /** |
||
| 2680 | * alias: for "Arrayy->randomValue()" |
||
| 2681 | * |
||
| 2682 | * @return mixed |
||
| 2683 | * <p>Get a random value or null if there wasn't a value.</p> |
||
| 2684 | * |
||
| 2685 | * @see Arrayy::randomValue() |
||
| 2686 | */ |
||
| 2687 | 3 | public function getRandomValue() |
|
| 2691 | |||
| 2692 | /** |
||
| 2693 | * alias: for "Arrayy->randomValues()" |
||
| 2694 | * |
||
| 2695 | * @param int $number |
||
| 2696 | * |
||
| 2697 | * @return static |
||
| 2698 | * <p>(Immutable)</p> |
||
| 2699 | * |
||
| 2700 | * @see Arrayy::randomValues() |
||
| 2701 | * |
||
| 2702 | * @psalm-return static<TKey,T> |
||
| 2703 | */ |
||
| 2704 | 6 | public function getRandomValues(int $number): self |
|
| 2708 | |||
| 2709 | /** |
||
| 2710 | * Gets all values. |
||
| 2711 | * |
||
| 2712 | * @return static |
||
| 2713 | * <p>The values of all elements in this array, in the order they |
||
| 2714 | * appear in the array.</p> |
||
| 2715 | * |
||
| 2716 | * @psalm-return static<TKey,T> |
||
| 2717 | */ |
||
| 2718 | 4 | public function getValues() |
|
| 2728 | |||
| 2729 | /** |
||
| 2730 | * Gets all values via Generator. |
||
| 2731 | * |
||
| 2732 | * @return \Generator |
||
| 2733 | * <p>The values of all elements in this array, in the order they |
||
| 2734 | * appear in the array as Generator.</p> |
||
| 2735 | * |
||
| 2736 | * @psalm-return \Generator<TKey,T> |
||
| 2737 | */ |
||
| 2738 | 4 | public function getValuesYield(): \Generator |
|
| 2742 | |||
| 2743 | /** |
||
| 2744 | * Group values from a array according to the results of a closure. |
||
| 2745 | * |
||
| 2746 | * @param callable|string $grouper <p>A callable function name.</p> |
||
| 2747 | * @param bool $saveKeys |
||
| 2748 | * |
||
| 2749 | * @return static |
||
| 2750 | * <p>(Immutable)</p> |
||
| 2751 | * |
||
| 2752 | * @psalm-return static<TKey,T> |
||
| 2753 | * @psalm-mutation-free |
||
| 2754 | */ |
||
| 2755 | 4 | public function group($grouper, bool $saveKeys = false): self |
|
| 2796 | |||
| 2797 | /** |
||
| 2798 | * Check if an array has a given key. |
||
| 2799 | * |
||
| 2800 | * @param mixed $key |
||
| 2801 | * |
||
| 2802 | * @return bool |
||
| 2803 | */ |
||
| 2804 | 28 | public function has($key): bool |
|
| 2830 | |||
| 2831 | /** |
||
| 2832 | * Check if an array has a given value. |
||
| 2833 | * |
||
| 2834 | * INFO: if you need to search recursive please use ```contains()``` |
||
| 2835 | * |
||
| 2836 | * @param mixed $value |
||
| 2837 | * |
||
| 2838 | * @return bool |
||
| 2839 | */ |
||
| 2840 | 1 | public function hasValue($value): bool |
|
| 2844 | |||
| 2845 | /** |
||
| 2846 | * Implodes the values of this array. |
||
| 2847 | * |
||
| 2848 | * @param string $glue |
||
| 2849 | * |
||
| 2850 | * @return string |
||
| 2851 | * @psalm-mutation-free |
||
| 2852 | */ |
||
| 2853 | 28 | public function implode(string $glue = ''): string |
|
| 2857 | |||
| 2858 | /** |
||
| 2859 | * Implodes the keys of this array. |
||
| 2860 | * |
||
| 2861 | * @param string $glue |
||
| 2862 | * |
||
| 2863 | * @return string |
||
| 2864 | * @psalm-mutation-free |
||
| 2865 | */ |
||
| 2866 | 8 | public function implodeKeys(string $glue = ''): string |
|
| 2870 | |||
| 2871 | /** |
||
| 2872 | * Given a list and an iterate-function that returns |
||
| 2873 | * a key for each element in the list (or a property name), |
||
| 2874 | * returns an object with an index of each item. |
||
| 2875 | * |
||
| 2876 | * @param mixed $key |
||
| 2877 | * |
||
| 2878 | * @return static |
||
| 2879 | * <p>(Immutable)</p> |
||
| 2880 | * |
||
| 2881 | * @psalm-return static<TKey,T> |
||
| 2882 | * @psalm-mutation-free |
||
| 2883 | */ |
||
| 2884 | 4 | public function indexBy($key): self |
|
| 2901 | |||
| 2902 | /** |
||
| 2903 | * alias: for "Arrayy->searchIndex()" |
||
| 2904 | * |
||
| 2905 | * @param mixed $value <p>The value to search for.</p> |
||
| 2906 | * |
||
| 2907 | * @return false|mixed |
||
| 2908 | * |
||
| 2909 | * @see Arrayy::searchIndex() |
||
| 2910 | */ |
||
| 2911 | 4 | public function indexOf($value) |
|
| 2915 | |||
| 2916 | /** |
||
| 2917 | * Get everything but the last..$to items. |
||
| 2918 | * |
||
| 2919 | * @param int $to |
||
| 2920 | * |
||
| 2921 | * @return static |
||
| 2922 | * <p>(Immutable)</p> |
||
| 2923 | * |
||
| 2924 | * @psalm-return static<TKey,T> |
||
| 2925 | * @psalm-mutation-free |
||
| 2926 | */ |
||
| 2927 | 12 | public function initial(int $to = 1): self |
|
| 2931 | |||
| 2932 | /** |
||
| 2933 | * Return an array with all elements found in input array. |
||
| 2934 | * |
||
| 2935 | * @param array $search |
||
| 2936 | * @param bool $keepKeys |
||
| 2937 | * |
||
| 2938 | * @return static |
||
| 2939 | * <p>(Immutable)</p> |
||
| 2940 | * |
||
| 2941 | * @psalm-param array<mixed,mixed>|array<TKey,T> $search |
||
| 2942 | * @psalm-return static<TKey,T> |
||
| 2943 | * @psalm-mutation-free |
||
| 2944 | */ |
||
| 2945 | 4 | public function intersection(array $search, bool $keepKeys = false): self |
|
| 2971 | |||
| 2972 | /** |
||
| 2973 | * Return an array with all elements found in input array. |
||
| 2974 | * |
||
| 2975 | * @param array ...$array |
||
| 2976 | * |
||
| 2977 | * @return static |
||
| 2978 | * <p>(Immutable)</p> |
||
| 2979 | * |
||
| 2980 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$array |
||
| 2981 | * @psalm-return static<TKey,T> |
||
| 2982 | * @psalm-mutation-free |
||
| 2983 | */ |
||
| 2984 | 1 | public function intersectionMulti(...$array): self |
|
| 2992 | |||
| 2993 | /** |
||
| 2994 | * Return a boolean flag which indicates whether the two input arrays have any common elements. |
||
| 2995 | * |
||
| 2996 | * @param array $search |
||
| 2997 | * |
||
| 2998 | * @return bool |
||
| 2999 | * |
||
| 3000 | * @psalm-param array<mixed,mixed>|array<TKey,T> $search |
||
| 3001 | */ |
||
| 3002 | 1 | public function intersects(array $search): bool |
|
| 3006 | |||
| 3007 | /** |
||
| 3008 | * Invoke a function on all of an array's values. |
||
| 3009 | * |
||
| 3010 | * @param callable $callable |
||
| 3011 | * @param mixed $arguments |
||
| 3012 | * |
||
| 3013 | * @return static |
||
| 3014 | * <p>(Immutable)</p> |
||
| 3015 | * |
||
| 3016 | * @psalm-param callable(T=,mixed):mixed $callable |
||
| 3017 | * @psalm-return static<TKey,T> |
||
| 3018 | * @psalm-mutation-free |
||
| 3019 | */ |
||
| 3020 | 1 | View Code Duplication | public function invoke($callable, $arguments = []): self |
| 3044 | |||
| 3045 | /** |
||
| 3046 | * Check whether array is associative or not. |
||
| 3047 | * |
||
| 3048 | * @param bool $recursive |
||
| 3049 | * |
||
| 3050 | * @return bool |
||
| 3051 | * <p>Returns true if associative, false otherwise.</p> |
||
| 3052 | */ |
||
| 3053 | 15 | View Code Duplication | public function isAssoc(bool $recursive = false): bool |
| 3067 | |||
| 3068 | /** |
||
| 3069 | * Check if a given key or keys are empty. |
||
| 3070 | * |
||
| 3071 | * @param int|int[]|string|string[]|null $keys |
||
| 3072 | * |
||
| 3073 | * @return bool |
||
| 3074 | * <p>Returns true if empty, false otherwise.</p> |
||
| 3075 | * @psalm-mutation-free |
||
| 3076 | */ |
||
| 3077 | 41 | public function isEmpty($keys = null): bool |
|
| 3095 | |||
| 3096 | /** |
||
| 3097 | * Check if the current array is equal to the given "$array" or not. |
||
| 3098 | * |
||
| 3099 | * @param array $array |
||
| 3100 | * |
||
| 3101 | * @return bool |
||
| 3102 | * |
||
| 3103 | * @psalm-param array<mixed,mixed> $array |
||
| 3104 | */ |
||
| 3105 | 1 | public function isEqual(array $array): bool |
|
| 3109 | |||
| 3110 | /** |
||
| 3111 | * Check if the current array is a multi-array. |
||
| 3112 | * |
||
| 3113 | * @return bool |
||
| 3114 | */ |
||
| 3115 | 22 | public function isMultiArray(): bool |
|
| 3123 | |||
| 3124 | /** |
||
| 3125 | * Check whether array is numeric or not. |
||
| 3126 | * |
||
| 3127 | * @return bool |
||
| 3128 | * <p>Returns true if numeric, false otherwise.</p> |
||
| 3129 | */ |
||
| 3130 | 5 | View Code Duplication | public function isNumeric(): bool |
| 3144 | |||
| 3145 | /** |
||
| 3146 | * Check if the current array is sequential [0, 1, 2, 3, 4, 5 ...] or not. |
||
| 3147 | * |
||
| 3148 | * @param bool $recursive |
||
| 3149 | * |
||
| 3150 | * @return bool |
||
| 3151 | * @psalm-mutation-free |
||
| 3152 | */ |
||
| 3153 | 9 | public function isSequential(bool $recursive = false): bool |
|
| 3170 | |||
| 3171 | /** |
||
| 3172 | * @return array |
||
| 3173 | * |
||
| 3174 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
| 3175 | */ |
||
| 3176 | 1 | public function jsonSerialize(): array |
|
| 3180 | |||
| 3181 | /** |
||
| 3182 | * Gets the key/index of the element at the current internal iterator position. |
||
| 3183 | * |
||
| 3184 | * @return int|string|null |
||
| 3185 | */ |
||
| 3186 | public function key() |
||
| 3190 | |||
| 3191 | /** |
||
| 3192 | * Checks if the given key exists in the provided array. |
||
| 3193 | * |
||
| 3194 | * INFO: This method only use "array_key_exists()" if you want to use "dot"-notation, |
||
| 3195 | * then you need to use "Arrayy->offsetExists()". |
||
| 3196 | * |
||
| 3197 | * @param int|string $key the key to look for |
||
| 3198 | * |
||
| 3199 | * @return bool |
||
| 3200 | * @psalm-mutation-free |
||
| 3201 | */ |
||
| 3202 | 140 | public function keyExists($key): bool |
|
| 3206 | |||
| 3207 | /** |
||
| 3208 | * Get all keys from the current array. |
||
| 3209 | * |
||
| 3210 | * @param bool $recursive [optional] <p> |
||
| 3211 | * Get all keys, also from all sub-arrays from an multi-dimensional array. |
||
| 3212 | * </p> |
||
| 3213 | * @param mixed|null $search_values [optional] <p> |
||
| 3214 | * If specified, then only keys containing these values are returned. |
||
| 3215 | * </p> |
||
| 3216 | * @param bool $strict [optional] <p> |
||
| 3217 | * Determines if strict comparison (===) should be used during the search. |
||
| 3218 | * </p> |
||
| 3219 | * |
||
| 3220 | * @return static |
||
| 3221 | * <p>(Immutable) An array of all the keys in input.</p> |
||
| 3222 | * |
||
| 3223 | * @psalm-return static<array-key,TKey> |
||
| 3224 | * @psalm-mutation-free |
||
| 3225 | */ |
||
| 3226 | 29 | public function keys( |
|
| 3296 | |||
| 3297 | /** |
||
| 3298 | * Sort an array by key in reverse order. |
||
| 3299 | * |
||
| 3300 | * @param int $sort_flags [optional] <p> |
||
| 3301 | * You may modify the behavior of the sort using the optional |
||
| 3302 | * parameter sort_flags, for details |
||
| 3303 | * see sort. |
||
| 3304 | * </p> |
||
| 3305 | * |
||
| 3306 | * @return $this |
||
| 3307 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 3308 | * |
||
| 3309 | * @psalm-return static<TKey,T> |
||
| 3310 | */ |
||
| 3311 | 4 | public function krsort(int $sort_flags = 0): self |
|
| 3319 | |||
| 3320 | /** |
||
| 3321 | * Sort an array by key in reverse order. |
||
| 3322 | * |
||
| 3323 | * @param int $sort_flags [optional] <p> |
||
| 3324 | * You may modify the behavior of the sort using the optional |
||
| 3325 | * parameter sort_flags, for details |
||
| 3326 | * see sort. |
||
| 3327 | * </p> |
||
| 3328 | * |
||
| 3329 | * @return $this |
||
| 3330 | * <p>(Immutable) Return this Arrayy object.</p> |
||
| 3331 | * |
||
| 3332 | * @psalm-return static<TKey,T> |
||
| 3333 | * @psalm-mutation-free |
||
| 3334 | */ |
||
| 3335 | 4 | public function krsortImmutable(int $sort_flags = 0): self |
|
| 3346 | |||
| 3347 | /** |
||
| 3348 | * Get the last value from the current array. |
||
| 3349 | * |
||
| 3350 | * @return mixed|null |
||
| 3351 | * <p>Return null if there wasn't a element.</p> |
||
| 3352 | * @psalm-mutation-free |
||
| 3353 | */ |
||
| 3354 | 17 | public function last() |
|
| 3363 | |||
| 3364 | /** |
||
| 3365 | * Get the last key from the current array. |
||
| 3366 | * |
||
| 3367 | * @return mixed|null |
||
| 3368 | * <p>Return null if there wasn't a element.</p> |
||
| 3369 | * @psalm-mutation-free |
||
| 3370 | */ |
||
| 3371 | 21 | public function lastKey() |
|
| 3377 | |||
| 3378 | /** |
||
| 3379 | * Get the last value(s) from the current array. |
||
| 3380 | * |
||
| 3381 | * @param int|null $number |
||
| 3382 | * |
||
| 3383 | * @return static |
||
| 3384 | * <p>(Immutable)</p> |
||
| 3385 | * |
||
| 3386 | * @psalm-return static<TKey,T> |
||
| 3387 | * @psalm-mutation-free |
||
| 3388 | */ |
||
| 3389 | 13 | public function lastsImmutable(int $number = null): self |
|
| 3420 | |||
| 3421 | /** |
||
| 3422 | * Get the last value(s) from the current array. |
||
| 3423 | * |
||
| 3424 | * @param int|null $number |
||
| 3425 | * |
||
| 3426 | * @return $this |
||
| 3427 | * <p>(Mutable)</p> |
||
| 3428 | * |
||
| 3429 | * @psalm-return static<TKey,T> |
||
| 3430 | */ |
||
| 3431 | 13 | public function lastsMutable(int $number = null): self |
|
| 3460 | |||
| 3461 | /** |
||
| 3462 | * Count the values from the current array. |
||
| 3463 | * |
||
| 3464 | * alias: for "Arrayy->count()" |
||
| 3465 | * |
||
| 3466 | * @param int $mode |
||
| 3467 | * |
||
| 3468 | * @return int |
||
| 3469 | * |
||
| 3470 | * @see Arrayy::count() |
||
| 3471 | */ |
||
| 3472 | 20 | public function length(int $mode = \COUNT_NORMAL): int |
|
| 3476 | |||
| 3477 | /** |
||
| 3478 | * Apply the given function to the every element of the array, |
||
| 3479 | * collecting the results. |
||
| 3480 | * |
||
| 3481 | * @param callable $callable |
||
| 3482 | * @param bool $useKeyAsSecondParameter |
||
| 3483 | * @param mixed ...$arguments |
||
| 3484 | * |
||
| 3485 | * @return static |
||
| 3486 | * <p>(Immutable) Arrayy object with modified elements.</p> |
||
| 3487 | * |
||
| 3488 | * @psalm-param callable(T,TKey=,mixed=):mixed $callable |
||
| 3489 | * @psalm-return static<TKey,T> |
||
| 3490 | * @psalm-mutation-free |
||
| 3491 | */ |
||
| 3492 | 5 | public function map( |
|
| 3525 | |||
| 3526 | /** |
||
| 3527 | * Check if all items in current array match a truth test. |
||
| 3528 | * |
||
| 3529 | * @param \Closure $closure |
||
| 3530 | * |
||
| 3531 | * @return bool |
||
| 3532 | */ |
||
| 3533 | 15 | View Code Duplication | public function matches(\Closure $closure): bool |
| 3549 | |||
| 3550 | /** |
||
| 3551 | * Check if any item in the current array matches a truth test. |
||
| 3552 | * |
||
| 3553 | * @param \Closure $closure |
||
| 3554 | * |
||
| 3555 | * @return bool |
||
| 3556 | */ |
||
| 3557 | 14 | View Code Duplication | public function matchesAny(\Closure $closure): bool |
| 3573 | |||
| 3574 | /** |
||
| 3575 | * Get the max value from an array. |
||
| 3576 | * |
||
| 3577 | * @return false|mixed |
||
| 3578 | * <p>Will return false if there are no values.</p> |
||
| 3579 | */ |
||
| 3580 | 10 | View Code Duplication | public function max() |
| 3599 | |||
| 3600 | /** |
||
| 3601 | * Merge the new $array into the current array. |
||
| 3602 | * |
||
| 3603 | * - keep key,value from the current array, also if the index is in the new $array |
||
| 3604 | * |
||
| 3605 | * @param array $array |
||
| 3606 | * @param bool $recursive |
||
| 3607 | * |
||
| 3608 | * @return static |
||
| 3609 | * <p>(Immutable)</p> |
||
| 3610 | * |
||
| 3611 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
| 3612 | * @psalm-return static<int|TKey,T> |
||
| 3613 | * @psalm-mutation-free |
||
| 3614 | */ |
||
| 3615 | 32 | View Code Duplication | public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self |
| 3630 | |||
| 3631 | /** |
||
| 3632 | * Merge the new $array into the current array. |
||
| 3633 | * |
||
| 3634 | * - replace duplicate assoc-keys from the current array with the key,values from the new $array |
||
| 3635 | * - create new indexes |
||
| 3636 | * |
||
| 3637 | * @param array $array |
||
| 3638 | * @param bool $recursive |
||
| 3639 | * |
||
| 3640 | * @return static |
||
| 3641 | * <p>(Immutable)</p> |
||
| 3642 | * |
||
| 3643 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
| 3644 | * @psalm-return static<TKey,T> |
||
| 3645 | * @psalm-mutation-free |
||
| 3646 | */ |
||
| 3647 | 19 | View Code Duplication | public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self |
| 3662 | |||
| 3663 | /** |
||
| 3664 | * Merge the the current array into the $array. |
||
| 3665 | * |
||
| 3666 | * - use key,value from the new $array, also if the index is in the current array |
||
| 3667 | * |
||
| 3668 | * @param array $array |
||
| 3669 | * @param bool $recursive |
||
| 3670 | * |
||
| 3671 | * @return static |
||
| 3672 | * <p>(Immutable)</p> |
||
| 3673 | * |
||
| 3674 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
| 3675 | * @psalm-return static<TKey,T> |
||
| 3676 | * @psalm-mutation-free |
||
| 3677 | */ |
||
| 3678 | 16 | View Code Duplication | public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self |
| 3693 | |||
| 3694 | /** |
||
| 3695 | * Merge the current array into the new $array. |
||
| 3696 | * |
||
| 3697 | * - replace duplicate assoc-keys from new $array with the key,values from the current array |
||
| 3698 | * - create new indexes |
||
| 3699 | * |
||
| 3700 | * @param array $array |
||
| 3701 | * @param bool $recursive |
||
| 3702 | * |
||
| 3703 | * @return static |
||
| 3704 | * <p>(Immutable)</p> |
||
| 3705 | * |
||
| 3706 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
| 3707 | * @psalm-return static<TKey,T> |
||
| 3708 | * @psalm-mutation-free |
||
| 3709 | */ |
||
| 3710 | 20 | View Code Duplication | public function mergePrependNewIndex(array $array = [], bool $recursive = false): self |
| 3725 | |||
| 3726 | /** |
||
| 3727 | * @return ArrayyMeta|static |
||
| 3728 | */ |
||
| 3729 | 15 | public static function meta() |
|
| 3733 | |||
| 3734 | /** |
||
| 3735 | * Get the min value from an array. |
||
| 3736 | * |
||
| 3737 | * @return false|mixed |
||
| 3738 | * <p>Will return false if there are no values.</p> |
||
| 3739 | */ |
||
| 3740 | 10 | View Code Duplication | public function min() |
| 3759 | |||
| 3760 | /** |
||
| 3761 | * Get the most used value from the array. |
||
| 3762 | * |
||
| 3763 | * @return mixed|null |
||
| 3764 | * <p>(Immutable) Return null if there wasn't a element.</p> |
||
| 3765 | * @psalm-mutation-free |
||
| 3766 | */ |
||
| 3767 | 3 | public function mostUsedValue() |
|
| 3771 | |||
| 3772 | /** |
||
| 3773 | * Get the most used value from the array. |
||
| 3774 | * |
||
| 3775 | * @param int|null $number <p>How many values you will take?</p> |
||
| 3776 | * |
||
| 3777 | * @return static |
||
| 3778 | * <p>(Immutable)</p> |
||
| 3779 | * |
||
| 3780 | * @psalm-return static<TKey,T> |
||
| 3781 | * @psalm-mutation-free |
||
| 3782 | */ |
||
| 3783 | 3 | public function mostUsedValues(int $number = null): self |
|
| 3787 | |||
| 3788 | /** |
||
| 3789 | * Move an array element to a new index. |
||
| 3790 | * |
||
| 3791 | * cherry-picked from: http://stackoverflow.com/questions/12624153/move-an-array-element-to-a-new-index-in-php |
||
| 3792 | * |
||
| 3793 | * @param int|string $from |
||
| 3794 | * @param int $to |
||
| 3795 | * |
||
| 3796 | * @return static |
||
| 3797 | * <p>(Immutable)</p> |
||
| 3798 | * |
||
| 3799 | * @psalm-return static<TKey,T> |
||
| 3800 | * @psalm-mutation-free |
||
| 3801 | */ |
||
| 3802 | 1 | public function moveElement($from, $to): self |
|
| 3835 | |||
| 3836 | /** |
||
| 3837 | * Move an array element to the first place. |
||
| 3838 | * |
||
| 3839 | * INFO: Instead of "Arrayy->moveElement()" this method will NOT |
||
| 3840 | * loss the keys of an indexed array. |
||
| 3841 | * |
||
| 3842 | * @param int|string $key |
||
| 3843 | * |
||
| 3844 | * @return static |
||
| 3845 | * <p>(Immutable)</p> |
||
| 3846 | * |
||
| 3847 | * @psalm-return static<TKey,T> |
||
| 3848 | * @psalm-mutation-free |
||
| 3849 | */ |
||
| 3850 | 1 | View Code Duplication | public function moveElementToFirstPlace($key): self |
| 3866 | |||
| 3867 | /** |
||
| 3868 | * Move an array element to the last place. |
||
| 3869 | * |
||
| 3870 | * INFO: Instead of "Arrayy->moveElement()" this method will NOT |
||
| 3871 | * loss the keys of an indexed array. |
||
| 3872 | * |
||
| 3873 | * @param int|string $key |
||
| 3874 | * |
||
| 3875 | * @return static |
||
| 3876 | * <p>(Immutable)</p> |
||
| 3877 | * |
||
| 3878 | * @psalm-return static<TKey,T> |
||
| 3879 | * @psalm-mutation-free |
||
| 3880 | */ |
||
| 3881 | 1 | View Code Duplication | public function moveElementToLastPlace($key): self |
| 3897 | |||
| 3898 | /** |
||
| 3899 | * Moves the internal iterator position to the next element and returns this element. |
||
| 3900 | * |
||
| 3901 | * @return false|mixed |
||
| 3902 | * <p>(Mutable) Will return false if there are no values.</p> |
||
| 3903 | */ |
||
| 3904 | public function next() |
||
| 3908 | |||
| 3909 | /** |
||
| 3910 | * Get the next nth keys and values from the array. |
||
| 3911 | * |
||
| 3912 | * @param int $step |
||
| 3913 | * @param int $offset |
||
| 3914 | * |
||
| 3915 | * @return static |
||
| 3916 | * <p>(Immutable)</p> |
||
| 3917 | * |
||
| 3918 | * @psalm-return static<TKey,T> |
||
| 3919 | * @psalm-mutation-free |
||
| 3920 | */ |
||
| 3921 | 1 | public function nth(int $step, int $offset = 0): self |
|
| 3940 | |||
| 3941 | /** |
||
| 3942 | * Get a subset of the items from the given array. |
||
| 3943 | * |
||
| 3944 | * @param mixed[] $keys |
||
| 3945 | * |
||
| 3946 | * @return static |
||
| 3947 | * <p>(Immutable)</p> |
||
| 3948 | * |
||
| 3949 | * @psalm-return static<TKey,T> |
||
| 3950 | * @psalm-mutation-free |
||
| 3951 | */ |
||
| 3952 | 1 | public function only(array $keys): self |
|
| 3962 | |||
| 3963 | /** |
||
| 3964 | * Pad array to the specified size with a given value. |
||
| 3965 | * |
||
| 3966 | * @param int $size <p>Size of the result array.</p> |
||
| 3967 | * @param mixed $value <p>Empty value by default.</p> |
||
| 3968 | * |
||
| 3969 | * @return static |
||
| 3970 | * <p>(Immutable) Arrayy object padded to $size with $value.</p> |
||
| 3971 | * |
||
| 3972 | * @psalm-return static<TKey,T> |
||
| 3973 | * @psalm-mutation-free |
||
| 3974 | */ |
||
| 3975 | 5 | public function pad(int $size, $value): self |
|
| 3983 | |||
| 3984 | /** |
||
| 3985 | * Partitions this array in two array according to a predicate. |
||
| 3986 | * Keys are preserved in the resulting array. |
||
| 3987 | * |
||
| 3988 | * @param \Closure $closure |
||
| 3989 | * <p>The predicate on which to partition.</p> |
||
| 3990 | * |
||
| 3991 | * @return array<int, static> |
||
| 3992 | * <p>An array with two elements. The first element contains the array |
||
| 3993 | * of elements where the predicate returned TRUE, the second element |
||
| 3994 | * contains the array of elements where the predicate returned FALSE.</p> |
||
| 3995 | * |
||
| 3996 | * @psalm-return array<int, static<TKey,T>> |
||
| 3997 | */ |
||
| 3998 | 1 | public function partition(\Closure $closure): array |
|
| 4014 | |||
| 4015 | /** |
||
| 4016 | * Pop a specified value off the end of the current array. |
||
| 4017 | * |
||
| 4018 | * @return mixed|null |
||
| 4019 | * <p>(Mutable) The popped element from the current array or null if the array is e.g. empty.</p> |
||
| 4020 | */ |
||
| 4021 | 5 | public function pop() |
|
| 4027 | |||
| 4028 | /** |
||
| 4029 | * Prepend a (key) + value to the current array. |
||
| 4030 | * |
||
| 4031 | * @param mixed $value |
||
| 4032 | * @param mixed $key |
||
| 4033 | * |
||
| 4034 | * @return $this |
||
| 4035 | * <p>(Mutable) Return this Arrayy object, with the prepended value.</p> |
||
| 4036 | * |
||
| 4037 | * @psalm-return static<TKey,T> |
||
| 4038 | */ |
||
| 4039 | 11 | public function prepend($value, $key = null) |
|
| 4055 | |||
| 4056 | /** |
||
| 4057 | * Add a suffix to each key. |
||
| 4058 | * |
||
| 4059 | * @param mixed $suffix |
||
| 4060 | * |
||
| 4061 | * @return static |
||
| 4062 | * <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> |
||
| 4063 | * |
||
| 4064 | * @psalm-return static<TKey,T> |
||
| 4065 | * @psalm-mutation-free |
||
| 4066 | */ |
||
| 4067 | 10 | View Code Duplication | public function prependToEachKey($suffix): self |
| 4093 | |||
| 4094 | /** |
||
| 4095 | * Add a suffix to each value. |
||
| 4096 | * |
||
| 4097 | * @param mixed $suffix |
||
| 4098 | * |
||
| 4099 | * @return static |
||
| 4100 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
||
| 4101 | * |
||
| 4102 | * @psalm-return static<TKey,T> |
||
| 4103 | * @psalm-mutation-free |
||
| 4104 | */ |
||
| 4105 | 10 | View Code Duplication | public function prependToEachValue($suffix): self |
| 4133 | |||
| 4134 | /** |
||
| 4135 | * Return the value of a given key and |
||
| 4136 | * delete the key. |
||
| 4137 | * |
||
| 4138 | * @param int|int[]|string|string[]|null $keyOrKeys |
||
| 4139 | * @param mixed $fallback |
||
| 4140 | * |
||
| 4141 | * @return mixed |
||
| 4142 | */ |
||
| 4143 | 5 | public function pull($keyOrKeys = null, $fallback = null) |
|
| 4165 | |||
| 4166 | /** |
||
| 4167 | * Push one or more values onto the end of array at once. |
||
| 4168 | * |
||
| 4169 | * @param array ...$args |
||
| 4170 | * |
||
| 4171 | * @return $this |
||
| 4172 | * <p>(Mutable) Return this Arrayy object, with pushed elements to the end of array.</p> |
||
| 4173 | * |
||
| 4174 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
| 4175 | * |
||
| 4176 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$args |
||
| 4177 | * @psalm-return static<TKey,T> |
||
| 4178 | */ |
||
| 4179 | 7 | public function push(...$args) |
|
| 4197 | |||
| 4198 | /** |
||
| 4199 | * Get a random value from the current array. |
||
| 4200 | * |
||
| 4201 | * @param int|null $number <p>How many values you will take?</p> |
||
| 4202 | * |
||
| 4203 | * @return static |
||
| 4204 | * <p>(Immutable)</p> |
||
| 4205 | * |
||
| 4206 | * @psalm-return static<int|array-key,T> |
||
| 4207 | */ |
||
| 4208 | 19 | public function randomImmutable(int $number = null): self |
|
| 4241 | |||
| 4242 | /** |
||
| 4243 | * Pick a random key/index from the keys of this array. |
||
| 4244 | * |
||
| 4245 | * @throws \RangeException If array is empty |
||
| 4246 | * |
||
| 4247 | * @return mixed |
||
| 4248 | * <p>Get a key/index or null if there wasn't a key/index.</p> |
||
| 4249 | */ |
||
| 4250 | 4 | public function randomKey() |
|
| 4260 | |||
| 4261 | /** |
||
| 4262 | * Pick a given number of random keys/indexes out of this array. |
||
| 4263 | * |
||
| 4264 | * @param int $number <p>The number of keys/indexes (should be <= \count($this->array))</p> |
||
| 4265 | * |
||
| 4266 | * @throws \RangeException If array is empty |
||
| 4267 | * |
||
| 4268 | * @return static |
||
| 4269 | * <p>(Immutable)</p> |
||
| 4270 | * |
||
| 4271 | * @psalm-return static<TKey,T> |
||
| 4272 | */ |
||
| 4273 | 13 | public function randomKeys(int $number): self |
|
| 4301 | |||
| 4302 | /** |
||
| 4303 | * Get a random value from the current array. |
||
| 4304 | * |
||
| 4305 | * @param int|null $number <p>How many values you will take?</p> |
||
| 4306 | * |
||
| 4307 | * @return $this |
||
| 4308 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 4309 | * |
||
| 4310 | * @psalm-return static<TKey,T> |
||
| 4311 | */ |
||
| 4312 | 17 | public function randomMutable(int $number = null): self |
|
| 4337 | |||
| 4338 | /** |
||
| 4339 | * Pick a random value from the values of this array. |
||
| 4340 | * |
||
| 4341 | * @return mixed |
||
| 4342 | * <p>Get a random value or null if there wasn't a value.</p> |
||
| 4343 | */ |
||
| 4344 | 4 | public function randomValue() |
|
| 4354 | |||
| 4355 | /** |
||
| 4356 | * Pick a given number of random values out of this array. |
||
| 4357 | * |
||
| 4358 | * @param int $number |
||
| 4359 | * |
||
| 4360 | * @return static |
||
| 4361 | * <p>(Mutable)</p> |
||
| 4362 | * |
||
| 4363 | * @psalm-return static<TKey,T> |
||
| 4364 | */ |
||
| 4365 | 7 | public function randomValues(int $number): self |
|
| 4369 | |||
| 4370 | /** |
||
| 4371 | * Get a random value from an array, with the ability to skew the results. |
||
| 4372 | * |
||
| 4373 | * Example: randomWeighted(['foo' => 1, 'bar' => 2]) has a 66% chance of returning bar. |
||
| 4374 | * |
||
| 4375 | * @param array $array |
||
| 4376 | * @param int|null $number <p>How many values you will take?</p> |
||
| 4377 | * |
||
| 4378 | * @return static<int,mixed> |
||
| 4379 | * <p>(Immutable)</p> |
||
| 4380 | * |
||
| 4381 | * @psalm-param array<mixed,mixed> $array |
||
| 4382 | * @psalm-return static<int|array-key,T> |
||
| 4383 | */ |
||
| 4384 | 9 | public function randomWeighted(array $array, int $number = null): self |
|
| 4399 | |||
| 4400 | /** |
||
| 4401 | * Reduce the current array via callable e.g. anonymous-function. |
||
| 4402 | * |
||
| 4403 | * @param callable $callable |
||
| 4404 | * @param mixed $init |
||
| 4405 | * |
||
| 4406 | * @return static |
||
| 4407 | * <p>(Immutable)</p> |
||
| 4408 | * |
||
| 4409 | * @psalm-return static<TKey,T> |
||
| 4410 | * @psalm-mutation-free |
||
| 4411 | */ |
||
| 4412 | 18 | public function reduce($callable, $init = []): self |
|
| 4442 | |||
| 4443 | /** |
||
| 4444 | * @param bool $unique |
||
| 4445 | * |
||
| 4446 | * @return static |
||
| 4447 | * <p>(Immutable)</p> |
||
| 4448 | * |
||
| 4449 | * @psalm-return static<TKey,T> |
||
| 4450 | * @psalm-mutation-free |
||
| 4451 | */ |
||
| 4452 | 14 | public function reduce_dimension(bool $unique = true): self |
|
| 4475 | |||
| 4476 | /** |
||
| 4477 | * Create a numerically re-indexed Arrayy object. |
||
| 4478 | * |
||
| 4479 | * @return $this |
||
| 4480 | * <p>(Mutable) Return this Arrayy object, with re-indexed array-elements.</p> |
||
| 4481 | * |
||
| 4482 | * @psalm-return static<TKey,T> |
||
| 4483 | */ |
||
| 4484 | 9 | public function reindex(): self |
|
| 4492 | |||
| 4493 | /** |
||
| 4494 | * Return all items that fail the truth test. |
||
| 4495 | * |
||
| 4496 | * @param \Closure $closure |
||
| 4497 | * |
||
| 4498 | * @return static |
||
| 4499 | * <p>(Immutable)</p> |
||
| 4500 | * |
||
| 4501 | * @psalm-return static<TKey,T> |
||
| 4502 | * @psalm-mutation-free |
||
| 4503 | */ |
||
| 4504 | 1 | View Code Duplication | public function reject(\Closure $closure): self |
| 4521 | |||
| 4522 | /** |
||
| 4523 | * Remove a value from the current array (optional using dot-notation). |
||
| 4524 | * |
||
| 4525 | * @param mixed $key |
||
| 4526 | * |
||
| 4527 | * @return static |
||
| 4528 | * <p>(Mutable)</p> |
||
| 4529 | * |
||
| 4530 | * @psalm-param TKey $key |
||
| 4531 | * @psalm-return static<TKey,T> |
||
| 4532 | */ |
||
| 4533 | 21 | public function remove($key) |
|
| 4556 | |||
| 4557 | /** |
||
| 4558 | * alias: for "Arrayy->removeValue()" |
||
| 4559 | * |
||
| 4560 | * @param mixed $element |
||
| 4561 | * |
||
| 4562 | * @return static |
||
| 4563 | * <p>(Immutable)</p> |
||
| 4564 | * |
||
| 4565 | * @psalm-param T $element |
||
| 4566 | * @psalm-return static<TKey,T> |
||
| 4567 | * @psalm-mutation-free |
||
| 4568 | */ |
||
| 4569 | 8 | public function removeElement($element) |
|
| 4573 | |||
| 4574 | /** |
||
| 4575 | * Remove the first value from the current array. |
||
| 4576 | * |
||
| 4577 | * @return static |
||
| 4578 | * <p>(Immutable)</p> |
||
| 4579 | * |
||
| 4580 | * @psalm-return static<TKey,T> |
||
| 4581 | * @psalm-mutation-free |
||
| 4582 | */ |
||
| 4583 | 7 | View Code Duplication | public function removeFirst(): self |
| 4595 | |||
| 4596 | /** |
||
| 4597 | * Remove the last value from the current array. |
||
| 4598 | * |
||
| 4599 | * @return static |
||
| 4600 | * <p>(Immutable)</p> |
||
| 4601 | * |
||
| 4602 | * @psalm-return static<TKey,T> |
||
| 4603 | * @psalm-mutation-free |
||
| 4604 | */ |
||
| 4605 | 7 | View Code Duplication | public function removeLast(): self |
| 4617 | |||
| 4618 | /** |
||
| 4619 | * Removes a particular value from an array (numeric or associative). |
||
| 4620 | * |
||
| 4621 | * @param mixed $value |
||
| 4622 | * |
||
| 4623 | * @return static |
||
| 4624 | * <p>(Immutable)</p> |
||
| 4625 | * |
||
| 4626 | * @psalm-param T $value |
||
| 4627 | * @psalm-return static<TKey,T> |
||
| 4628 | * @psalm-mutation-free |
||
| 4629 | */ |
||
| 4630 | 8 | public function removeValue($value): self |
|
| 4653 | |||
| 4654 | /** |
||
| 4655 | * Generate array of repeated arrays. |
||
| 4656 | * |
||
| 4657 | * @param int $times <p>How many times has to be repeated.</p> |
||
| 4658 | * |
||
| 4659 | * @return static |
||
| 4660 | * <p>(Immutable)</p> |
||
| 4661 | * |
||
| 4662 | * @psalm-return static<TKey,T> |
||
| 4663 | * @psalm-mutation-free |
||
| 4664 | */ |
||
| 4665 | 1 | public function repeat($times): self |
|
| 4677 | |||
| 4678 | /** |
||
| 4679 | * Replace a key with a new key/value pair. |
||
| 4680 | * |
||
| 4681 | * @param mixed $oldKey |
||
| 4682 | * @param mixed $newKey |
||
| 4683 | * @param mixed $newValue |
||
| 4684 | * |
||
| 4685 | * @return static |
||
| 4686 | * <p>(Immutable)</p> |
||
| 4687 | * |
||
| 4688 | * @psalm-return static<TKey,T> |
||
| 4689 | * @psalm-mutation-free |
||
| 4690 | */ |
||
| 4691 | 5 | public function replace($oldKey, $newKey, $newValue): self |
|
| 4701 | |||
| 4702 | /** |
||
| 4703 | * Create an array using the current array as values and the other array as keys. |
||
| 4704 | * |
||
| 4705 | * @param array $keys <p>An array of keys.</p> |
||
| 4706 | * |
||
| 4707 | * @return static |
||
| 4708 | * <p>(Immutable) Arrayy object with keys from the other array.</p> |
||
| 4709 | * |
||
| 4710 | * @psalm-param array<mixed,mixed>|array<mixed,TKey> $keys |
||
| 4711 | * @psalm-return static<TKey,T> |
||
| 4712 | * @psalm-mutation-free |
||
| 4713 | */ |
||
| 4714 | 2 | public function replaceAllKeys(array $keys): self |
|
| 4722 | |||
| 4723 | /** |
||
| 4724 | * Create an array using the current array as keys and the other array as values. |
||
| 4725 | * |
||
| 4726 | * @param array $array <p>An array o values.</p> |
||
| 4727 | * |
||
| 4728 | * @return static |
||
| 4729 | * <p>(Immutable) Arrayy object with values from the other array.</p> |
||
| 4730 | * |
||
| 4731 | * @psalm-param array<mixed,T> $array |
||
| 4732 | * @psalm-return static<TKey,T> |
||
| 4733 | * @psalm-mutation-free |
||
| 4734 | */ |
||
| 4735 | 2 | public function replaceAllValues(array $array): self |
|
| 4743 | |||
| 4744 | /** |
||
| 4745 | * Replace the keys in an array with another set. |
||
| 4746 | * |
||
| 4747 | * @param array $keys <p>An array of keys matching the array's size</p> |
||
| 4748 | * |
||
| 4749 | * @return static |
||
| 4750 | * <p>(Immutable)</p> |
||
| 4751 | * |
||
| 4752 | * @psalm-param array<mixed,mixed>|array<mixed,TKey> $keys |
||
| 4753 | * @psalm-return static<TKey,T> |
||
| 4754 | * @psalm-mutation-free |
||
| 4755 | */ |
||
| 4756 | 1 | public function replaceKeys(array $keys): self |
|
| 4767 | |||
| 4768 | /** |
||
| 4769 | * Replace the first matched value in an array. |
||
| 4770 | * |
||
| 4771 | * @param mixed $search <p>The value to replace.</p> |
||
| 4772 | * @param mixed $replacement <p>The value to replace.</p> |
||
| 4773 | * |
||
| 4774 | * @return static |
||
| 4775 | * <p>(Immutable)</p> |
||
| 4776 | * |
||
| 4777 | * @psalm-return static<TKey,T> |
||
| 4778 | * @psalm-mutation-free |
||
| 4779 | */ |
||
| 4780 | 3 | public function replaceOneValue($search, $replacement = ''): self |
|
| 4795 | |||
| 4796 | /** |
||
| 4797 | * Replace values in the current array. |
||
| 4798 | * |
||
| 4799 | * @param mixed $search <p>The value to replace.</p> |
||
| 4800 | * @param mixed $replacement <p>What to replace it with.</p> |
||
| 4801 | * |
||
| 4802 | * @return static |
||
| 4803 | * <p>(Immutable)</p> |
||
| 4804 | * |
||
| 4805 | * @psalm-return static<TKey,T> |
||
| 4806 | * @psalm-mutation-free |
||
| 4807 | */ |
||
| 4808 | 1 | public function replaceValues($search, $replacement = ''): self |
|
| 4820 | |||
| 4821 | /** |
||
| 4822 | * Get the last elements from index $from until the end of this array. |
||
| 4823 | * |
||
| 4824 | * @param int $from |
||
| 4825 | * |
||
| 4826 | * @return static |
||
| 4827 | * <p>(Immutable)</p> |
||
| 4828 | * |
||
| 4829 | * @psalm-return static<TKey,T> |
||
| 4830 | * @psalm-mutation-free |
||
| 4831 | */ |
||
| 4832 | 15 | View Code Duplication | public function rest(int $from = 1): self |
| 4842 | |||
| 4843 | /** |
||
| 4844 | * Return the array in the reverse order. |
||
| 4845 | * |
||
| 4846 | * @return $this |
||
| 4847 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 4848 | * |
||
| 4849 | * @psalm-return static<TKey,T> |
||
| 4850 | */ |
||
| 4851 | 9 | public function reverse(): self |
|
| 4859 | |||
| 4860 | /** |
||
| 4861 | * Sort an array in reverse order. |
||
| 4862 | * |
||
| 4863 | * @param int $sort_flags [optional] <p> |
||
| 4864 | * You may modify the behavior of the sort using the optional |
||
| 4865 | * parameter sort_flags, for details |
||
| 4866 | * see sort. |
||
| 4867 | * </p> |
||
| 4868 | * |
||
| 4869 | * @return $this |
||
| 4870 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 4871 | * |
||
| 4872 | * @psalm-return static<TKey,T> |
||
| 4873 | */ |
||
| 4874 | 4 | public function rsort(int $sort_flags = 0): self |
|
| 4882 | |||
| 4883 | /** |
||
| 4884 | * Sort an array in reverse order. |
||
| 4885 | * |
||
| 4886 | * @param int $sort_flags [optional] <p> |
||
| 4887 | * You may modify the behavior of the sort using the optional |
||
| 4888 | * parameter sort_flags, for details |
||
| 4889 | * see sort. |
||
| 4890 | * </p> |
||
| 4891 | * |
||
| 4892 | * @return $this |
||
| 4893 | * <p>(Immutable) Return this Arrayy object.</p> |
||
| 4894 | * |
||
| 4895 | * @psalm-return static<TKey,T> |
||
| 4896 | * @psalm-mutation-free |
||
| 4897 | */ |
||
| 4898 | 4 | public function rsortImmutable(int $sort_flags = 0): self |
|
| 4909 | |||
| 4910 | /** |
||
| 4911 | * Search for the first index of the current array via $value. |
||
| 4912 | * |
||
| 4913 | * @param mixed $value |
||
| 4914 | * |
||
| 4915 | * @return false|float|int|string |
||
| 4916 | * <p>Will return <b>FALSE</b> if the value can't be found.</p> |
||
| 4917 | * @psalm-mutation-free |
||
| 4918 | */ |
||
| 4919 | 21 | public function searchIndex($value) |
|
| 4929 | |||
| 4930 | /** |
||
| 4931 | * Search for the value of the current array via $index. |
||
| 4932 | * |
||
| 4933 | * @param mixed $index |
||
| 4934 | * |
||
| 4935 | * @return static |
||
| 4936 | * <p>(Immutable) Will return a empty Arrayy if the value wasn't found.</p> |
||
| 4937 | * |
||
| 4938 | * @psalm-return static<TKey,T> |
||
| 4939 | * @psalm-mutation-free |
||
| 4940 | */ |
||
| 4941 | 9 | public function searchValue($index): self |
|
| 4971 | |||
| 4972 | /** |
||
| 4973 | * Set a value for the current array (optional using dot-notation). |
||
| 4974 | * |
||
| 4975 | * @param string $key <p>The key to set.</p> |
||
| 4976 | * @param mixed $value <p>Its value.</p> |
||
| 4977 | * |
||
| 4978 | * @return $this |
||
| 4979 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 4980 | * |
||
| 4981 | * @psalm-param TKey $key |
||
| 4982 | * @psalm-param T $value |
||
| 4983 | * @psalm-return static<TKey,T> |
||
| 4984 | */ |
||
| 4985 | 26 | public function set($key, $value): self |
|
| 4991 | |||
| 4992 | /** |
||
| 4993 | * Get a value from a array and set it if it was not. |
||
| 4994 | * |
||
| 4995 | * WARNING: this method only set the value, if the $key is not already set |
||
| 4996 | * |
||
| 4997 | * @param mixed $key <p>The key</p> |
||
| 4998 | * @param mixed $fallback <p>The default value to set if it isn't.</p> |
||
| 4999 | * |
||
| 5000 | * @return mixed |
||
| 5001 | * <p>(Mutable)</p> |
||
| 5002 | */ |
||
| 5003 | 11 | public function setAndGet($key, $fallback = null) |
|
| 5014 | |||
| 5015 | /** |
||
| 5016 | * Shifts a specified value off the beginning of array. |
||
| 5017 | * |
||
| 5018 | * @return mixed |
||
| 5019 | * <p>(Mutable) A shifted element from the current array.</p> |
||
| 5020 | */ |
||
| 5021 | 5 | public function shift() |
|
| 5027 | |||
| 5028 | /** |
||
| 5029 | * Shuffle the current array. |
||
| 5030 | * |
||
| 5031 | * @param bool $secure <p>using a CSPRNG | @link https://paragonie.com/b/JvICXzh_jhLyt4y3</p> |
||
| 5032 | * @param array $array [optional] |
||
| 5033 | * |
||
| 5034 | * @return static |
||
| 5035 | * <p>(Immutable)</p> |
||
| 5036 | * |
||
| 5037 | * @psalm-param array<mixed,mixed>|array<TKey,T> $array |
||
| 5038 | * @psalm-return static<TKey,T> |
||
| 5039 | * |
||
| 5040 | * @noinspection BadExceptionsProcessingInspection |
||
| 5041 | * @noinspection RandomApiMigrationInspection |
||
| 5042 | * @noinspection NonSecureShuffleUsageInspection |
||
| 5043 | */ |
||
| 5044 | 2 | public function shuffle(bool $secure = false, array $array = null): self |
|
| 5082 | |||
| 5083 | /** |
||
| 5084 | * Count the values from the current array. |
||
| 5085 | * |
||
| 5086 | * alias: for "Arrayy->count()" |
||
| 5087 | * |
||
| 5088 | * @param int $mode |
||
| 5089 | * |
||
| 5090 | * @return int |
||
| 5091 | */ |
||
| 5092 | 20 | public function size(int $mode = \COUNT_NORMAL): int |
|
| 5096 | |||
| 5097 | /** |
||
| 5098 | * Checks whether array has exactly $size items. |
||
| 5099 | * |
||
| 5100 | * @param int $size |
||
| 5101 | * |
||
| 5102 | * @return bool |
||
| 5103 | */ |
||
| 5104 | 1 | View Code Duplication | public function sizeIs(int $size): bool |
| 5118 | |||
| 5119 | /** |
||
| 5120 | * Checks whether array has between $fromSize to $toSize items. $toSize can be |
||
| 5121 | * smaller than $fromSize. |
||
| 5122 | * |
||
| 5123 | * @param int $fromSize |
||
| 5124 | * @param int $toSize |
||
| 5125 | * |
||
| 5126 | * @return bool |
||
| 5127 | */ |
||
| 5128 | 1 | public function sizeIsBetween(int $fromSize, int $toSize): bool |
|
| 5148 | |||
| 5149 | /** |
||
| 5150 | * Checks whether array has more than $size items. |
||
| 5151 | * |
||
| 5152 | * @param int $size |
||
| 5153 | * |
||
| 5154 | * @return bool |
||
| 5155 | */ |
||
| 5156 | 1 | View Code Duplication | public function sizeIsGreaterThan(int $size): bool |
| 5170 | |||
| 5171 | /** |
||
| 5172 | * Checks whether array has less than $size items. |
||
| 5173 | * |
||
| 5174 | * @param int $size |
||
| 5175 | * |
||
| 5176 | * @return bool |
||
| 5177 | */ |
||
| 5178 | 1 | View Code Duplication | public function sizeIsLessThan(int $size): bool |
| 5192 | |||
| 5193 | /** |
||
| 5194 | * Counts all elements in an array, or something in an object. |
||
| 5195 | * |
||
| 5196 | * <p> |
||
| 5197 | * For objects, if you have SPL installed, you can hook into count() by implementing interface {@see Countable}. |
||
| 5198 | * The interface has exactly one method, {@see Countable::count()}, which returns the return value for the count() |
||
| 5199 | * function. Please see the {@see Array} section of the manual for a detailed explanation of how arrays are |
||
| 5200 | * implemented and used in PHP. |
||
| 5201 | * </p> |
||
| 5202 | * |
||
| 5203 | * @return int |
||
| 5204 | * <p> |
||
| 5205 | * The number of elements in var, which is |
||
| 5206 | * typically an array, since anything else will have one |
||
| 5207 | * element. |
||
| 5208 | * </p> |
||
| 5209 | * <p> |
||
| 5210 | * If var is not an array or an object with |
||
| 5211 | * implemented Countable interface, |
||
| 5212 | * 1 will be returned. |
||
| 5213 | * There is one exception, if var is &null;, |
||
| 5214 | * 0 will be returned. |
||
| 5215 | * </p> |
||
| 5216 | * <p> |
||
| 5217 | * Caution: count may return 0 for a variable that isn't set, |
||
| 5218 | * but it may also return 0 for a variable that has been initialized with an |
||
| 5219 | * empty array. Use isset to test if a variable is set. |
||
| 5220 | * </p> |
||
| 5221 | */ |
||
| 5222 | 10 | public function sizeRecursive(): int |
|
| 5226 | |||
| 5227 | /** |
||
| 5228 | * Extract a slice of the array. |
||
| 5229 | * |
||
| 5230 | * @param int $offset <p>Slice begin index.</p> |
||
| 5231 | * @param int|null $length <p>Length of the slice.</p> |
||
| 5232 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
| 5233 | * |
||
| 5234 | * @return static |
||
| 5235 | * <p>(Immutable) A slice of the original array with length $length.</p> |
||
| 5236 | * |
||
| 5237 | * @psalm-return static<TKey,T> |
||
| 5238 | * @psalm-mutation-free |
||
| 5239 | */ |
||
| 5240 | 5 | public function slice(int $offset, int $length = null, bool $preserveKeys = false) |
|
| 5253 | |||
| 5254 | /** |
||
| 5255 | * Sort the current array and optional you can keep the keys. |
||
| 5256 | * |
||
| 5257 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
| 5258 | * @param int $strategy <p>sort_flags => use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
| 5259 | * <strong>SORT_NATURAL</strong></p> |
||
| 5260 | * @param bool $keepKeys |
||
| 5261 | * |
||
| 5262 | * @return static |
||
| 5263 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 5264 | * |
||
| 5265 | * @psalm-return static<TKey,T> |
||
| 5266 | */ |
||
| 5267 | 20 | public function sort( |
|
| 5281 | |||
| 5282 | /** |
||
| 5283 | * Sort the current array and optional you can keep the keys. |
||
| 5284 | * |
||
| 5285 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
| 5286 | * @param int $strategy <p>sort_flags => use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
| 5287 | * <strong>SORT_NATURAL</strong></p> |
||
| 5288 | * @param bool $keepKeys |
||
| 5289 | * |
||
| 5290 | * @return static |
||
| 5291 | * <p>(Immutable) Return this Arrayy object.</p> |
||
| 5292 | * |
||
| 5293 | * @psalm-return static<TKey,T> |
||
| 5294 | */ |
||
| 5295 | 12 | public function sortImmutable( |
|
| 5311 | |||
| 5312 | /** |
||
| 5313 | * Sort the current array by key. |
||
| 5314 | * |
||
| 5315 | * @see http://php.net/manual/en/function.ksort.php |
||
| 5316 | * @see http://php.net/manual/en/function.krsort.php |
||
| 5317 | * |
||
| 5318 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
| 5319 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
| 5320 | * <strong>SORT_NATURAL</strong></p> |
||
| 5321 | * |
||
| 5322 | * @return $this |
||
| 5323 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 5324 | * |
||
| 5325 | * @psalm-return static<TKey,T> |
||
| 5326 | */ |
||
| 5327 | 18 | public function sortKeys( |
|
| 5337 | |||
| 5338 | /** |
||
| 5339 | * Sort the current array by key. |
||
| 5340 | * |
||
| 5341 | * @see http://php.net/manual/en/function.ksort.php |
||
| 5342 | * @see http://php.net/manual/en/function.krsort.php |
||
| 5343 | * |
||
| 5344 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
| 5345 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
| 5346 | * <strong>SORT_NATURAL</strong></p> |
||
| 5347 | * |
||
| 5348 | * @return $this |
||
| 5349 | * <p>(Immutable) Return this Arrayy object.</p> |
||
| 5350 | * |
||
| 5351 | * @psalm-return static<TKey,T> |
||
| 5352 | * @psalm-mutation-free |
||
| 5353 | */ |
||
| 5354 | 8 | public function sortKeysImmutable( |
|
| 5367 | |||
| 5368 | /** |
||
| 5369 | * Sort the current array by value. |
||
| 5370 | * |
||
| 5371 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
| 5372 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
| 5373 | * <strong>SORT_NATURAL</strong></p> |
||
| 5374 | * |
||
| 5375 | * @return static |
||
| 5376 | * <p>(Mutable)</p> |
||
| 5377 | * |
||
| 5378 | * @psalm-return static<TKey,T> |
||
| 5379 | */ |
||
| 5380 | 1 | public function sortValueKeepIndex( |
|
| 5386 | |||
| 5387 | /** |
||
| 5388 | * Sort the current array by value. |
||
| 5389 | * |
||
| 5390 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
| 5391 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
| 5392 | * <strong>SORT_NATURAL</strong></p> |
||
| 5393 | * |
||
| 5394 | * @return static |
||
| 5395 | * <p>(Mutable)</p> |
||
| 5396 | * |
||
| 5397 | * @psalm-return static<TKey,T> |
||
| 5398 | */ |
||
| 5399 | 1 | public function sortValueNewIndex($direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
| 5403 | |||
| 5404 | /** |
||
| 5405 | * Sort a array by value, by a closure or by a property. |
||
| 5406 | * |
||
| 5407 | * - If the sorter is null, the array is sorted naturally. |
||
| 5408 | * - Associative (string) keys will be maintained, but numeric keys will be re-indexed. |
||
| 5409 | * |
||
| 5410 | * @param callable|string|null $sorter |
||
| 5411 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or |
||
| 5412 | * <strong>SORT_DESC</strong></p> |
||
| 5413 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
| 5414 | * <strong>SORT_NATURAL</strong></p> |
||
| 5415 | * |
||
| 5416 | * @return static |
||
| 5417 | * <p>(Immutable)</p> |
||
| 5418 | * |
||
| 5419 | * @psalm-return static<TKey,T> |
||
| 5420 | * @psalm-mutation-free |
||
| 5421 | */ |
||
| 5422 | 1 | public function sorter($sorter = null, $direction = \SORT_ASC, int $strategy = \SORT_REGULAR): self |
|
| 5463 | |||
| 5464 | /** |
||
| 5465 | * @param int $offset |
||
| 5466 | * @param int|null $length |
||
| 5467 | * @param array $replacement |
||
| 5468 | * |
||
| 5469 | * @return static |
||
| 5470 | * <p>(Immutable)</p> |
||
| 5471 | * |
||
| 5472 | * @psalm-param array<mixed,mixed>|array<mixed,T> $replacement |
||
| 5473 | * @psalm-return static<TKey,T> |
||
| 5474 | * @psalm-mutation-free |
||
| 5475 | */ |
||
| 5476 | 1 | public function splice(int $offset, int $length = null, $replacement = []): self |
|
| 5493 | |||
| 5494 | /** |
||
| 5495 | * Split an array in the given amount of pieces. |
||
| 5496 | * |
||
| 5497 | * @param int $numberOfPieces |
||
| 5498 | * @param bool $keepKeys |
||
| 5499 | * |
||
| 5500 | * @return static |
||
| 5501 | * <p>(Immutable)</p> |
||
| 5502 | * |
||
| 5503 | * @psalm-return static<TKey,T> |
||
| 5504 | * @psalm-mutation-free |
||
| 5505 | */ |
||
| 5506 | 1 | public function split(int $numberOfPieces = 2, bool $keepKeys = false): self |
|
| 5525 | |||
| 5526 | /** |
||
| 5527 | * Stripe all empty items. |
||
| 5528 | * |
||
| 5529 | * @return static |
||
| 5530 | * <p>(Immutable)</p> |
||
| 5531 | * |
||
| 5532 | * @psalm-return static<TKey,T> |
||
| 5533 | * @psalm-mutation-free |
||
| 5534 | */ |
||
| 5535 | 1 | public function stripEmpty(): self |
|
| 5547 | |||
| 5548 | /** |
||
| 5549 | * Swap two values between positions by key. |
||
| 5550 | * |
||
| 5551 | * @param int|string $swapA <p>a key in the array</p> |
||
| 5552 | * @param int|string $swapB <p>a key in the array</p> |
||
| 5553 | * |
||
| 5554 | * @return static |
||
| 5555 | * <p>(Immutable)</p> |
||
| 5556 | * |
||
| 5557 | * @psalm-return static<TKey,T> |
||
| 5558 | * @psalm-mutation-free |
||
| 5559 | */ |
||
| 5560 | 1 | public function swap($swapA, $swapB): self |
|
| 5572 | |||
| 5573 | /** |
||
| 5574 | * Get the current array from the "Arrayy"-object. |
||
| 5575 | * alias for "getArray()" |
||
| 5576 | * |
||
| 5577 | * @param bool $convertAllArrayyElements <p> |
||
| 5578 | * Convert all Child-"Arrayy" objects also to arrays. |
||
| 5579 | * </p> |
||
| 5580 | * @param bool $preserveKeys <p> |
||
| 5581 | * e.g.: A generator maybe return the same key more then once, |
||
| 5582 | * so maybe you will ignore the keys. |
||
| 5583 | * </p> |
||
| 5584 | * |
||
| 5585 | * @return array |
||
| 5586 | * |
||
| 5587 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
| 5588 | * @psalm-mutation-free |
||
| 5589 | */ |
||
| 5590 | 929 | public function toArray( |
|
| 5615 | |||
| 5616 | /** |
||
| 5617 | * Get the current array from the "Arrayy"-object as list. |
||
| 5618 | * |
||
| 5619 | * @param bool $convertAllArrayyElements <p> |
||
| 5620 | * Convert all Child-"Arrayy" objects also to arrays. |
||
| 5621 | * </p> |
||
| 5622 | * |
||
| 5623 | * @return array |
||
| 5624 | * |
||
| 5625 | * @psalm-return array<int,mixed>|array<int,T> |
||
| 5626 | * @psalm-mutation-free |
||
| 5627 | */ |
||
| 5628 | 1 | public function toList(bool $convertAllArrayyElements = false): array |
|
| 5635 | |||
| 5636 | /** |
||
| 5637 | * Convert the current array to JSON. |
||
| 5638 | * |
||
| 5639 | * @param int $options [optional] <p>e.g. JSON_PRETTY_PRINT</p> |
||
| 5640 | * @param int $depth [optional] <p>Set the maximum depth. Must be greater than zero.</p> |
||
| 5641 | * |
||
| 5642 | * @return string |
||
| 5643 | */ |
||
| 5644 | 11 | public function toJson(int $options = 0, int $depth = 512): string |
|
| 5653 | |||
| 5654 | /** |
||
| 5655 | * @param string[]|null $items [optional] |
||
| 5656 | * @param string[] $helper [optional] |
||
| 5657 | * |
||
| 5658 | * @return static|static[] |
||
| 5659 | * |
||
| 5660 | * @psalm-return static<int, static<TKey,T>> |
||
| 5661 | */ |
||
| 5662 | 1 | public function toPermutation(array $items = null, array $helper = []): self |
|
| 5696 | |||
| 5697 | /** |
||
| 5698 | * Implodes array to a string with specified separator. |
||
| 5699 | * |
||
| 5700 | * @param string $separator [optional] <p>The element's separator.</p> |
||
| 5701 | * |
||
| 5702 | * @return string |
||
| 5703 | * <p>The string representation of array, separated by ",".</p> |
||
| 5704 | */ |
||
| 5705 | 19 | public function toString(string $separator = ','): string |
|
| 5709 | |||
| 5710 | /** |
||
| 5711 | * Return a duplicate free copy of the current array. |
||
| 5712 | * |
||
| 5713 | * @return $this |
||
| 5714 | * <p>(Mutable)</p> |
||
| 5715 | * |
||
| 5716 | * @psalm-return static<TKey,T> |
||
| 5717 | */ |
||
| 5718 | 13 | public function unique(): self |
|
| 5740 | |||
| 5741 | /** |
||
| 5742 | * Return a duplicate free copy of the current array. (with the old keys) |
||
| 5743 | * |
||
| 5744 | * @return $this |
||
| 5745 | * <p>(Mutable)</p> |
||
| 5746 | * |
||
| 5747 | * @psalm-return static<TKey,T> |
||
| 5748 | */ |
||
| 5749 | 11 | public function uniqueKeepIndex(): self |
|
| 5775 | |||
| 5776 | /** |
||
| 5777 | * alias: for "Arrayy->unique()" |
||
| 5778 | * |
||
| 5779 | * @return static |
||
| 5780 | * <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
| 5781 | * |
||
| 5782 | * @see Arrayy::unique() |
||
| 5783 | * |
||
| 5784 | * @psalm-return static<TKey,T> |
||
| 5785 | */ |
||
| 5786 | 10 | public function uniqueNewIndex(): self |
|
| 5790 | |||
| 5791 | /** |
||
| 5792 | * Prepends one or more values to the beginning of array at once. |
||
| 5793 | * |
||
| 5794 | * @param array ...$args |
||
| 5795 | * |
||
| 5796 | * @return $this |
||
| 5797 | * <p>(Mutable) Return this Arrayy object, with prepended elements to the beginning of array.</p> |
||
| 5798 | * |
||
| 5799 | * @psalm-param array<mixed,mixed>|array<TKey,T> ...$args |
||
| 5800 | * @psalm-return static<TKey,T> |
||
| 5801 | */ |
||
| 5802 | 4 | public function unshift(...$args): self |
|
| 5810 | |||
| 5811 | /** |
||
| 5812 | * Tests whether the given closure return something valid for all elements of this array. |
||
| 5813 | * |
||
| 5814 | * @param \Closure $closure the predicate |
||
| 5815 | * |
||
| 5816 | * @return bool |
||
| 5817 | * <p>TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.</p> |
||
| 5818 | */ |
||
| 5819 | 1 | View Code Duplication | public function validate(\Closure $closure): bool |
| 5829 | |||
| 5830 | /** |
||
| 5831 | * Get all values from a array. |
||
| 5832 | * |
||
| 5833 | * @return static |
||
| 5834 | * <p>(Immutable)</p> |
||
| 5835 | * |
||
| 5836 | * @psalm-return static<TKey,T> |
||
| 5837 | * @psalm-mutation-free |
||
| 5838 | */ |
||
| 5839 | 2 | public function values(): self |
|
| 5852 | |||
| 5853 | /** |
||
| 5854 | * Apply the given function to every element in the array, discarding the results. |
||
| 5855 | * |
||
| 5856 | * @param callable $callable |
||
| 5857 | * @param bool $recursive <p>Whether array will be walked recursively or no</p> |
||
| 5858 | * |
||
| 5859 | * @return $this |
||
| 5860 | * <p>(Mutable) Return this Arrayy object, with modified elements.</p> |
||
| 5861 | * |
||
| 5862 | * @psalm-return static<TKey,T> |
||
| 5863 | */ |
||
| 5864 | 12 | public function walk($callable, bool $recursive = false): self |
|
| 5878 | |||
| 5879 | /** |
||
| 5880 | * Returns a collection of matching items. |
||
| 5881 | * |
||
| 5882 | * @param string $keyOrPropertyOrMethod the property or method to evaluate |
||
| 5883 | * @param mixed $value the value to match |
||
| 5884 | * |
||
| 5885 | * @throws \InvalidArgumentException if property or method is not defined |
||
| 5886 | * |
||
| 5887 | * @return static |
||
| 5888 | * |
||
| 5889 | * @psalm-param T $value |
||
| 5890 | * @psalm-return static<TKey,T> |
||
| 5891 | */ |
||
| 5892 | 1 | public function where(string $keyOrPropertyOrMethod, $value): self |
|
| 5905 | |||
| 5906 | /** |
||
| 5907 | * Convert an array into a object. |
||
| 5908 | * |
||
| 5909 | * @param array $array |
||
| 5910 | * |
||
| 5911 | * @return \stdClass |
||
| 5912 | * |
||
| 5913 | * @psalm-param array<mixed,mixed> $array |
||
| 5914 | */ |
||
| 5915 | 4 | final protected static function arrayToObject(array $array = []): \stdClass |
|
| 5934 | |||
| 5935 | /** |
||
| 5936 | * @param array|\Generator|null $input <p> |
||
| 5937 | * An array containing keys to return. |
||
| 5938 | * </p> |
||
| 5939 | * @param mixed|null $search_values [optional] <p> |
||
| 5940 | * If specified, then only keys containing these values are returned. |
||
| 5941 | * </p> |
||
| 5942 | * @param bool $strict [optional] <p> |
||
| 5943 | * Determines if strict comparison (===) should be used during the |
||
| 5944 | * search. |
||
| 5945 | * </p> |
||
| 5946 | * |
||
| 5947 | * @return array |
||
| 5948 | * <p>an array of all the keys in input</p> |
||
| 5949 | * |
||
| 5950 | * @psalm-param array<mixed,mixed>|\Generator<TKey,T>|null $input |
||
| 5951 | * @psalm-return array<TKey|mixed> |
||
| 5952 | * @psalm-mutation-free |
||
| 5953 | */ |
||
| 5954 | 11 | protected function array_keys_recursive( |
|
| 6015 | |||
| 6016 | /** |
||
| 6017 | * @param mixed $path |
||
| 6018 | * @param callable $callable |
||
| 6019 | * @param array|null $currentOffset |
||
| 6020 | * |
||
| 6021 | * @return void |
||
| 6022 | * |
||
| 6023 | * @psalm-param array<mixed,mixed>|array<TKey,T>|null $currentOffset |
||
| 6024 | * @psalm-mutation-free |
||
| 6025 | */ |
||
| 6026 | 10 | protected function callAtPath($path, $callable, &$currentOffset = null) |
|
| 6055 | |||
| 6056 | /** |
||
| 6057 | * Extracts the value of the given property or method from the object. |
||
| 6058 | * |
||
| 6059 | * @param static $object <p>The object to extract the value from.</p> |
||
| 6060 | * @param string $keyOrPropertyOrMethod <p>The property or method for which the |
||
| 6061 | * value should be extracted.</p> |
||
| 6062 | * |
||
| 6063 | * @throws \InvalidArgumentException if the method or property is not defined |
||
| 6064 | * |
||
| 6065 | * @return mixed |
||
| 6066 | * <p>The value extracted from the specified property or method.</p> |
||
| 6067 | * |
||
| 6068 | * @psalm-param self<TKey,T> $object |
||
| 6069 | */ |
||
| 6070 | 2 | final protected function extractValue(self $object, string $keyOrPropertyOrMethod) |
|
| 6092 | |||
| 6093 | /** |
||
| 6094 | * create a fallback for array |
||
| 6095 | * |
||
| 6096 | * 1. use the current array, if it's a array |
||
| 6097 | * 2. fallback to empty array, if there is nothing |
||
| 6098 | * 3. call "getArray()" on object, if there is a "Arrayy"-object |
||
| 6099 | * 4. call "createFromObject()" on object, if there is a "\Traversable"-object |
||
| 6100 | * 5. call "__toArray()" on object, if the method exists |
||
| 6101 | * 6. cast a string or object with "__toString()" into an array |
||
| 6102 | * 7. throw a "InvalidArgumentException"-Exception |
||
| 6103 | * |
||
| 6104 | * @param mixed $data |
||
| 6105 | * |
||
| 6106 | * @throws \InvalidArgumentException |
||
| 6107 | * |
||
| 6108 | * @return array |
||
| 6109 | * |
||
| 6110 | * @psalm-return array<mixed,mixed>|array<TKey,T> |
||
| 6111 | */ |
||
| 6112 | 1167 | protected function fallbackForArray(&$data): array |
|
| 6122 | |||
| 6123 | /** |
||
| 6124 | * @param bool $preserveKeys <p> |
||
| 6125 | * e.g.: A generator maybe return the same key more then once, |
||
| 6126 | * so maybe you will ignore the keys. |
||
| 6127 | * </p> |
||
| 6128 | * |
||
| 6129 | * @return bool |
||
| 6130 | * |
||
| 6131 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
| 6132 | * @psalm-mutation-free :/ |
||
| 6133 | */ |
||
| 6134 | 1079 | protected function generatorToArray(bool $preserveKeys = true) |
|
| 6145 | |||
| 6146 | /** |
||
| 6147 | * Get correct PHP constant for direction. |
||
| 6148 | * |
||
| 6149 | * @param int|string $direction |
||
| 6150 | * |
||
| 6151 | * @return int |
||
| 6152 | * @psalm-mutation-free |
||
| 6153 | */ |
||
| 6154 | 43 | protected function getDirection($direction): int |
|
| 6176 | |||
| 6177 | /** |
||
| 6178 | * @return TypeCheckPhpDoc[] |
||
| 6179 | * |
||
| 6180 | * @noinspection ReturnTypeCanBeDeclaredInspection |
||
| 6181 | */ |
||
| 6182 | 16 | protected function getPropertiesFromPhpDoc() |
|
| 6207 | |||
| 6208 | /** |
||
| 6209 | * @param mixed $glue |
||
| 6210 | * @param mixed $pieces |
||
| 6211 | * @param bool $useKeys |
||
| 6212 | * |
||
| 6213 | * @return string |
||
| 6214 | * @psalm-mutation-free |
||
| 6215 | */ |
||
| 6216 | 36 | protected function implode_recursive( |
|
| 6249 | |||
| 6250 | /** |
||
| 6251 | * @param mixed $needle <p> |
||
| 6252 | * The searched value. |
||
| 6253 | * </p> |
||
| 6254 | * <p> |
||
| 6255 | * If needle is a string, the comparison is done |
||
| 6256 | * in a case-sensitive manner. |
||
| 6257 | * </p> |
||
| 6258 | * @param array|\Generator|null $haystack <p> |
||
| 6259 | * The array. |
||
| 6260 | * </p> |
||
| 6261 | * @param bool $strict [optional] <p> |
||
| 6262 | * If the third parameter strict is set to true |
||
| 6263 | * then the in_array function will also check the |
||
| 6264 | * types of the |
||
| 6265 | * needle in the haystack. |
||
| 6266 | * </p> |
||
| 6267 | * |
||
| 6268 | * @return bool |
||
| 6269 | * <p>true if needle is found in the array, false otherwise</p> |
||
| 6270 | * |
||
| 6271 | * @psalm-param array<mixed,mixed>|\Generator<TKey,T>|null $haystack |
||
| 6272 | * @psalm-mutation-free |
||
| 6273 | */ |
||
| 6274 | 18 | protected function in_array_recursive($needle, $haystack = null, $strict = true): bool |
|
| 6299 | |||
| 6300 | /** |
||
| 6301 | * @param mixed $data |
||
| 6302 | * |
||
| 6303 | * @return array|null |
||
| 6304 | * |
||
| 6305 | * @psalm-return array<mixed,mixed>|array<TKey,T>|null |
||
| 6306 | */ |
||
| 6307 | 1167 | protected function internalGetArray(&$data) |
|
| 6358 | |||
| 6359 | /** |
||
| 6360 | * Internal mechanics of remove method. |
||
| 6361 | * |
||
| 6362 | * @param mixed $key |
||
| 6363 | * |
||
| 6364 | * @return bool |
||
| 6365 | */ |
||
| 6366 | 21 | protected function internalRemove($key): bool |
|
| 6399 | |||
| 6400 | /** |
||
| 6401 | * Internal mechanic of set method. |
||
| 6402 | * |
||
| 6403 | * @param int|string|null $key |
||
| 6404 | * @param mixed $value |
||
| 6405 | * @param bool $checkProperties |
||
| 6406 | * |
||
| 6407 | * @return bool |
||
| 6408 | */ |
||
| 6409 | 1018 | protected function internalSet( |
|
| 6462 | |||
| 6463 | /** |
||
| 6464 | * Convert a object into an array. |
||
| 6465 | * |
||
| 6466 | * @param mixed|object $object |
||
| 6467 | * |
||
| 6468 | * @return array|mixed |
||
| 6469 | * |
||
| 6470 | * @psalm-mutation-free |
||
| 6471 | */ |
||
| 6472 | 5 | protected static function objectToArray($object) |
|
| 6485 | |||
| 6486 | /** |
||
| 6487 | * @param array $data |
||
| 6488 | * @param bool $checkPropertiesInConstructor |
||
| 6489 | * |
||
| 6490 | * @return void |
||
| 6491 | * |
||
| 6492 | * @psalm-param array<mixed,T> $data |
||
| 6493 | */ |
||
| 6494 | 1165 | protected function setInitialValuesAndProperties(array &$data, bool $checkPropertiesInConstructor) |
|
| 6539 | |||
| 6540 | /** |
||
| 6541 | * sorting keys |
||
| 6542 | * |
||
| 6543 | * @param array $elements |
||
| 6544 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
| 6545 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
| 6546 | * <strong>SORT_NATURAL</strong></p> |
||
| 6547 | * |
||
| 6548 | * @return $this |
||
| 6549 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 6550 | * |
||
| 6551 | * @psalm-param array<mixed,mixed>|array<mixed|TKey,T> $elements |
||
| 6552 | * @psalm-return static<TKey,T> |
||
| 6553 | */ |
||
| 6554 | 18 | protected function sorterKeys( |
|
| 6575 | |||
| 6576 | /** |
||
| 6577 | * @param array $elements <p>Warning: used as reference</p> |
||
| 6578 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
| 6579 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
| 6580 | * <strong>SORT_NATURAL</strong></p> |
||
| 6581 | * @param bool $keepKeys |
||
| 6582 | * |
||
| 6583 | * @return $this |
||
| 6584 | * <p>(Mutable) Return this Arrayy object.</p> |
||
| 6585 | * |
||
| 6586 | * @psalm-param array<mixed,mixed>|array<mixed|TKey,T> $elements |
||
| 6587 | * @psalm-return static<TKey,T> |
||
| 6588 | */ |
||
| 6589 | 24 | protected function sorting(array &$elements, $direction = \SORT_ASC, int $strategy = \SORT_REGULAR, bool $keepKeys = false): self |
|
| 6619 | |||
| 6620 | /** |
||
| 6621 | * @param array $array |
||
| 6622 | * |
||
| 6623 | * @return array |
||
| 6624 | * |
||
| 6625 | * @psalm-mutation-free |
||
| 6626 | */ |
||
| 6627 | 25 | private function getArrayRecursiveHelperArrayy(array $array) |
|
| 6649 | |||
| 6650 | /** |
||
| 6651 | * @param int|string|null $key |
||
| 6652 | * @param mixed $value |
||
| 6653 | * |
||
| 6654 | * @return void |
||
| 6655 | */ |
||
| 6656 | 87 | private function checkType($key, $value) |
|
| 6674 | } |
||
| 6675 |
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..