public function withPort(int $port = null): Uri
    {
        if ($port === $this->port) {
            return clone $this;
        }

        $this->validatePort($port);

        $new = clone $this;

        $new->port = $port;

        return $new;
    }
public function withPort(int $port = null): Uri
    {
        if ($port === $this->port) {
            return clone $this;
        }

        $this->validatePort($port);

        $new = clone $this;

        $new->port = $port;

        return $new;
    }
public function withPort ( int $ port = null ) : Uri { if ( $ port === $ this -> port ) { return clone $ this ; } $ this -> validatePort ( $ port ) ; $ new = clone $ this ; $ new -> port = $ port ; return $ new ; }
Return an instance with the specified port.

This method MUST retain the state of the current instance, and return
an instance that contains the specified port.

Implementations MUST raise an exception for ports outside the
established TCP and UDP port ranges.

A null value provided for the port is equivalent to removing the port
information.

@param null|int $port The port to use with the new instance; a null value
removes the port information.

@throws \Valkyrja\HttpMessage\Exceptions\InvalidPort for invalid ports.

@return static A new instance with the specified port.
Return an instance with the specified port .