Checks if URI components are valid

@param array $uri an associated array of URI components

@return bool
966061
private static function isValidUri(array $uri): bool
    {
        if (!self::isValidUriScheme($uri['scheme'])) {
            return false;
        }
        if (!self::isValidUriPath($uri['path'])) {
            return false;
        }
        if (!self::isValidUriQuery($uri['query'])) {
            return false;
        }
        if (!self::isValidUriFragment($uri['fragment'])) {
            return false;
        }
        if (!self::isValidUriAuthority($uri['authority'])) {
            return false;
        }

        return true;
    }
1124719
private function parseUri($uri)
    {
        $parts = parse_url($uri);

        if (false === $parts) {
            throw new \InvalidArgumentException(
                'The source URI string appears to be malformed'
            );
        }

        $this->scheme    = isset($parts['scheme'])   ? $this->filterScheme($parts['scheme']) : '';
        $this->userInfo  = isset($parts['user'])     ? $parts['user']     : '';
        $this->host      = isset($parts['host'])     ? $parts['host']     : '';
        $this->port      = isset($parts['port'])     ? $parts['port']     : null;
        $this->path      = isset($parts['path'])     ? $this->filterPath($parts['path']) : '';
        $this->query     = isset($parts['query'])    ? $this->filterQuery($parts['query']) : '';
        $this->fragment  = isset($parts['fragment']) ? $this->filterFragment($parts['fragment']) : '';

        if (isset($parts['pass'])) {
            $this->userInfo .= ':' . $parts['pass'];
        }
    }
1055710
protected function composeUri(array $components)
    {
        $uri = '';

        $scheme = empty($components['scheme']) ? 'http' : $components['scheme'];
        if ($scheme !== '') {
            $uri .= $scheme . ':';
        }

        $authority = $this->composeAuthority($components);

        if ($authority !== '' || $scheme === 'file') {
            // authority separator is added even when the authority is missing/empty for the "file" scheme
            // while `file:///myfile` and `file:/myfile` are equivalent according to RFC 3986, `file:///` is more common
            // PHP functions and Chrome, for example, use this format
            $uri .= '//' . $authority;
        }

        if (!empty($components['path'])) {
            $uri .= $components['path'];
        }

        if (!empty($components['query'])) {
            $uri .= '?' . $components['query'];
        }

        if (!empty($components['fragment'])) {
            $uri .= '#' . $components['fragment'];
        }

        return $uri;
    }
1217641
public function isStream($uri)
    {
        try {
            list ($scheme,) = $this->normalize($uri, true, true);
        } catch (\Exception $e) {
            return false;
        }

        return $this->schemeExists($scheme);
    }
300133
public function parseUri($uri)
    {
        $ret = [];
        foreach (explode($this->seperators['param'], $uri) as $params) {
            if ($params) {
                @list($key, $values) = explode($this->seperators['key_value'], $params, 2);
                $external = $key;
                if ($internal = $this->translateKeyInput($key)) {
                    $key = $internal;
                }
                $ret[$key] = [];
                foreach (explode($this->seperators['value'], $values) as $value) {
                    if (strlen($value) > 0) {
                        if ($internal = $this->translateValueInput($external, $value)) {
                            $value = $internal;
                        }
                        $ret[$key][] = urldecode($value);
                    }
                }
            }
        }

        return $ret;
    }
284519
protected function processUri($uri)
    {
        return preg_replace_callback('#\{([a-zA-Z0-9_,]*)\}#i', function ($matches) {
            return isset($this->tokens[$matches[1]]) ? $this->tokens[$matches[1]] : '';
        }, $uri);
    }
1177560
public function isValid(): bool
    {
        $uris = [];
        foreach ($this->members as $member) {
            $uri = $member->uri;
            if ($uri) {
                if (isset($uris[$uri])) {
                    return false;
                } else {
                    $uris[$uri] = true;
                }
            }
        }
        return true;
    }
891526
public static boolean validateResource(URI uri) {
        return uri != null && uri.getPort() != -1 && uri.getHost() != null;
    }
1247015
public static function validateURI($uri) {
        if(!empty(trim($uri))){
            return filter_var(trim($uri), FILTER_VALIDATE_URL);
        }
        return false;
    }
1202057
public static function isValid($httpUri): bool
    {
        if ($httpUri instanceof self) {
            return true;
        }

        if (empty($httpUri) || !is_string($httpUri)) {
            return false;
        }

        try {
            self::fromString($httpUri);
        } catch (MalformedUri $murle) {
            return false;
        }

        return true;
    }
157910
public static function fromInvalidUri($uri)
    {
        return new self(sprintf('Expected data to be a valid URI object; received "%s"', is_object($uri) ? get_class($uri) : gettype($uri)));
    }
292621
protected function isRelativeUri($uri)
    {
        if ($uri && !parse_url($uri, PHP_URL_SCHEME)) {
            if (!in_array($uri[0], [ '/', '#', '?' ])) {
                return true;
            }
        }

        return false;
    }
612394
public static function parseUri(string $uri){
        if(1 !== preg_match(static::REGEX_URI, $uri, $m)){
            return false;
        }

        $result = [
            "scheme"    => $m["scheme"] ?? "",
            "userinfo"  => $m["userinfo"] ?? "",
            "host"      => $m["host"] ?? "",
            "port"      => "" === $m["port"] ? null : (int)$m["port"],
            "path"      => $m["path"] ?? "",
            "query"     => $m["query"] ?? "",
            "fragment"  => $m["fragment"] ?? "",
        ];

        return $result;
    }
31875
private static boolean isValidFileSystemUri(URI uri) {
    // would like to just check null, but fragment appears to be the empty string when not present
    return isNullOrEmpty(uri.getPath())
        && isNullOrEmpty(uri.getQuery())
        && isNullOrEmpty(uri.getFragment());
  }
946598
public function isValid() : bool
    {
        $this->validate();

        if ($this->hasErrors()) {
            return false;
        }

        foreach ($this->components as $component) {
            if ($component->hasErrors()) {
                return false;
            }
        }

        return true;
    }
726815
public function validateUris(array $uris)
    {
        $requiredParams = [
            'temporary_credentials_uri',
            'authorization_uri',
            'token_credentials_uri',
        ];

        foreach ($requiredParams as $param) {
            if (! isset($uris[$param])) {
                throw new InvalidArgumentException("Missing URI configuration: {$param}.");
            }
        }

        return true;
    }
171118
public static function isAbsolute($uri): bool
    {
        $null = $uri instanceof Psr7UriInterface ? '' : null;

        return $null !== self::filterUri($uri)->getScheme();
    }