src/Message/Uri.php
public function getPort()
    {
        $default = array_key_exists($this->getScheme(), $this->defaultPorts)
            ? $this->defaultPorts[$this->getScheme()]
            : -1;

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

        return (int) $this->port;
    }
public function getPort()
    {
        $default = array_key_exists($this->getScheme(), $this->defaultPorts)
            ? $this->defaultPorts[$this->getScheme()]
            : -1;

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

        return (int) $this->port;
    }
Retrieve the port component of the URI.

@return null|int The URI port.