CompiledUrlMatcherDumper
extends MatcherDumper
in package
CompiledUrlMatcherDumper creates PHP arrays to be used with CompiledUrlMatcher.
Tags
Table of Contents
- $expressionLanguage : mixed
- $expressionLanguageProviders : array<string|int, ExpressionFunctionProviderInterface>
- $routes : mixed
- $signalingException : mixed
- __construct() : mixed
- addExpressionLanguageProvider() : mixed
- dump() : mixed
- {@inheritdoc}
- getCompiledRoutes() : array<string|int, mixed>
- Generates the arrays for CompiledUrlMatcher's constructor.
- getRoutes() : RouteCollection
- Gets the routes to dump.
- compileDynamicRoutes() : array<string|int, mixed>
- Compiles a regular expression followed by a switch statement to match dynamic routes.
- compileRoute() : array<string|int, mixed>
- Compiles a single Route to PHP code used to match it against the path info.
- compileStaticPrefixCollection() : string
- Compiles a regexp tree of subpatterns that matches nested same-prefix routes.
- compileStaticRoutes() : array<string|int, mixed>
- Compiles static routes in a switch statement.
- generateCompiledRoutes() : string
- getExpressionLanguage() : ExpressionLanguage
- groupStaticRoutes() : array<string|int, mixed>
- Splits static routes from dynamic routes, so that they can be matched first, using a simple switch.
- indent() : string
Properties
$expressionLanguage
private
mixed
$expressionLanguage
$expressionLanguageProviders
private
array<string|int, ExpressionFunctionProviderInterface>
$expressionLanguageProviders
= []
$routes
private
mixed
$routes
$signalingException
private
mixed
$signalingException
Methods
__construct()
public
__construct(RouteCollection $routes) : mixed
Parameters
- $routes : RouteCollection
Return values
mixed —addExpressionLanguageProvider()
public
addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider) : mixed
Parameters
- $provider : ExpressionFunctionProviderInterface
Return values
mixed —dump()
{@inheritdoc}
public
dump([array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $options : array<string|int, mixed> = []
Return values
mixed —getCompiledRoutes()
Generates the arrays for CompiledUrlMatcher's constructor.
public
getCompiledRoutes([bool $forDump = false ]) : array<string|int, mixed>
Parameters
- $forDump : bool = false
Return values
array<string|int, mixed> —getRoutes()
Gets the routes to dump.
public
getRoutes() : RouteCollection
Return values
RouteCollection —compileDynamicRoutes()
Compiles a regular expression followed by a switch statement to match dynamic routes.
private
compileDynamicRoutes(RouteCollection $collection, bool $matchHost, int $chunkLimit, array<string|int, mixed> &$conditions) : array<string|int, mixed>
The regular expression matches both the host and the pathinfo at the same time. For stellar performance, it is built as a tree of patterns, with re-ordering logic to group same-prefix routes together when possible.
Patterns are named so that we know which one matched (https://pcre.org/current/doc/html/pcre2syntax.html#SEC23). This name is used to "switch" to the additional logic required to match the final route.
Condition-less paths are put in a static array in the switch's default, with generic matching logic. Paths that can match two or more routes, or have user-specified conditions are put in separate switch's cases.
Last but not least:
- Because it is not possible to mix unicode/non-unicode patterns in a single regexp, several of them can be generated.
- The same regexp can be used several times when the logic in the switch rejects the match. When this happens, the matching-but-failing subpattern is excluded by replacing its name by "(*F)", which forces a failure-to-match. To ease this backlisting operation, the name of subpatterns is also the string offset where the replacement should occur.
Parameters
- $collection : RouteCollection
- $matchHost : bool
- $chunkLimit : int
- $conditions : array<string|int, mixed>
Return values
array<string|int, mixed> —compileRoute()
Compiles a single Route to PHP code used to match it against the path info.
private
compileRoute(Route $route, string $name, mixed $vars, bool $hasTrailingSlash, bool $hasTrailingVar, array<string|int, mixed> &$conditions) : array<string|int, mixed>
Parameters
- $route : Route
- $name : string
- $vars : mixed
- $hasTrailingSlash : bool
- $hasTrailingVar : bool
- $conditions : array<string|int, mixed>
Return values
array<string|int, mixed> —compileStaticPrefixCollection()
Compiles a regexp tree of subpatterns that matches nested same-prefix routes.
private
compileStaticPrefixCollection(StaticPrefixCollection $tree, stdClass $state, int $prefixLen, array<string|int, mixed> &$conditions) : string
Parameters
- $tree : StaticPrefixCollection
- $state : stdClass
-
A simple state object that keeps track of the progress of the compilation, and gathers the generated switch's "case" and "default" statements
- $prefixLen : int
- $conditions : array<string|int, mixed>
Return values
string —compileStaticRoutes()
Compiles static routes in a switch statement.
private
compileStaticRoutes(array<string|int, mixed> $staticRoutes, array<string|int, mixed> &$conditions) : array<string|int, mixed>
Condition-less paths are put in a static array in the switch's default, with generic matching logic. Paths that can match two or more routes, or have user-specified conditions are put in separate switch's cases.
Parameters
- $staticRoutes : array<string|int, mixed>
- $conditions : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —generateCompiledRoutes()
private
generateCompiledRoutes() : string
Return values
string —getExpressionLanguage()
private
getExpressionLanguage() : ExpressionLanguage
Return values
ExpressionLanguage —groupStaticRoutes()
Splits static routes from dynamic routes, so that they can be matched first, using a simple switch.
private
groupStaticRoutes(RouteCollection $collection) : array<string|int, mixed>
Parameters
- $collection : RouteCollection
Return values
array<string|int, mixed> —indent()
private
indent(string $code[, int $level = 1 ]) : string
Parameters
- $code : string
- $level : int = 1