src/Collection/ArrayCollection.php
public function splice(int $offset, ?int $length = null, array $replacement = []): ArrayCollection
    {
        if ($length === null && empty($replacement)) {
            return new static(array_splice($this->items, $offset));
        }

        if ($length === null) {
            $length = $this->count();
        }

        return new static(array_splice($this->items, $offset, $length, $replacement));
    }
public function splice(int $offset, ?int $length = null, array $replacement = []): ArrayCollection
    {
        if ($length === null && empty($replacement)) {
            return new static(array_splice($this->items, $offset));
        }

        if ($length === null) {
            $length = $this->count();
        }

        return new static(array_splice($this->items, $offset, $length, $replacement));
    }
public function splice ( int $ offset , ? int $ length = null , array $ replacement = [ ] ) : ArrayCollection { if ( $ length === null && empty ( $ replacement ) ) { return new static ( array_splice ( $ this -> items , $ offset ) ) ; } if ( $ length === null ) { $ length = $ this -> count ( ) ; } return new static ( array_splice ( $ this -> items , $ offset , $ length , $ replacement ) ) ; }
Removes and returns a portion of the collection

Replacement items will replace removed items in the collection.

@param int      $offset      The starting offset
@param int|null $length      The length or null for remaining
@param array    $replacement The replacement items

@return ArrayCollection
Removes and returns a portion of the collection