@@ 3247-3270 (lines=24) @@ | ||
3244 | * @psalm-return static<TKey,T> |
|
3245 | * @psalm-mutation-free |
|
3246 | */ |
|
3247 | public function invoke($callable, $arguments = []): self |
|
3248 | { |
|
3249 | // If one argument given for each iteration, create an array for it. |
|
3250 | if (\is_array($arguments) === false) { |
|
3251 | $arguments = \array_fill( |
|
3252 | 0, |
|
3253 | $this->count(), |
|
3254 | $arguments |
|
3255 | ); |
|
3256 | } |
|
3257 | ||
3258 | // If the callable has arguments, pass them. |
|
3259 | if ($arguments) { |
|
3260 | $array = \array_map($callable, $this->toArray(), $arguments); |
|
3261 | } else { |
|
3262 | $array = $this->map($callable); |
|
3263 | } |
|
3264 | ||
3265 | return static::create( |
|
3266 | $array, |
|
3267 | $this->iteratorClass, |
|
3268 | false |
|
3269 | ); |
|
3270 | } |
|
3271 | ||
3272 | /** |
|
3273 | * Check whether array is associative or not. |
|
@@ 3844-3858 (lines=15) @@ | ||
3841 | * @psalm-return static<int|TKey,T> |
|
3842 | * @psalm-mutation-free |
|
3843 | */ |
|
3844 | public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self |
|
3845 | { |
|
3846 | if ($recursive === true) { |
|
3847 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
3848 | $result = \array_replace_recursive($this->toArray(), $array); |
|
3849 | } else { |
|
3850 | $result = \array_replace($this->toArray(), $array); |
|
3851 | } |
|
3852 | ||
3853 | return static::create( |
|
3854 | $result, |
|
3855 | $this->iteratorClass, |
|
3856 | false |
|
3857 | ); |
|
3858 | } |
|
3859 | ||
3860 | /** |
|
3861 | * Merge the new $array into the current array. |
|
@@ 3876-3890 (lines=15) @@ | ||
3873 | * @psalm-return static<TKey,T> |
|
3874 | * @psalm-mutation-free |
|
3875 | */ |
|
3876 | public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self |
|
3877 | { |
|
3878 | if ($recursive === true) { |
|
3879 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
3880 | $result = \array_merge_recursive($this->toArray(), $array); |
|
3881 | } else { |
|
3882 | $result = \array_merge($this->toArray(), $array); |
|
3883 | } |
|
3884 | ||
3885 | return static::create( |
|
3886 | $result, |
|
3887 | $this->iteratorClass, |
|
3888 | false |
|
3889 | ); |
|
3890 | } |
|
3891 | ||
3892 | /** |
|
3893 | * Merge the the current array into the $array. |
|
@@ 3907-3921 (lines=15) @@ | ||
3904 | * @psalm-return static<TKey,T> |
|
3905 | * @psalm-mutation-free |
|
3906 | */ |
|
3907 | public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self |
|
3908 | { |
|
3909 | if ($recursive === true) { |
|
3910 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
3911 | $result = \array_replace_recursive($array, $this->toArray()); |
|
3912 | } else { |
|
3913 | $result = \array_replace($array, $this->toArray()); |
|
3914 | } |
|
3915 | ||
3916 | return static::create( |
|
3917 | $result, |
|
3918 | $this->iteratorClass, |
|
3919 | false |
|
3920 | ); |
|
3921 | } |
|
3922 | ||
3923 | /** |
|
3924 | * Merge the current array into the new $array. |
|
@@ 3939-3953 (lines=15) @@ | ||
3936 | * @psalm-return static<TKey,T> |
|
3937 | * @psalm-mutation-free |
|
3938 | */ |
|
3939 | public function mergePrependNewIndex(array $array = [], bool $recursive = false): self |
|
3940 | { |
|
3941 | if ($recursive === true) { |
|
3942 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
3943 | $result = \array_merge_recursive($array, $this->toArray()); |
|
3944 | } else { |
|
3945 | $result = \array_merge($array, $this->toArray()); |
|
3946 | } |
|
3947 | ||
3948 | return static::create( |
|
3949 | $result, |
|
3950 | $this->iteratorClass, |
|
3951 | false |
|
3952 | ); |
|
3953 | } |
|
3954 | ||
3955 | /** |
|
3956 | * @return ArrayyMeta|static |