| @@ 3020-3043 (lines=24) @@ | ||
| 3017 | * @psalm-return static<TKey,T> |
|
| 3018 | * @psalm-mutation-free |
|
| 3019 | */ |
|
| 3020 | public function invoke($callable, $arguments = []): self |
|
| 3021 | { |
|
| 3022 | // If one argument given for each iteration, create an array for it. |
|
| 3023 | if (\is_array($arguments) === false) { |
|
| 3024 | $arguments = \array_fill( |
|
| 3025 | 0, |
|
| 3026 | $this->count(), |
|
| 3027 | $arguments |
|
| 3028 | ); |
|
| 3029 | } |
|
| 3030 | ||
| 3031 | // If the callable has arguments, pass them. |
|
| 3032 | if ($arguments) { |
|
| 3033 | $array = \array_map($callable, $this->toArray(), $arguments); |
|
| 3034 | } else { |
|
| 3035 | $array = $this->map($callable); |
|
| 3036 | } |
|
| 3037 | ||
| 3038 | return static::create( |
|
| 3039 | $array, |
|
| 3040 | $this->iteratorClass, |
|
| 3041 | false |
|
| 3042 | ); |
|
| 3043 | } |
|
| 3044 | ||
| 3045 | /** |
|
| 3046 | * Check whether array is associative or not. |
|
| @@ 3615-3629 (lines=15) @@ | ||
| 3612 | * @psalm-return static<int|TKey,T> |
|
| 3613 | * @psalm-mutation-free |
|
| 3614 | */ |
|
| 3615 | public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self |
|
| 3616 | { |
|
| 3617 | if ($recursive === true) { |
|
| 3618 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
| 3619 | $result = \array_replace_recursive($this->toArray(), $array); |
|
| 3620 | } else { |
|
| 3621 | $result = \array_replace($this->toArray(), $array); |
|
| 3622 | } |
|
| 3623 | ||
| 3624 | return static::create( |
|
| 3625 | $result, |
|
| 3626 | $this->iteratorClass, |
|
| 3627 | false |
|
| 3628 | ); |
|
| 3629 | } |
|
| 3630 | ||
| 3631 | /** |
|
| 3632 | * Merge the new $array into the current array. |
|
| @@ 3647-3661 (lines=15) @@ | ||
| 3644 | * @psalm-return static<TKey,T> |
|
| 3645 | * @psalm-mutation-free |
|
| 3646 | */ |
|
| 3647 | public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self |
|
| 3648 | { |
|
| 3649 | if ($recursive === true) { |
|
| 3650 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
| 3651 | $result = \array_merge_recursive($this->toArray(), $array); |
|
| 3652 | } else { |
|
| 3653 | $result = \array_merge($this->toArray(), $array); |
|
| 3654 | } |
|
| 3655 | ||
| 3656 | return static::create( |
|
| 3657 | $result, |
|
| 3658 | $this->iteratorClass, |
|
| 3659 | false |
|
| 3660 | ); |
|
| 3661 | } |
|
| 3662 | ||
| 3663 | /** |
|
| 3664 | * Merge the the current array into the $array. |
|
| @@ 3678-3692 (lines=15) @@ | ||
| 3675 | * @psalm-return static<TKey,T> |
|
| 3676 | * @psalm-mutation-free |
|
| 3677 | */ |
|
| 3678 | public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self |
|
| 3679 | { |
|
| 3680 | if ($recursive === true) { |
|
| 3681 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
| 3682 | $result = \array_replace_recursive($array, $this->toArray()); |
|
| 3683 | } else { |
|
| 3684 | $result = \array_replace($array, $this->toArray()); |
|
| 3685 | } |
|
| 3686 | ||
| 3687 | return static::create( |
|
| 3688 | $result, |
|
| 3689 | $this->iteratorClass, |
|
| 3690 | false |
|
| 3691 | ); |
|
| 3692 | } |
|
| 3693 | ||
| 3694 | /** |
|
| 3695 | * Merge the current array into the new $array. |
|
| @@ 3710-3724 (lines=15) @@ | ||
| 3707 | * @psalm-return static<TKey,T> |
|
| 3708 | * @psalm-mutation-free |
|
| 3709 | */ |
|
| 3710 | public function mergePrependNewIndex(array $array = [], bool $recursive = false): self |
|
| 3711 | { |
|
| 3712 | if ($recursive === true) { |
|
| 3713 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
| 3714 | $result = \array_merge_recursive($array, $this->toArray()); |
|
| 3715 | } else { |
|
| 3716 | $result = \array_merge($array, $this->toArray()); |
|
| 3717 | } |
|
| 3718 | ||
| 3719 | return static::create( |
|
| 3720 | $result, |
|
| 3721 | $this->iteratorClass, |
|
| 3722 | false |
|
| 3723 | ); |
|
| 3724 | } |
|
| 3725 | ||
| 3726 | /** |
|
| 3727 | * @return ArrayyMeta|static |
|