src/MemorySink.php
public function seek(int $offset, int $whence = SEEK_SET, float $timeout = 0): \Generator
    {
        if (!$this->isOpen()) {
            throw new UnseekableException('The stream is no longer seekable.');
        }

        $offset = (int) $offset;

        switch ($whence) {
            case SEEK_SET:
                break;

            case SEEK_CUR:
                $offset += $this->tell();
                break;

            case SEEK_END:
                $offset += $this->getLength();
                break;

            default:
                throw new InvalidArgumentError('Invalid value for whence. Use SEEK_SET, SEEK_CUR, or SEEK_END.');
        }

        if (0 > $offset || $this->buffer->getLength() < $offset) {
            throw new OutOfBoundsException(sprintf('Invalid offset: %s.', $offset));
        }

        $this->iterator->seek($offset);

        return $offset;

        yield; // Unreachable, but makes the method a coroutine.
    }
public function seek(int $offset, int $whence = SEEK_SET, float $timeout = 0): \Generator
    {
        if (!$this->isOpen()) {
            throw new UnseekableException('The stream is no longer seekable.');
        }

        $offset = (int) $offset;

        switch ($whence) {
            case SEEK_SET:
                break;

            case SEEK_CUR:
                $offset += $this->tell();
                break;

            case SEEK_END:
                $offset += $this->getLength();
                break;

            default:
                throw new InvalidArgumentError('Invalid value for whence. Use SEEK_SET, SEEK_CUR, or SEEK_END.');
        }

        if (0 > $offset || $this->buffer->getLength() < $offset) {
            throw new OutOfBoundsException(sprintf('Invalid offset: %s.', $offset));
        }

        $this->iterator->seek($offset);

        return $offset;

        yield; // Unreachable, but makes the method a coroutine.
    }
{@inheritdoc}