protected function isSyntacticallyValid(): bool
    {
        if (preg_match('!^([a-z][a-z0-9\+]*)://([^@]+@)?([^/?#]*)(/([^#?]*))?(.*)$!', $this->parsedUri->asString()) == 0) {
            return false;
        }

        if ($this->parsedUri->hasUser()) {
            if (preg_match('~([@:/])~', $this->parsedUri->user()) != 0) {
                return false;
            }

            if (!empty($this->parsedUri->password()) && preg_match('~([@:/])~', $this->parsedUri->password()) != 0) {
                return false;
            }
        }

        if (!$this->parsedUri->hasHostname() || strlen($this->parsedUri->hostname()) === 0) {
            return true;
        }

        if ($this->parsedUri->hasHostname()
          && preg_match('!^([a-zA-Z0-9\.-]+|\[[^\]]+\])(:([0-9]+))?$!', $this->parsedUri->hostname()) != 0) {
            return true;
        }

        return false;
    }
protected function isSyntacticallyValid(): bool
    {
        if (preg_match('!^([a-z][a-z0-9\+]*)://([^@]+@)?([^/?#]*)(/([^#?]*))?(.*)$!', $this->parsedUri->asString()) == 0) {
            return false;
        }

        if ($this->parsedUri->hasUser()) {
            if (preg_match('~([@:/])~', $this->parsedUri->user()) != 0) {
                return false;
            }

            if (!empty($this->parsedUri->password()) && preg_match('~([@:/])~', $this->parsedUri->password()) != 0) {
                return false;
            }
        }

        if (!$this->parsedUri->hasHostname() || strlen($this->parsedUri->hostname()) === 0) {
            return true;
        }

        if ($this->parsedUri->hasHostname()
          && preg_match('!^([a-zA-Z0-9\.-]+|\[[^\]]+\])(:([0-9]+))?$!', $this->parsedUri->hostname()) != 0) {
            return true;
        }

        return false;
    }
protected function isSyntacticallyValid ( ) : bool { if ( preg_match ( '!^([a-z][a-z0-9\+]*)://([^@]+@)?([^/?#]*)(/([^#?]*))?(.*)$!' , $ this -> parsedUri -> asString ( ) ) == 0 ) { return false ; } if ( $ this -> parsedUri -> hasUser ( ) ) { if ( preg_match ( '~([@:/])~' , $ this -> parsedUri -> user ( ) ) != 0 ) { return false ; } if ( ! empty ( $ this -> parsedUri -> password ( ) ) && preg_match ( '~([@:/])~' , $ this -> parsedUri -> password ( ) ) != 0 ) { return false ; } } if ( ! $ this -> parsedUri -> hasHostname ( ) || strlen ( $ this -> parsedUri -> hostname ( ) ) === 0 ) { return true ; } if ( $ this -> parsedUri -> hasHostname ( ) && preg_match ( '!^([a-zA-Z0-9\.-]+|\[[^\]]+\])(:([0-9]+))?$!' , $ this -> parsedUri -> hostname ( ) ) != 0 ) { return true ; } return false ; }
Checks whether URI is a syntactically correct URI.

@return  bool
Checks whether URI is a syntactically correct URI .