| @@ 3320-3343 (lines=24) @@ | ||
| 3317 | * @psalm-return static<TKey,T> |
|
| 3318 | * @psalm-mutation-free |
|
| 3319 | */ |
|
| 3320 | public function invoke($callable, $arguments = []): self |
|
| 3321 | { |
|
| 3322 | // If one argument given for each iteration, create an array for it. |
|
| 3323 | if (\is_array($arguments) === false) { |
|
| 3324 | $arguments = \array_fill( |
|
| 3325 | 0, |
|
| 3326 | $this->count(), |
|
| 3327 | $arguments |
|
| 3328 | ); |
|
| 3329 | } |
|
| 3330 | ||
| 3331 | // If the callable has arguments, pass them. |
|
| 3332 | if ($arguments) { |
|
| 3333 | $array = \array_map($callable, $this->toArray(), $arguments); |
|
| 3334 | } else { |
|
| 3335 | $array = $this->map($callable); |
|
| 3336 | } |
|
| 3337 | ||
| 3338 | return static::create( |
|
| 3339 | $array, |
|
| 3340 | $this->iteratorClass, |
|
| 3341 | false |
|
| 3342 | ); |
|
| 3343 | } |
|
| 3344 | ||
| 3345 | /** |
|
| 3346 | * Check whether array is associative or not. |
|
| @@ 3917-3931 (lines=15) @@ | ||
| 3914 | * @psalm-return static<int|TKey,T> |
|
| 3915 | * @psalm-mutation-free |
|
| 3916 | */ |
|
| 3917 | public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self |
|
| 3918 | { |
|
| 3919 | if ($recursive === true) { |
|
| 3920 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
| 3921 | $result = \array_replace_recursive($this->toArray(), $array); |
|
| 3922 | } else { |
|
| 3923 | $result = \array_replace($this->toArray(), $array); |
|
| 3924 | } |
|
| 3925 | ||
| 3926 | return static::create( |
|
| 3927 | $result, |
|
| 3928 | $this->iteratorClass, |
|
| 3929 | false |
|
| 3930 | ); |
|
| 3931 | } |
|
| 3932 | ||
| 3933 | /** |
|
| 3934 | * Merge the new $array into the current array. |
|
| @@ 3949-3963 (lines=15) @@ | ||
| 3946 | * @psalm-return static<TKey,T> |
|
| 3947 | * @psalm-mutation-free |
|
| 3948 | */ |
|
| 3949 | public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self |
|
| 3950 | { |
|
| 3951 | if ($recursive === true) { |
|
| 3952 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
| 3953 | $result = \array_merge_recursive($this->toArray(), $array); |
|
| 3954 | } else { |
|
| 3955 | $result = \array_merge($this->toArray(), $array); |
|
| 3956 | } |
|
| 3957 | ||
| 3958 | return static::create( |
|
| 3959 | $result, |
|
| 3960 | $this->iteratorClass, |
|
| 3961 | false |
|
| 3962 | ); |
|
| 3963 | } |
|
| 3964 | ||
| 3965 | /** |
|
| 3966 | * Merge the the current array into the $array. |
|
| @@ 3980-3994 (lines=15) @@ | ||
| 3977 | * @psalm-return static<TKey,T> |
|
| 3978 | * @psalm-mutation-free |
|
| 3979 | */ |
|
| 3980 | public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self |
|
| 3981 | { |
|
| 3982 | if ($recursive === true) { |
|
| 3983 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
| 3984 | $result = \array_replace_recursive($array, $this->toArray()); |
|
| 3985 | } else { |
|
| 3986 | $result = \array_replace($array, $this->toArray()); |
|
| 3987 | } |
|
| 3988 | ||
| 3989 | return static::create( |
|
| 3990 | $result, |
|
| 3991 | $this->iteratorClass, |
|
| 3992 | false |
|
| 3993 | ); |
|
| 3994 | } |
|
| 3995 | ||
| 3996 | /** |
|
| 3997 | * Merge the current array into the new $array. |
|
| @@ 4012-4026 (lines=15) @@ | ||
| 4009 | * @psalm-return static<TKey,T> |
|
| 4010 | * @psalm-mutation-free |
|
| 4011 | */ |
|
| 4012 | public function mergePrependNewIndex(array $array = [], bool $recursive = false): self |
|
| 4013 | { |
|
| 4014 | if ($recursive === true) { |
|
| 4015 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
| 4016 | $result = \array_merge_recursive($array, $this->toArray()); |
|
| 4017 | } else { |
|
| 4018 | $result = \array_merge($array, $this->toArray()); |
|
| 4019 | } |
|
| 4020 | ||
| 4021 | return static::create( |
|
| 4022 | $result, |
|
| 4023 | $this->iteratorClass, |
|
| 4024 | false |
|
| 4025 | ); |
|
| 4026 | } |
|
| 4027 | ||
| 4028 | /** |
|
| 4029 | * @return ArrayyMeta|static |
|