src/Uri.php
public function getAuthority(bool $includeUserInfo = true): ?string
    {
        $authority = '';

        if ($includeUserInfo && $this->user !== null) {
            // The password can be empty
            $authority = $this->user;

            if ($this->password !== null && $this->password !== '') {
                $authority .= ":{$this->password}";
            }

            $authority .= '@';
        }

        if ($this->host !== null) {
            $authority .= $this->host;
        }

        if (!$this->isUsingStandardPort()) {
            $authority .= ":{$this->port}";
        }

        return $authority === '' ? null : $authority;
    }
public function getAuthority(bool $includeUserInfo = true): ?string
    {
        $authority = '';

        if ($includeUserInfo && $this->user !== null) {
            // The password can be empty
            $authority = $this->user;

            if ($this->password !== null && $this->password !== '') {
                $authority .= ":{$this->password}";
            }

            $authority .= '@';
        }

        if ($this->host !== null) {
            $authority .= $this->host;
        }

        if (!$this->isUsingStandardPort()) {
            $authority .= ":{$this->port}";
        }

        return $authority === '' ? null : $authority;
    }
Gets the authority portion of the URI, eg user:password@host:port
Note: The port is only included if it is non-standard for the scheme

@param bool $includeUserInfo Whether or not to include the user info
@return string|null The URI authority if set, otherwise null