@@ 3063-3086 (lines=24) @@ | ||
3060 | * @psalm-return static<TKey,T> |
|
3061 | * @psalm-mutation-free |
|
3062 | */ |
|
3063 | public function invoke($callable, $arguments = []): self |
|
3064 | { |
|
3065 | // If one argument given for each iteration, create an array for it. |
|
3066 | if (\is_array($arguments) === false) { |
|
3067 | $arguments = \array_fill( |
|
3068 | 0, |
|
3069 | $this->count(), |
|
3070 | $arguments |
|
3071 | ); |
|
3072 | } |
|
3073 | ||
3074 | // If the callable has arguments, pass them. |
|
3075 | if ($arguments) { |
|
3076 | $array = \array_map($callable, $this->toArray(), $arguments); |
|
3077 | } else { |
|
3078 | $array = $this->map($callable); |
|
3079 | } |
|
3080 | ||
3081 | return static::create( |
|
3082 | $array, |
|
3083 | $this->iteratorClass, |
|
3084 | false |
|
3085 | ); |
|
3086 | } |
|
3087 | ||
3088 | /** |
|
3089 | * Check whether array is associative or not. |
|
@@ 3658-3672 (lines=15) @@ | ||
3655 | * @psalm-return static<int|TKey,T> |
|
3656 | * @psalm-mutation-free |
|
3657 | */ |
|
3658 | public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self |
|
3659 | { |
|
3660 | if ($recursive === true) { |
|
3661 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
3662 | $result = \array_replace_recursive($this->toArray(), $array); |
|
3663 | } else { |
|
3664 | $result = \array_replace($this->toArray(), $array); |
|
3665 | } |
|
3666 | ||
3667 | return static::create( |
|
3668 | $result, |
|
3669 | $this->iteratorClass, |
|
3670 | false |
|
3671 | ); |
|
3672 | } |
|
3673 | ||
3674 | /** |
|
3675 | * Merge the new $array into the current array. |
|
@@ 3690-3704 (lines=15) @@ | ||
3687 | * @psalm-return static<TKey,T> |
|
3688 | * @psalm-mutation-free |
|
3689 | */ |
|
3690 | public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self |
|
3691 | { |
|
3692 | if ($recursive === true) { |
|
3693 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
3694 | $result = \array_merge_recursive($this->toArray(), $array); |
|
3695 | } else { |
|
3696 | $result = \array_merge($this->toArray(), $array); |
|
3697 | } |
|
3698 | ||
3699 | return static::create( |
|
3700 | $result, |
|
3701 | $this->iteratorClass, |
|
3702 | false |
|
3703 | ); |
|
3704 | } |
|
3705 | ||
3706 | /** |
|
3707 | * Merge the the current array into the $array. |
|
@@ 3721-3735 (lines=15) @@ | ||
3718 | * @psalm-return static<TKey,T> |
|
3719 | * @psalm-mutation-free |
|
3720 | */ |
|
3721 | public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self |
|
3722 | { |
|
3723 | if ($recursive === true) { |
|
3724 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
3725 | $result = \array_replace_recursive($array, $this->toArray()); |
|
3726 | } else { |
|
3727 | $result = \array_replace($array, $this->toArray()); |
|
3728 | } |
|
3729 | ||
3730 | return static::create( |
|
3731 | $result, |
|
3732 | $this->iteratorClass, |
|
3733 | false |
|
3734 | ); |
|
3735 | } |
|
3736 | ||
3737 | /** |
|
3738 | * Merge the current array into the new $array. |
|
@@ 3753-3767 (lines=15) @@ | ||
3750 | * @psalm-return static<TKey,T> |
|
3751 | * @psalm-mutation-free |
|
3752 | */ |
|
3753 | public function mergePrependNewIndex(array $array = [], bool $recursive = false): self |
|
3754 | { |
|
3755 | if ($recursive === true) { |
|
3756 | $array = $this->getArrayRecursiveHelperArrayy($array); |
|
3757 | $result = \array_merge_recursive($array, $this->toArray()); |
|
3758 | } else { |
|
3759 | $result = \array_merge($array, $this->toArray()); |
|
3760 | } |
|
3761 | ||
3762 | return static::create( |
|
3763 | $result, |
|
3764 | $this->iteratorClass, |
|
3765 | false |
|
3766 | ); |
|
3767 | } |
|
3768 | ||
3769 | /** |
|
3770 | * @return ArrayyMeta|static |