lib/Request.php
public function withProtocolVersions(array $versions): self {
        $versions = \array_unique($versions);

        if (empty($versions)) {
            throw new \Error("Empty array of protocol versions provided, must not be empty.");
        }

        foreach ($versions as $version) {
            if (!\in_array($version, ["1.0", "1.1", "2.0"], true)) {
                throw new \Error(
                    "Invalid HTTP protocol version: " . $version
                );
            }
        }

        if ($this->protocolVersions === $versions) {
            return $this;
        }

        $clone = clone $this;
        $clone->protocolVersions = $versions;

        return $clone;
    }
public function withProtocolVersions(array $versions): self {
        $versions = \array_unique($versions);

        if (empty($versions)) {
            throw new \Error("Empty array of protocol versions provided, must not be empty.");
        }

        foreach ($versions as $version) {
            if (!\in_array($version, ["1.0", "1.1", "2.0"], true)) {
                throw new \Error(
                    "Invalid HTTP protocol version: " . $version
                );
            }
        }

        if ($this->protocolVersions === $versions) {
            return $this;
        }

        $clone = clone $this;
        $clone->protocolVersions = $versions;

        return $clone;
    }
public function withProtocolVersions ( array $ versions ) : self { $ versions = \ array_unique ( $ versions ) ; if ( empty ( $ versions ) ) { throw new \ Error ( "Empty array of protocol versions provided, must not be empty." ) ; } foreach ( $ versions as $ version ) { if ( ! \ in_array ( $ version , [ "1.0" , "1.1" , "2.0" ] , true ) ) { throw new \ Error ( "Invalid HTTP protocol version: " . $ version ) ; } } if ( $ this -> protocolVersions === $ versions ) { return $ this ; } $ clone = clone $ this ; $ clone -> protocolVersions = $ versions ; return $ clone ; }
Assign the requests's acceptable HTTP protocol versions.

The HTTP client might choose any of these.

@param string[] $versions

@return Request
Assign the requests s acceptable HTTP protocol versions .