Check if url exists

@param string $pathInfo

@return bool
768412
public function match($pathInfo)
    {
        if ($ret = $this->matchCollection($pathInfo, $this->routesCopy)) {
            return $ret;
        }

        return false;
    }
240276
public function setPathInfo($pathInfo = null)
    {
        if ($pathInfo === null) {
            $requestUri = $this->getRequestUri();
            if (null === $requestUri) {
                return $this;
            }

            // Remove the query string from REQUEST_URI
            $pos = strpos($requestUri, '?');
            if ($pos) {
                $requestUri = substr($requestUri, 0, $pos);
            }

            $baseUrl = $this->getBaseUrl();
            $pathInfo = substr($requestUri, strlen($baseUrl));

            if ((null !== $baseUrl) && (false === $pathInfo)) {
                $pathInfo = '';
            } elseif (null === $baseUrl) {
                $pathInfo = $requestUri;
            }

            if ($this->_canBeStoreCodeInUrl()) {
                $pathParts = explode('/', ltrim($pathInfo, '/'), 2);
                $storeCode = $pathParts[0];

                if (!$this->isDirectAccessFrontendName($storeCode)) {
                    $stores = Mage::app()->getStores(true, true);
                    if ($storeCode!=='' && isset($stores[$storeCode])) {
                        Mage::app()->setCurrentStore($storeCode);
                        $pathInfo = '/'.(isset($pathParts[1]) ? $pathParts[1] : '');
                    } elseif ($storeCode !== '') {
                        $this->setActionName('noRoute');
                    }
                }
            }

            $this->_originalPathInfo = (string) $pathInfo;

            $this->_requestString = $pathInfo . ($pos!==false ? substr($requestUri, $pos) : '');
        }

        $this->_pathInfo = (string) $pathInfo;
        return $this;
    }
305916
public function pathExists($path = '', $public = true)
    {
        $path = $this->getStoragePath($path);

        return $this->_storage->exists($path, $public);
    }
414909
public function pathExists()
    {
        $path = $this->getPath();
        return !empty($path) && @file_exists($path) && @is_dir($path);
    }
188357
public boolean exists(URI path)
      throws IOException {
    logger.atFine().log("exists(%s)", path);
    return getFileInfo(path).exists();
  }
668738
public function match($pathinfo)
    {
        $urlMatcher = new UrlMatcher(
            $this->getRouteCollection(),
            $this->getContext()
        );
        $result = $urlMatcher->match($pathinfo);

        if (!empty($result)) {
            $nodeTranslation = $this->getNodeTranslation($result);
            if (is_null($nodeTranslation)) {
                throw new ResourceNotFoundException(
                    'No page found for slug ' . $pathinfo
                );
            }
            $result['_nodeTranslation'] = $nodeTranslation;
        }

        return $result;
    }
940475
public function exists($path)
	{
		$path = Util::normalizePath($path);

		return (bool) $this->adapter->exists($path);
	}
513936
private function isRoute(&$pathInfo)
    {
        empty($pathInfo) && $pathInfo[0] = '/';//网站根地址
        $isSuccess = [];
        $route = self::$rules;

        $httpMethod = isset($_POST['_method']) ? strtoupper($_POST['_method']) : strtoupper($_SERVER['REQUEST_METHOD']);

        switch ($httpMethod) {
            case 'GET':
                $rMethod = self::REQUEST_METHOD_GET;
                break;
            case 'POST':
                $rMethod = self::REQUEST_METHOD_POST;
                break;
            case 'PUT':
                $rMethod = self::REQUEST_METHOD_PUT;
                break;
            case 'PATCH':
                $rMethod = self::REQUEST_METHOD_PATCH;
                break;
            case 'DELETE':
                $rMethod = self::REQUEST_METHOD_DELETE;
                break;
            case 'OPTIONS':
                $rMethod = self::REQUEST_METHOD_OPTIONS;
                break;
            default :
                $rMethod = self::REQUEST_METHOD_ANY;
        }

        foreach ($route as $k => $v) {
            $rulesMethod = substr($k, 0, 1);
            if (
                $rulesMethod != $rMethod
                && $rulesMethod != self::REQUEST_METHOD_ANY
                && $rulesMethod != self::REST_ROUTE
            ) { //此条路由不符合当前请求方式
                continue;
            }
            unset($v);
            $singleRule = substr($k, 1);
            $arr = $singleRule === '/' ? [$singleRule] : explode('/', ltrim($singleRule, '/'));

            if ($arr[0] == $pathInfo[0]) {
                array_shift($arr);
                foreach ($arr as $key => $val) {
                    if (isset($pathInfo[$key + 1]) && $pathInfo[$key + 1] !== '') {
                        if (strpos($val, '\d') && !is_numeric($pathInfo[$key + 1])) {//数字变量
                            $route[$k] = false;//匹配失败
                            break 1;
                        } elseif (strpos($val, ':') === false && $val != $pathInfo[$key + 1]) {//字符串
                            $route[$k] = false;//匹配失败
                            break 1;
                        }
                    } else {
                        $route[$k] = false;//匹配失败
                        break 1;
                    }
                }
            } else {
                $route[$k] = false;//匹配失败
            }

            if ($route[$k] !== false) {//匹配成功的路由
                $isSuccess[] = $k;
            }
        }

        if (empty($isSuccess)) {
            $returnArr[0] = false;
        } else {
            //匹配到多条路由时 选择最长的一条（匹配更精确）
            usort($isSuccess, function ($item1, $item2) {
                return strlen($item1) >= strlen($item2) ? 0 : 1;
            });

            if (is_callable($route[$isSuccess[0]])) {
                \Cml\Route::executeCallableRoute($route[$isSuccess[0]], substr($isSuccess[0], 1));
            }

            is_array($route[$isSuccess[0]]) || $route[$isSuccess[0]] = trim(str_replace('\\', '/', $route[$isSuccess[0]]), '/');

            //判断路由的正确性
            if (!is_array($route[$isSuccess[0]]) && count(explode('/', $route[$isSuccess[0]])) < 2) {
                throw new \InvalidArgumentException(Lang::get('_ROUTE_PARAM_ERROR_', substr($isSuccess[0], 1)));
            }

            $returnArr[0] = true;
            $successRoute = explode('/', $isSuccess[0]);
            foreach ($successRoute as $key => $val) {
                $t = explode('\d', $val);
                if (strpos($t[0], ':') !== false) {
                    $_GET[ltrim($t[0], ':')] = $pathInfo[$key];
                }
                unset($pathInfo[$key]);
            }

            if (substr($isSuccess[0], 0, 1) == self::REST_ROUTE) {
                $actions = explode('/', $route[$isSuccess[0]]);
                $arrKey = count($actions) - 1;
                $actions[$arrKey] = strtolower($httpMethod) . ucfirst($actions[$arrKey]);
                $route[$isSuccess[0]] = implode('/', $actions);
            }

            self::$matchRoute = substr($isSuccess[0], 1);
            $returnArr['route'] = $route[$isSuccess[0]];
        }
        return $returnArr;
    }
1302711
public static function parseURL($parsedInfo) {
        $pageSet = false;
        if (preg_match('#.+?\.$#', $parsedInfo->url)) {
            return false;
        }
        if (rqset('_cpn')) {
            $parsedInfo->page = irqst('_cpn');
            $pageSet          = true;
        }
        if (preg_match('#(.+?)(_([\d]+|all))?$#', $parsedInfo->name, $ms)) {
            $parsedInfo->name   = $ms[1];
            $parsedInfo->ogname = urlencode($ms[1]);
            if (isset($ms[3])) {
                if ($ms[3] === '1') {
                    return false;
                }
                if ($ms[3] == 'all') {
                    $ms[3] = PHP_INT_MAX;
                } else {
                    $ms[3] = intval($ms[3]);
                }
                if (!$pageSet) {
                    $parsedInfo->page = $ms[3];
                }
            }
        }
        if (!preg_match('#.+?(\..+)$#', $parsedInfo->url)) {
            if ($parsedInfo->page > 1 && !$pageSet) {
                return false;
            }
            $parsedInfo->name   .= '/index';
            $parsedInfo->ogname .= '/index';
            if (!$parsedInfo->ext) {
                $parsedInfo->ext = 'html';
            }
        }
        if (!$parsedInfo->ext) {
            return false;
        }
        $parsedInfo->contentType = Router::mimeContentType('a.' . $parsedInfo->ext);

        $parsedInfo->parsedUrl = ltrim(implode('', [
            $parsedInfo->path,
            '/',
            $parsedInfo->name,
            '.' . $parsedInfo->ext
        ]), '/');

        return $parsedInfo->parsedUrl;
    }
1157870
public static function exists(string $link = ''): bool
    {
        $link = static::normalizePath($link);
        return static::verifyPath($link) && \file_exists($link) && \is_link($link);
    }
140095
public function exists($path)
	{
		// Return default value if path is empty
		if (empty($path))
		{
			return false;
		}

		// Explode the registry path into an array
		$nodes = explode($this->separator, $path);

		// Initialize the current node to be the registry root.
		$node  = $this->data;
		$found = false;

		// Traverse the registry to find the correct node for the result.
		foreach ($nodes as $n)
		{
			if (\is_array($node) && isset($node[$n]))
			{
				$node  = $node[$n];
				$found = true;

				continue;
			}

			if (!isset($node->$n))
			{
				return false;
			}

			$node  = $node->$n;
			$found = true;
		}

		return $found;
	}
1151546
public function has($path)
    {
        $x = $this->xpath($path);

        return count($x) ? true : false;
    }
1113230
public function match($pathinfo)
    {
        $return = null;

        // Default (homepage) - index.html
        if (
            ('/' === $pathinfo) &&
            ($index_template = $this->resolver->resolveIndexTemplate())
        ) {
            $return = array(
                '_controller' => $this->controller,
                '_route' => $index_template->getRenderName(),
                'template' => $index_template,
            );
        }

        // 404 not found - 404.html

        if (!$return && ($nf_template = $this->resolver->resolveNotFoundTemplate())) {
            $return = array(
                '_controller' => $this->controller,
                '_route' => $nf_template->getRenderName(),
                'template' => $nf_template,
            );
        }

        // 404 not found - last resort
        if (!$return) {
            $return = array(
                '_controller' => $this->errorController,
                '_route' => '404',
            );
        }

        return($return);
    }
1222376
protected function removeUrlSuffix($pathInfo, $urlSuffix)
    {
        if ('' !== $urlSuffix && substr($pathInfo, -strlen($urlSuffix)) === $urlSuffix) {
            return substr($pathInfo, 0, -strlen($urlSuffix));
        } else {
            return $pathInfo;
        }
    }
1002209
public function has($path) {
        $mapping = $this->mapper->get($path);

        if (!$mapping) {
            return false;
        }

        return $this->client->has($mapping['fid']);
    }
1331568
public function pathExists(string $path): bool
	{
		$loader = $this->getRenderer()->getLoader();

		/*
		 * For Twig 1.x compatibility, check if the loader implements ExistsLoaderInterface
		 * As of Twig 2.0, the `exists()` method is part of LoaderInterface
		 * This conditional may be removed when dropping Twig 1.x support
		 */
		if ($loader instanceof ExistsLoaderInterface || method_exists(LoaderInterface::class, 'exists'))
		{
			return $loader->exists($path);
		}

		// For all other cases we'll assume the path exists
		return true;
	}
868868
public function existsChunk($path)
    {
        $path = Alias::getAlias($path, ['lang' => $this->locale]);
        if (!pathinfo($path, PATHINFO_EXTENSION)) {
            $path .= '.' . $this->defaultExtension;
        }

        return file_exists($path);
    }