Checks if $uri is of type string.

@throws InvalidArgumentException if $uri is not a string.
338024
private function validateString(string $uri): void
    {
        if (!\is_string($uri)) {
            throw new InvalidArgumentException(sprintf('String required, %s given', \gettype($uri)));
        }
    }
1237437
public static function validateURL($string)
    {
        if (filter_var($string, FILTER_VALIDATE_URL)) {
            return (string)$string;
        }

        throw new InvalidArgumentException(
            sprintf(
                'Provided string "%1$s" was not a valid URL.',
                $string
            )
        );
    }
1186116
private static function parseURI($uri){
        //Remove protocol (for clarity).
        $uri = substr($uri, strlen('mmap://'));
        $parts = explode('?', $uri);

        $file_name_block_size = explode(':', $parts[0]);

        if(!isset($file_name_block_size[1])){
            throw new \Exception(sprintf('%s is not a valid uri', $uri));
        }

        $parsed = [];

        list($parsed['file_name'], $parsed['block_size']) = $file_name_block_size;

        if(isset($parts[1])){
            //Extra params
            parse_str($parts[1], $parsed['options']);
        } else {
            $parsed['options'] = [];
        }

        return $parsed;
    }
854486
public function withQuery($query)
    {
        if (!is_string($query) && !method_exists($query, '__toString')) {
            throw new InvalidArgumentException('Uri query must be a string');
        }
        $query = ltrim((string)$query, '?');
        $clone = clone $this;
        $clone->query = Validator::checkQuery($query);

        return $clone;
    }
321674
function _set_uri_string($str)
	{
		// Filter out control characters
		$str = remove_invisible_characters($str, FALSE);

		// If the URI contains only a slash we'll kill it
		$this->uri_string = ($str == '/') ? '' : $str;
	}
1071288
public function createGeneric($uri)
    {
        if (!is_string($uri)) {
            throw new InvalidArgumentException('URI must be a string.');
        }

        $schemeClass = $this->defaultClass();

        return new $schemeClass($uri);
    }
659566
public function isValidRegex()
    {
        set_error_handler(function ($errno, $errstr) {
            throw new InvalidArgumentException($errstr, $errno);
        }, E_WARNING);

        $valid = true;

        try {
            preg_match($this->string, 'tester');
        } catch (InvalidArgumentException $e) {
            $valid = false;
        }

        restore_error_handler();

        return $valid;
    }
474838
public static function validateString($string)
    {
        if (is_string($string) || (is_object($string) && method_exists($string, '__toString'))) {
            return (string) $string;
        }
        throw new \InvalidArgumentException('Expected data must either be a string or stringable');
    }
451030
protected function assertKey($key): void
    {
        if (!is_string($key)) {
            $type = (is_object($key) ? get_class($key) . ' ' : '') . gettype($key);
            throw new InvalidArgumentException("Expected key to be a string, not $type");
        }

        if ($key === '' || preg_match('~[{}()/\\\\@:]~', $key)) {
            throw new InvalidArgumentException("Invalid key '$key'");
        }
    }
347074
private function check($directive, $uri)
    {
        $uriParser = new UriParser($uri);
        $uri = $uriParser->convertToFull($this->base);
        if ($this->base !== $uriParser->base()) {
            throw new \InvalidArgumentException('URI belongs to a different robots.txt');
        }
        if (($result = $this->checkOverride($uri)) !== false) {
            return $directive === $result;
        }
        // Path check
        return $this->checkPath($directive, $uri);
    }
476020
public static ErrorCode isUriValid(String uri){
        if(uri == null || uri.isEmpty()){
            return ErrorCode.SERVICE_INSTANCE_URI_FORMAT_ERROR;
        }
        if (!isMustFieldValid(uri, urlRegEx)
                || ! isValidBrace(uri)) {
            return ErrorCode.SERVICE_INSTANCE_URI_FORMAT_ERROR;
        }
        return ErrorCode.OK;
    }
751919
public function isMatch(string $uri): bool {
        list($path) = explode('?', $uri, 2);
        if ($path === '') {
            $path = trim($this->conf['default'], '/');
        }
        /** @noinspection ReturnFalseInspection */
        $lastDotPos = strrpos($path, '.');
        $suffix = '';
        if (false !== $lastDotPos) {
            $suffix = substr($path, $lastDotPos + 1);
            $path = substr($path, 0, $lastDotPos);
        }
        $parts = explode('/', $path);
        $this->args = [];
        while (count($parts)) {
            $p = $parts;
            $lastPart =& $p[count($p) - 1];
            $lastPart = Toolkit::toCamelCase($lastPart, true);
            $className = 'action\\' . implode('\\', $p);
            $classNameAction = $className . 'Action';
            $this->action = null;
            if (class_exists($classNameAction)) {
                $this->action = new $classNameAction();
            } else if (class_exists($className)) {
                $this->action = new $className();
            }

            if ($this->action instanceof Action) {
                $this->action->suffix = $suffix;
                return true;
            } elseif ($this->action !== null) {
                X::logger()->warn('Class ' . get_class($this->action) .
                    " is in the action namespace but not an instance of x2ts\\route\\Action.\n" .
                    "Please check the inheriting chain.");
            }
            array_unshift($this->args, array_pop($parts));
        }

        return false;
    }
940964
public function isValidUriString($uriString)
    {
        $uriString = '/' . ltrim($uriString, '/');

        if (strtolower($uriString) === $this->path) {
            $this->closureParameters = array_merge(
                $this->closureParameters,
                array_filter(explode('/', $uriString))
            );

            return true;
        } elseif (false !== ($matches = $this->getParseUriString($uriString))) {
            $parameters = [];
            $closure = new \ReflectionFunction($this->closure);

            if (is_string(key($matches))) {
                foreach ($closure->getParameters() as $index => $parameter) {
                    if (($class = $parameter->getClass()) instanceof \ReflectionClass) {
                        $className = $class->getName();
                        if (class_exists($className)) {
                            if (isset($matches[ $parameter->name ])) {
                                $parameters[ $index ] = new $className($matches[ $parameter->name ]);
                            }
                        }
                    } elseif (isset($matches[ $parameter->name ])) {
                        $parameters[ $index ] = $matches[ $parameter->name ];
                    } else {
                        $parameters[ $index ] = null;
                    }
                }
            } else {
                foreach ($closure->getParameters() as $index => $parameter) {
                    if (isset($matches[ $index ])) {
                        $parameters[ $index ] = $matches[ $index ];
                    } else {
                        $parameters[ $index ] = null;
                    }
                }
            }

            $this->closureParameters = $parameters;

            return true;
        }

        return false;
    }
958739
protected function isValidString(string $value, int $length = 20): void
    {
        if (mb_strlen($value) > $length) {
            throw new InvalidStringException(sprintf('String should not exceed %s characters.', $length));
        }
    }
71722
private function isString(string $key, $value): void
    {
        if (!\is_string($value) &&
            \in_array($key, [self::CONFIG_KEY_CUSTOM_TOKEN, self::CONFIG_KEY_MODEL], true)
        ) {
            throw new InvalidTypeException(sprintf('%s must be a string.', $key));
        }
    }
164990
public function match($string)
    {
        if (!is_string($string)) {
            throw new InvalidArgumentException('
                Invalid argument. Expected a string, received ' . gettype($string)
            );
        }

        return (bool) preg_match(
            '/' . $this->getRule() . '/ms', strtolower($string)
        );
    }
648130
private function validate($uri)
    {
        try {
            // set to false as default
            $validate = [];

            // check if there is the marker vor a special validation and or a / for complex routing
            if (strpos($uri, self::VALIDATION_PREFIX) === false && strpos($uri, $this->getDelimiter()) === false) {
                return false;
            }

            $parts = explode($this->_delimiter, $uri);
            for ($i = 0, $c = count($parts); $i < $c; $i++) {
                if (empty($parts[$i])) {
                    continue;
                } elseif ((strpos($parts[$i], self::VALIDATION_PREFIX)) === false) { // if there's no placeholder in use for a specific type
                    $this->urlPart[] = $parts[$i];
                    continue;
                }

                // this is an option to map "polymorph" [differnt types differnt classes / methods]
                $this->urlPart[] = $parts[$i];
                // position within the route to be validated
                $validate[]     = new Validator($parts[$i]);
                $this->validate = true;
            }
            unset($parts, $c, $i, $uri);
        } catch (RouteException $e) {
            throw $e;
        }

        return $validate;
    }