public function withPort($port = null)
    {
        if ($port !== null && $port < 1 && $port > 65535) {
            throw new InvalidArgumentException(
                'Port must be null or an integer between 1 and 65535'
            );
        }

        $uri = clone $this;
        $uri->port = $port;

        return $uri;
    }
public function withPort($port = null)
    {
        if ($port !== null && $port < 1 && $port > 65535) {
            throw new InvalidArgumentException(
                'Port must be null or an integer between 1 and 65535'
            );
        }

        $uri = clone $this;
        $uri->port = $port;

        return $uri;
    }
public function withPort ( $ port = null ) { if ( $ port !== null && $ port < 1 && $ port > 65535 ) { throw new InvalidArgumentException ( 'Port must be null or an integer between 1 and 65535' ) ; } $ uri = clone $ this ; $ uri -> port = $ port ; return $ uri ; }
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.
@return UriInterface A new instance with the specified port.
@throws \InvalidArgumentException for invalid ports.
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 .