private static function processUriParams(&$path, &$params) {
		// if the route path contains parameters like `:key`
		if (preg_match_all(static::REGEX_PATH_PARAMS, $path, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
			$previousMatchEnd = 0;
			$regexParts = [];

			// extract all parameter names and create a regex that matches URIs and captures the parameters' values
			foreach ($matches as $match) {
				// remember the boundaries of the full match (e.g. `:key`) in the subject
				$matchStart = $match[0][1];
				$matchEnd = $matchStart + strlen($match[0][0]);

				// keep the part between this one and the previous match and escape it for regex
				$regexParts[] = static::regexEscape(substr($path, $previousMatchEnd, $matchStart - $previousMatchEnd));

				// save the current parameter's name
				$params[] = $match[1][0];

				// insert an expression that will match the parameter's value
				$regexParts[] = static::REGEX_PATH_SEGMENT;

				// remember the end index of the current match
				$previousMatchEnd = $matchEnd;
			}

			// keep the part after the last match and escape it for regex
			$regexParts[] = static::regexEscape(substr($path, $previousMatchEnd));

			// replace the parameterized URI with a regex that matches the parameters' values
			$path = implode('', $regexParts);
		}
		// if the route path is not parameterized
		else {
			// just escape the path for literal usage in regex
			$path = static::regexEscape($path);
		}
	}
private static function processUriParams(&$path, &$params) {
		// if the route path contains parameters like `:key`
		if (preg_match_all(static::REGEX_PATH_PARAMS, $path, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
			$previousMatchEnd = 0;
			$regexParts = [];

			// extract all parameter names and create a regex that matches URIs and captures the parameters' values
			foreach ($matches as $match) {
				// remember the boundaries of the full match (e.g. `:key`) in the subject
				$matchStart = $match[0][1];
				$matchEnd = $matchStart + strlen($match[0][0]);

				// keep the part between this one and the previous match and escape it for regex
				$regexParts[] = static::regexEscape(substr($path, $previousMatchEnd, $matchStart - $previousMatchEnd));

				// save the current parameter's name
				$params[] = $match[1][0];

				// insert an expression that will match the parameter's value
				$regexParts[] = static::REGEX_PATH_SEGMENT;

				// remember the end index of the current match
				$previousMatchEnd = $matchEnd;
			}

			// keep the part after the last match and escape it for regex
			$regexParts[] = static::regexEscape(substr($path, $previousMatchEnd));

			// replace the parameterized URI with a regex that matches the parameters' values
			$path = implode('', $regexParts);
		}
		// if the route path is not parameterized
		else {
			// just escape the path for literal usage in regex
			$path = static::regexEscape($path);
		}
	}
private static function processUriParams ( & $ path , & $ params ) { // if the route path contains parameters like `:key` if ( preg_match_all ( static :: REGEX_PATH_PARAMS , $ path , $ matches , PREG_SET_ORDER | PREG_OFFSET_CAPTURE ) ) { $ previousMatchEnd = 0 ; $ regexParts = [ ] ; // extract all parameter names and create a regex that matches URIs and captures the parameters' values foreach ( $ matches as $ match ) { // remember the boundaries of the full match (e.g. `:key`) in the subject $ matchStart = $ match [ 0 ] [ 1 ] ; $ matchEnd = $ matchStart + strlen ( $ match [ 0 ] [ 0 ] ) ; // keep the part between this one and the previous match and escape it for regex $ regexParts [ ] = static :: regexEscape ( substr ( $ path , $ previousMatchEnd , $ matchStart - $ previousMatchEnd ) ) ; // save the current parameter's name $ params [ ] = $ match [ 1 ] [ 0 ] ; // insert an expression that will match the parameter's value $ regexParts [ ] = static :: REGEX_PATH_SEGMENT ; // remember the end index of the current match $ previousMatchEnd = $ matchEnd ; } // keep the part after the last match and escape it for regex $ regexParts [ ] = static :: regexEscape ( substr ( $ path , $ previousMatchEnd ) ) ; // replace the parameterized URI with a regex that matches the parameters' values $ path = implode ( '' , $ regexParts ) ; } // if the route path is not parameterized else { // just escape the path for literal usage in regex $ path = static :: regexEscape ( $ path ) ; } }
Extracts parameters from a path

@param string $path the path to extract the parameters from
@param array $params the array that should receive the matched parameters
Extracts parameters from a path