zend implementation overridden to avoid pathInfo getting modified even if route didn't match
550614
public function match($request, $partial = null)
    {
        $path        = trim($request->getPathInfo(), self::URI_DELIMITER);
        $subPath     = $path;
        $values      = array();
        $numRoutes   = count($this->_routes);
        $matchedPath = null;

        foreach ($this->_routes as $key => $route) {
            if ($key > 0
                && $matchedPath !== null
                && $subPath !== ''
                && $subPath !== false
            ) {
                $separator = substr($subPath, 0, strlen($this->_separators[$key]));

                if ($separator !== $this->_separators[$key]) {
                    return false;
                }

                $subPath = substr($subPath, strlen($separator));
            }

            // TODO: Should be an interface method. Hack for 1.0 BC
            if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) {
                $match = $subPath;
            } else {
                $request->setPathInfo($subPath);
                $match = $request;
            }

            $res = $route->match($match, true, ($key == $numRoutes - 1));
            if ($res === false) {
//BEGIN FIX
                $request->setPathInfo($path);
//END FIX
                return false;
            }

            $matchedPath = $route->getMatchedPath();

            if ($matchedPath !== null) {
                $subPath     = substr($subPath, strlen($matchedPath));
                $separator   = substr($subPath, 0, strlen($this->_separators[$key]));
            }

            $values = $res + $values;
        }

        $request->setPathInfo($path);

        if ($subPath !== '' && $subPath !== false) {
            return false;
        }

        return $values;
    }
71230
function updateAndStoreModified()
    {
        $pathString = trim( $this->attribute( 'path_string' ), '/' );

        // during publishing, a temporary path is generated. The update query shouldn't be executed as it doesn't affect anything
        if ( $pathString == 'TEMPPATH' )
            return;
        $pathArray = explode( '/', $pathString );

        if ( count( $pathArray ) > 0 )
        {
            $db = eZDB::instance();
            $db->query( 'UPDATE ezcontentobject_tree SET modified_subnode=' . time() .
                        ' WHERE ' . $db->generateSQLINStatement( $pathArray, 'node_id', false, true, 'int' ) );
        }
    }
1196251
protected function matchRoute($pathinfo, $name, BaseRoute $route) {
		$compiledRoute = $route->compile();

		// check the static prefix of the URL first. Only use the more expensive preg_match when it matches
		if ('' !== $compiledRoute->getStaticPrefix() && 0 !== strpos($pathinfo, $compiledRoute->getStaticPrefix())) {
			return null;
		}

		if (!preg_match($compiledRoute->getRegex(), $pathinfo, $matches)) {
			return null;
		}

		$hostMatches = array();
		if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) {
			return null;
		}

		// check HTTP method requirement
		if ($req = $route->getRequirement('_method')) {
			// HEAD and GET are equivalent as per RFC
			if ('HEAD' === $method = $this->context->getMethod()) {
				$method = 'GET';
			}

			if (!in_array($method, $req = explode('|', strtoupper($req)))) {
				$this->allow = array_merge($this->allow, $req);

				return null;
			}
		}

		$status = $this->handleRouteRequirements($pathinfo, $name, $route);

		if (self::ROUTE_MATCH === $status[0]) {
			return $status[1];
		}

		if (self::REQUIREMENT_MISMATCH === $status[0]) {
			return null;
		}

		$attrs = $this->getAttributes($route, $name, array_replace($matches, $hostMatches));

		if($route instanceof Route) {
			foreach($route->getMatchCallbacks() as $callback) {
				$ret = call_user_func($callback, $attrs);
				if($ret === false) {
					return null;
				}
				if(is_array($ret)) {
					$attrs = $ret;
				}
			}
		}

		return $attrs;

	}
541263
protected function matchRegex()
    {
        // Match request against route table
        foreach ($this->routes as $route => $endpoint) {
            $result = $this->routeParser->parse($route);

            // Get regex
            $regex = $result[0];
            // Get param names
            $paramNames = $result[1];

            if (preg_match($regex, $this->requestUri, $matches)) {
                // Check if endpoint class exists
                if (!$this->endpointExists($endpoint)) {
                    // Endpoint class not found
                    throw new NotFound();
                } elseif (!$this->endpointMethodExists($endpoint, $this->requestMethod)) {
                    // Route found but method can't be found
                    throw new MethodNotAllowed();
                }

                // Set matched route
                $this->matchedRoute = $route;
                // Set matched endpoint
                $this->matchedEndpoint = $endpoint;
                // Set matched request method
                $this->matchedMethod = $this->requestMethod;

                // Remove all slashes from param values/matches
                $matches = array_diff($matches, ['/']);

                // Remove first value in the matches array since it wont be used
                array_shift($matches);

                // Loop through all params and match them with values and save the result
                // to the params array
                foreach ($paramNames as $key => $name) {
                    $this->params[$name] = (isset($matches[$key])) ? $matches[$key]: null;
                }

                // Match found, add it to the cache for later use
                $this->addToCache($this->requestUri);

                // Time to stop looking for more matches
                return true;
            }
        }

        return false;
    }
868802
function route(method, path, handler, config) {

    if( (typeof method !== 'string' && !Array.isArray(method))
        || (typeof path !== 'string')
        || (typeof handler !== 'function' && typeof handler !== 'string' && typeof handler !== 'object')
        || (config != null && typeof config !== 'object') ) {
        throw new TypeError('Bad arguments');
    }

    if (typeof method === 'string') {
        method = method.toUpperCase().replace(/\s+/g, ' ').trim().replace(/^DEL$/, 'DELETE');
        if (method.match(/ /)) {
            method = method.split(' ');
        }
    }
    if (Array.isArray(method)) {
        method = method.map(function (x) {
            return x.toUpperCase().replace(/\s+/g, ' ').trim().replace(/^DEL$/, 'DELETE');
        });
        method.forEach(function (elem) {
            if (elem.match(/[^A-Z*]/)) {
                throw new TypeError('Bad arguments');
            }
        });
    }
    return {
        method: method,
        path: path,
        handler: handler,
        config: config
    };
}
1071166
public function preDispatch()
    {
        parent::preDispatch();

        $action = strtolower($this->getRequest()->getActionName());
        if (in_array($action, $this->authActions)) {
            $auth       = \Zend_Auth::getInstance();
            $this->auth = $auth;

            if (!$auth->hasIdentity()) {
                $config = array(
                    'accept_schemes' => 'basic',
                    'realm'          => GEMS_PROJECT_NAME,
                    'nonce_timeout'  => 3600,
                );
                $adapter         = new \Zend_Auth_Adapter_Http($config);
                $basicResolver   = new \Zend_Auth_Adapter_Http_Resolver_File();

                //This is a basic resolver, use username:realm:password
                //@@TODO: move to a better db stored authentication system

                $basicResolver->setFile(GEMS_ROOT_DIR . '/var/settings/pwd.txt');
                $adapter->setBasicResolver($basicResolver);
                $request  = $this->getRequest();
                $response = $this->getResponse();

                assert($request instanceof \Zend_Controller_Request_Http);
                assert($response instanceof \Zend_Controller_Response_Http);

                $adapter->setRequest($request);
                $adapter->setResponse($response);

                $result = $auth->authenticate($adapter);

                if (!$result->isValid()) {
                    $adapter->getResponse()->sendResponse();
                    print 'Unauthorized';
                    exit;
                }
            }
        }
    }
294971
public function matchRestParamSet($path, $method = 'GET')
    {
        $rootCtrl = '';
        $params = array();
        $routes = array();

        // Split out format
        if (strpos($path, '.') !== false) {
            $params['_format'] = pathinfo($path, PATHINFO_EXTENSION);
            $path = substr($path, 0, - strlen($params['_format']) - 1);
        }

        $parts = $this->parsePath($path);

        // Split out namespace
        if (count($parts) > 1 && in_array($parts[0], $this->namespaces)) {
            $rootCtrl .= array_shift($parts) . '/';
        }

        // Split out scope
        if (count($parts) > 1 && in_array($parts[0], $this->scopes)) {
            $rootCtrl .= array_shift($parts) . '/';
        }

        $baseCtrl = $rootCtrl;

        // The first parameter must be controller name,
        // the second parameter may be action name or id, eg posts/show, posts/1
        // the last parameter may be controller name or action name or null, eg posts/1/comments, posts/1/edit
        $lastParts = array_pad(array_splice($parts, count($parts) % 2 == 0 ? -2 : -3), 3, null);
        list($ctrl, $actOrId, $ctrlOrAct) = $lastParts;

        // Generate part of controller name and query parameters
        $count = count($parts);
        for ($i = 0; $i < $count; $i += 2) {
            $baseCtrl .= $parts[$i] . '/';
            $params[$this->camelize($this->singularize($parts[$i])) . 'Id'] = $parts[$i + 1];
        }

        if (is_null($actOrId)) {
            // GET|POST|... /, GET|POST|... posts
            $routes[] = array(
                'controller' => $baseCtrl . ($ctrl ?: $this->defaultController),
                'action' => $this->methodToAction($method, true),
            );
        } elseif (is_null($ctrlOrAct)) {
            // GET posts/show
            if ($this->isAction($actOrId)) {
                $routes[] = array(
                    'controller' => $baseCtrl . $ctrl,
                    'action' => $actOrId,
                );
            }

            // GET|PUT|... posts/1
            $routes[] = array(
                'controller' => $baseCtrl . $ctrl,
                'action' => $this->methodToAction($method),
                'id' => $actOrId
            );

            // GET posts/1/comment/new => comment::new postId=1
            if ($count >= 2 && $this->isAction($actOrId)) {
                $routes[] = array(
                    'controller' => $rootCtrl . $ctrl,
                    'action' => $actOrId,
                );
            }
        } else {
            // GET posts/1/edit
            $routes[] = array(
                'controller' => $baseCtrl . $ctrl,
                'action' => $ctrlOrAct,
                'id' => $actOrId
            );

            // GET|PUT|... posts/1/comments
            $routes[] = array(
                'controller' => $baseCtrl . $ctrl . '/' . $ctrlOrAct,
                'action' => $this->methodToAction($method, true),
                $this->camelize($this->singularize($ctrl)) . 'Id' => $actOrId,
            );

            // GET|PUT|... posts/1/comments, use the last parameter as main controller name
            $routes[] = array('controller' => $rootCtrl . $ctrlOrAct) + $routes[1];
        }

        foreach ($routes as &$route) {
            $route['controller'] = $this->camelize($route['controller']);
            $route['action'] = $this->camelize($route['action']);
            $route += $params;
        }
        return $routes;
    }
481089
protected function notFound()
    {
        $errmsg = sprintf('[%s][%s]method not found: %s:%s. handlers: %s', $this->request->getMethod(), UriHelper::getCurrentUrl(), get_class($this), $this->getLongName(), implode('|', $this->getHandleStack()));
        Ioc::logger('router')->error($errmsg);
        
        $handler = Ioc::get('notFoundHandler');
        return $handler($this->request, $this->response);
    }
491090
function (path) {
		var mockDirConfig = {
			openRoute: function (req, res, params) {
			},
			
			closeRoute: function (req, res, params) {
			},
		};

		spyOn(mockDirConfig, 'openRoute').and.callThrough();
		spyOn(mockDirConfig, 'closeRoute').and.callThrough();

		registerRequireMock(testObject._formatPathForRequire(path), function () {
			return mockDirConfig;
		});

		filesThatExist.push(path);

		return mockDirConfig;
	}
1368408
private static function handleRequestNotFound () {
        $response = get_response();
        $response->clear();
        $response->statusCode(Response::HTTP_NOT_FOUND);
        $notFoundRoutes = self::$notFoundRoutes->getRoutes();
        if (!empty($notFoundRoutes)) {
            foreach ($notFoundRoutes as $notFoundRoute) {
                $routeResult = self::executeAction($notFoundRoute->getAction(), array_merge($_REQUEST, $notFoundRoute->getParameters()));
                if (isset($routeResult)) {
                    $response->content($routeResult);
                }
            }
            $response->send();
        }
        else {
            handle_error_code(Response::HTTP_NOT_FOUND);
        }
    }
116710
protected function ensure_path_exists() {
        global $CFG;
        if (!is_writable($this->path)) {
            if ($this->custompath && !$this->autocreate) {
                throw new coding_exception('File store path does not exist. It must exist and be writable by the web server.');
            }
            $createdcfg = false;
            if (!isset($CFG)) {
                // This can only happen during destruction of objects.
                // A cache is being used within a destructor, php is ending a request and $CFG has
                // already being cleaned up.
                // Rebuild $CFG with directory permissions just to complete this write.
                $CFG = $this->cfg;
                $createdcfg = true;
            }
            if (!make_writable_directory($this->path, false)) {
                throw new coding_exception('File store path does not exist and can not be created.');
            }
            if ($createdcfg) {
                // We re-created it so we'll clean it up.
                unset($CFG);
            }
        }
        return true;
    }
39099
private function initAPIRoutes()
    {
        $path = config('jiyis.laravel_generator.path.routes', app_path('Http/routes.php'));

        $prompt = 'Existing routes.php file detected. Should we add an API group to the file? (y|N) :';
        if (file_exists($path) && !$this->confirmOverwrite($path, $prompt)) {
            return;
        }

        $routeContents = file_get_contents($path);

        $template = 'api.routes.api_routes_group';

        $templateData = TemplateUtil::getTemplate($template, 'laravel-generator');

        $templateData = $this->fillTemplate($templateData);

        file_put_contents($path, $routeContents."\n\n".$templateData);
        $this->comment("\nAPI group added to routes.php");
    }
1275559
public function matchUrl($pathinfo)
    {
        $routes = $this->getRoutes();
        if (!empty($routes) && isset($routes[$pathinfo])) {
            return $routes[$pathinfo];
        }
        return false;
    }
907112
def _ValidatePathInfos(path_infos):
  """"""
  precondition.AssertIterableType(path_infos, rdf_objects.PathInfo)

  validated = set()
  for path_info in path_infos:
    _ValidatePathInfo(path_info)

    path_key = (path_info.path_type, path_info.GetPathID())
    if path_key in validated:
      message = "Conflicting writes for path: '{path}' ({path_type})".format(
          path="/".join(path_info.components), path_type=path_info.path_type)
      raise ValueError(message)

    if path_info.HasField("hash_entry"):
      if path_info.hash_entry.sha256 is None:
        message = "Path with hash entry without SHA256: {}".format(path_info)
        raise ValueError(message)

    validated.add(path_key)
1293564
public function rewritePathInfo($pathInfo)
    {
        if (($pathInfo != $this->getPathInfo()) && ($this->_rewritedPathInfo === null)) {
            $this->_rewritedPathInfo = explode('/', trim($this->getPathInfo(), '/'));
        }
        $this->setPathInfo($pathInfo);
        return $this;
    }
352716
public function match(string $path, ?string $method, ?string $host): ?RouteInterface{
        if("/" !== mb_substr($path, 0, 1)){
            $path   = "/" . $path;
        }

        $stack      = new \SplStack();

        foreach(array_reverse(explode("/", $path)) as $segment){
            $stack->push($segment);
        }

        return $this->recursionMatch($this->rootNode, $stack, $method, $host);
    }
280241
public function overridePath()
	{
		if (!isset($this->paths['override']))
		{
			$this->paths['override']  = \App::get('template')->path . DS . 'html';
			$this->paths['override'] .= DS . $this->extensionName() . DS . ($this->extensionType() == 'system' ? $this->type() . DS : '') . $this->file();
		}
		return $this->paths['override'];
	}