src/Url.php
private static function myParseAuthority(?UrlInterface $baseUrl = null, ?string $authorityString, ?HostInterface &$host = null, ?int &$port = null, ?string &$error = null): bool
    {
        if ($authorityString === null && $baseUrl !== null) {
            $host = $baseUrl->getHost();
            $port = $baseUrl->getPort();

            return true;
        }

        // Throw away username and password if present.
        $parts = explode('@', $authorityString, 2);
        if (count($parts) > 1) {
            $authorityString = $parts[1];
        }

        $parts = explode(':', $authorityString, 2);
        $port = null;

        // Try parse and validate port.
        if (count($parts) === 2 && $parts[1] !== '') {
            // Port containing invalid character is invalid.
            if (preg_match('/[^0-9]/', $parts[1], $matches)) {
                $error = 'Port "' . $parts[1] . '" contains invalid character "' . $matches[0] . '".';

                return false;
            }

            $port = intval($parts[1]);

            // Port out of range is invalid.
            if (!self::myValidatePort($port, $error)) {
                return false;
            }
        }

        try {
            $host = Host::parse($parts[0]);
        } catch (HostInvalidArgumentException $e) {
            $error = $e->getMessage();

            return false;
        }

        return true;
    }
private static function myParseAuthority(?UrlInterface $baseUrl = null, ?string $authorityString, ?HostInterface &$host = null, ?int &$port = null, ?string &$error = null): bool
    {
        if ($authorityString === null && $baseUrl !== null) {
            $host = $baseUrl->getHost();
            $port = $baseUrl->getPort();

            return true;
        }

        // Throw away username and password if present.
        $parts = explode('@', $authorityString, 2);
        if (count($parts) > 1) {
            $authorityString = $parts[1];
        }

        $parts = explode(':', $authorityString, 2);
        $port = null;

        // Try parse and validate port.
        if (count($parts) === 2 && $parts[1] !== '') {
            // Port containing invalid character is invalid.
            if (preg_match('/[^0-9]/', $parts[1], $matches)) {
                $error = 'Port "' . $parts[1] . '" contains invalid character "' . $matches[0] . '".';

                return false;
            }

            $port = intval($parts[1]);

            // Port out of range is invalid.
            if (!self::myValidatePort($port, $error)) {
                return false;
            }
        }

        try {
            $host = Host::parse($parts[0]);
        } catch (HostInvalidArgumentException $e) {
            $error = $e->getMessage();

            return false;
        }

        return true;
    }
private static function myParseAuthority ( ? UrlInterface $ baseUrl = null , ? string $ authorityString , ? HostInterface & $ host = null , ? int & $ port = null , ? string & $ error = null ) : bool { if ( $ authorityString === null && $ baseUrl !== null ) { $ host = $ baseUrl -> getHost ( ) ; $ port = $ baseUrl -> getPort ( ) ; return true ; } // Throw away username and password if present. $ parts = explode ( '@' , $ authorityString , 2 ) ; if ( count ( $ parts ) > 1 ) { $ authorityString = $ parts [ 1 ] ; } $ parts = explode ( ':' , $ authorityString , 2 ) ; $ port = null ; // Try parse and validate port. if ( count ( $ parts ) === 2 && $ parts [ 1 ] !== '' ) { // Port containing invalid character is invalid. if ( preg_match ( '/[^0-9]/' , $ parts [ 1 ] , $ matches ) ) { $ error = 'Port "' . $ parts [ 1 ] . '" contains invalid character "' . $ matches [ 0 ] . '".' ; return false ; } $ port = intval ( $ parts [ 1 ] ) ; // Port out of range is invalid. if ( ! self :: myValidatePort ( $ port , $ error ) ) { return false ; } } try { $ host = Host :: parse ( $ parts [ 0 ] ) ; } catch ( HostInvalidArgumentException $ e ) { $ error = $ e -> getMessage ( ) ; return false ; } return true ; }
Parse authority part.

@param UrlInterface|null  $baseUrl         The base url or null if no base url is present.
@param string|null        $authorityString The authority part that is to be parsed or null if no authority part is present.
@param HostInterface|null $host            The host if parsing was successful, undefined otherwise.
@param int|null           $port            The port if parsing was successful, undefined otherwise.
@param string|null        $error           The error text if parsing was not successful, undefined otherwise.

@return bool True if parsing was successful, false otherwise.
Parse authority part .