| @@ 3146-3169 (lines=24) @@ | ||
| 3143 | * @psalm-return static<TKey,T> |
|
| 3144 | * @psalm-mutation-free |
|
| 3145 | */ |
|
| 3146 | public function invoke($callable, $arguments = []): self |
|
| 3147 | { |
|
| 3148 | // If one argument given for each iteration, create an array for it. |
|
| 3149 | if (\is_array($arguments) === false) { |
|
| 3150 | $arguments = \array_fill( |
|
| 3151 | 0, |
|
| 3152 | $this->count(), |
|
| 3153 | $arguments |
|
| 3154 | ); |
|
| 3155 | } |
|
| 3156 | ||
| 3157 | // If the callable has arguments, pass them. |
|
| 3158 | if ($arguments) { |
|
| 3159 | $array = \array_map($callable, $this->toArray(), $arguments); |
|
| 3160 | } else { |
|
| 3161 | $array = $this->map($callable); |
|
| 3162 | } |
|
| 3163 | ||
| 3164 | return static::create( |
|
| 3165 | $array, |
|
| 3166 | $this->iteratorClass, |
|
| 3167 | false |
|
| 3168 | ); |
|
| 3169 | } |
|
| 3170 | ||
| 3171 | /** |
|
| 3172 | * Check whether array is associative or not. |
|
| @@ 3741-3755 (lines=15) @@ | ||
| 3738 | * @psalm-return static<int|TKey,T> |
|
| 3739 | * @psalm-mutation-free |
|
| 3740 | */ |
|
| 3741 | public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self |
|
| 3742 | { |
|
| 3743 | if ($recursive === true) { |
|
| 3744 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
| 3745 | $result = \array_replace_recursive($this->toArray(), $array); |
|
| 3746 | } else { |
|
| 3747 | $result = \array_replace($this->toArray(), $array); |
|
| 3748 | } |
|
| 3749 | ||
| 3750 | return static::create( |
|
| 3751 | $result, |
|
| 3752 | $this->iteratorClass, |
|
| 3753 | false |
|
| 3754 | ); |
|
| 3755 | } |
|
| 3756 | ||
| 3757 | /** |
|
| 3758 | * Merge the new $array into the current array. |
|
| @@ 3773-3787 (lines=15) @@ | ||
| 3770 | * @psalm-return static<TKey,T> |
|
| 3771 | * @psalm-mutation-free |
|
| 3772 | */ |
|
| 3773 | public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self |
|
| 3774 | { |
|
| 3775 | if ($recursive === true) { |
|
| 3776 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
| 3777 | $result = \array_merge_recursive($this->toArray(), $array); |
|
| 3778 | } else { |
|
| 3779 | $result = \array_merge($this->toArray(), $array); |
|
| 3780 | } |
|
| 3781 | ||
| 3782 | return static::create( |
|
| 3783 | $result, |
|
| 3784 | $this->iteratorClass, |
|
| 3785 | false |
|
| 3786 | ); |
|
| 3787 | } |
|
| 3788 | ||
| 3789 | /** |
|
| 3790 | * Merge the the current array into the $array. |
|
| @@ 3804-3818 (lines=15) @@ | ||
| 3801 | * @psalm-return static<TKey,T> |
|
| 3802 | * @psalm-mutation-free |
|
| 3803 | */ |
|
| 3804 | public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self |
|
| 3805 | { |
|
| 3806 | if ($recursive === true) { |
|
| 3807 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
| 3808 | $result = \array_replace_recursive($array, $this->toArray()); |
|
| 3809 | } else { |
|
| 3810 | $result = \array_replace($array, $this->toArray()); |
|
| 3811 | } |
|
| 3812 | ||
| 3813 | return static::create( |
|
| 3814 | $result, |
|
| 3815 | $this->iteratorClass, |
|
| 3816 | false |
|
| 3817 | ); |
|
| 3818 | } |
|
| 3819 | ||
| 3820 | /** |
|
| 3821 | * Merge the current array into the new $array. |
|
| @@ 3836-3850 (lines=15) @@ | ||
| 3833 | * @psalm-return static<TKey,T> |
|
| 3834 | * @psalm-mutation-free |
|
| 3835 | */ |
|
| 3836 | public function mergePrependNewIndex(array $array = [], bool $recursive = false): self |
|
| 3837 | { |
|
| 3838 | if ($recursive === true) { |
|
| 3839 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
| 3840 | $result = \array_merge_recursive($array, $this->toArray()); |
|
| 3841 | } else { |
|
| 3842 | $result = \array_merge($array, $this->toArray()); |
|
| 3843 | } |
|
| 3844 | ||
| 3845 | return static::create( |
|
| 3846 | $result, |
|
| 3847 | $this->iteratorClass, |
|
| 3848 | false |
|
| 3849 | ); |
|
| 3850 | } |
|
| 3851 | ||
| 3852 | /** |
|
| 3853 | * @return ArrayyMeta|static |
|