src/Uri.php
protected function setPort($port)
    {
        $this->uriString = null;

        if (null === $port) {
            $this->port = null;

            return $this;
        }

        if (! $this->isPortValid($port)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid port "%s" provided.',
                (is_object($port) ? get_class($port) : gettype($port))
            ));
        }
        $this->port = (int) $port;

        return $this;
    }
protected function setPort($port)
    {
        $this->uriString = null;

        if (null === $port) {
            $this->port = null;

            return $this;
        }

        if (! $this->isPortValid($port)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid port "%s" provided.',
                (is_object($port) ? get_class($port) : gettype($port))
            ));
        }
        $this->port = (int) $port;

        return $this;
    }
protected function setPort ( $ port ) { $ this -> uriString = null ; if ( null === $ port ) { $ this -> port = null ; return $ this ; } if ( ! $ this -> isPortValid ( $ port ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid port "%s" provided.' , ( is_object ( $ port ) ? get_class ( $ port ) : gettype ( $ port ) ) ) ) ; } $ this -> port = ( int ) $ port ; return $ this ; }
Sets the provided port to current instance.

@param null|int $port The port; a null value removes the port information

@throw \InvalidArgumentException For invalid ports

@return Uri The current instance with the provided port
Sets the provided port to current instance .