@@ 4701-4716 (lines=16) @@ | ||
4698 | * @phpstan-return static<TKey,T> |
|
4699 | * @psalm-mutation-free |
|
4700 | */ |
|
4701 | public function moveElementToFirstPlace($key): self |
|
4702 | { |
|
4703 | $array = $this->toArray(); |
|
4704 | ||
4705 | if ($this->offsetExists($key)) { |
|
4706 | $tmpValue = $this->get($key); |
|
4707 | unset($array[$key]); |
|
4708 | $array = [$key => $tmpValue] + $array; |
|
4709 | } |
|
4710 | ||
4711 | return static::create( |
|
4712 | $array, |
|
4713 | $this->iteratorClass, |
|
4714 | false |
|
4715 | ); |
|
4716 | } |
|
4717 | ||
4718 | /** |
|
4719 | * Move an array element to the last place. |
|
@@ 4732-4747 (lines=16) @@ | ||
4729 | * @phpstan-return static<TKey,T> |
|
4730 | * @psalm-mutation-free |
|
4731 | */ |
|
4732 | public function moveElementToLastPlace($key): self |
|
4733 | { |
|
4734 | $array = $this->toArray(); |
|
4735 | ||
4736 | if ($this->offsetExists($key)) { |
|
4737 | $tmpValue = $this->get($key); |
|
4738 | unset($array[$key]); |
|
4739 | $array += [$key => $tmpValue]; |
|
4740 | } |
|
4741 | ||
4742 | return static::create( |
|
4743 | $array, |
|
4744 | $this->iteratorClass, |
|
4745 | false |
|
4746 | ); |
|
4747 | } |
|
4748 | ||
4749 | /** |
|
4750 | * Moves the internal iterator position to the next element and returns this element. |