| @@ 5712-5724 (lines=13) @@ | ||
| 5709 | * @phpstan-return static<TKey,T> |
|
| 5710 | * @psalm-mutation-free |
|
| 5711 | */ |
|
| 5712 | public function replaceAllKeys(array $keys): self |
|
| 5713 | { |
|
| 5714 | $data = \array_combine($keys, $this->toArray()); |
|
| 5715 | if ($data === false) { |
|
| 5716 | $data = []; |
|
| 5717 | } |
|
| 5718 | ||
| 5719 | return static::create( |
|
| 5720 | $data, |
|
| 5721 | $this->iteratorClass, |
|
| 5722 | false |
|
| 5723 | ); |
|
| 5724 | } |
|
| 5725 | ||
| 5726 | /** |
|
| 5727 | * Create an array using the current array as keys and the other array as values. |
|
| @@ 5755-5767 (lines=13) @@ | ||
| 5752 | * @phpstan-return static<TKey,T> |
|
| 5753 | * @psalm-mutation-free |
|
| 5754 | */ |
|
| 5755 | public function replaceAllValues(array $array): self |
|
| 5756 | { |
|
| 5757 | $data = \array_combine($this->toArray(), $array); |
|
| 5758 | if ($data === false) { |
|
| 5759 | $data = []; |
|
| 5760 | } |
|
| 5761 | ||
| 5762 | return static::create( |
|
| 5763 | $data, |
|
| 5764 | $this->iteratorClass, |
|
| 5765 | false |
|
| 5766 | ); |
|
| 5767 | } |
|
| 5768 | ||
| 5769 | /** |
|
| 5770 | * Replace the keys in an array with another set. |
|
| @@ 5785-5798 (lines=14) @@ | ||
| 5782 | * @phpstan-return static<TKey,T> |
|
| 5783 | * @psalm-mutation-free |
|
| 5784 | */ |
|
| 5785 | public function replaceKeys(array $keys): self |
|
| 5786 | { |
|
| 5787 | $values = \array_values($this->toArray()); |
|
| 5788 | $result = \array_combine($keys, $values); |
|
| 5789 | if ($result === false) { |
|
| 5790 | $result = []; |
|
| 5791 | } |
|
| 5792 | ||
| 5793 | return static::create( |
|
| 5794 | $result, |
|
| 5795 | $this->iteratorClass, |
|
| 5796 | false |
|
| 5797 | ); |
|
| 5798 | } |
|
| 5799 | ||
| 5800 | /** |
|
| 5801 | * Replace the first matched value in an array. |
|