@@ -32,7 +32,7 @@ class PhpMatcherDumper extends MatcherDumper
32
32
/**
33
33
* @var ExpressionFunctionProviderInterface[]
34
34
*/
35
- private $ expressionLanguageProviders = array () ;
35
+ private $ expressionLanguageProviders = [] ;
36
36
37
37
/**
38
38
* Dumps a set of routes to a PHP class.
@@ -46,12 +46,12 @@ class PhpMatcherDumper extends MatcherDumper
46
46
*
47
47
* @return string A PHP class representing the matcher class
48
48
*/
49
- public function dump (array $ options = array () )
49
+ public function dump (array $ options = [] )
50
50
{
51
- $ options = array_replace (array (
51
+ $ options = array_replace ([
52
52
'class ' => 'ProjectUrlMatcher ' ,
53
53
'base_class ' => 'Symfony \\Component \\Routing \\Matcher \\UrlMatcher ' ,
54
- ) , $ options );
54
+ ] , $ options );
55
55
56
56
// trailing slash support is only enabled if we know how to redirect the user
57
57
$ interfaces = class_implements ($ options ['base_class ' ]);
@@ -98,7 +98,7 @@ private function generateProperties(): string
98
98
$ host = '/ ' .strtr (strrev ($ host ), '}.{ ' , '(/) ' );
99
99
}
100
100
101
- $ routes ->addRoute ($ host ?: '/(.*) ' , array ( $ name , $ route) );
101
+ $ routes ->addRoute ($ host ?: '/(.*) ' , [ $ name , $ route] );
102
102
}
103
103
104
104
if ($ matchHost ) {
@@ -111,7 +111,7 @@ private function generateProperties(): string
111
111
112
112
list ($ staticRoutes , $ dynamicRoutes ) = $ this ->groupStaticRoutes ($ routes );
113
113
114
- $ conditions = array ( null ) ;
114
+ $ conditions = [ null ] ;
115
115
$ code .= $ this ->compileStaticRoutes ($ staticRoutes , $ conditions );
116
116
$ chunkLimit = \count ($ dynamicRoutes );
117
117
@@ -154,7 +154,7 @@ private function generateProperties(): string
154
154
*/
155
155
private function groupStaticRoutes (RouteCollection $ collection ): array
156
156
{
157
- $ staticRoutes = $ dynamicRegex = array () ;
157
+ $ staticRoutes = $ dynamicRegex = [] ;
158
158
$ dynamicRoutes = new RouteCollection ();
159
159
160
160
foreach ($ collection ->all () as $ name => $ route ) {
@@ -175,20 +175,20 @@ private function groupStaticRoutes(RouteCollection $collection): array
175
175
}
176
176
foreach ($ dynamicRegex as list ($ hostRx , $ rx )) {
177
177
if (preg_match ($ rx , $ url ) && (!$ host || !$ hostRx || preg_match ($ hostRx , $ host ))) {
178
- $ dynamicRegex [] = array ( $ hostRegex , $ regex) ;
178
+ $ dynamicRegex [] = [ $ hostRegex , $ regex] ;
179
179
$ dynamicRoutes ->add ($ name , $ route );
180
180
continue 2 ;
181
181
}
182
182
}
183
183
184
- $ staticRoutes [$ url ][$ name ] = array ( $ route , $ hasTrailingSlash) ;
184
+ $ staticRoutes [$ url ][$ name ] = [ $ route , $ hasTrailingSlash] ;
185
185
} else {
186
- $ dynamicRegex [] = array ( $ hostRegex , $ regex) ;
186
+ $ dynamicRegex [] = [ $ hostRegex , $ regex] ;
187
187
$ dynamicRoutes ->add ($ name , $ route );
188
188
}
189
189
}
190
190
191
- return array ( $ staticRoutes , $ dynamicRoutes) ;
191
+ return [ $ staticRoutes , $ dynamicRoutes] ;
192
192
}
193
193
194
194
/**
@@ -245,14 +245,14 @@ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHo
245
245
return '' ;
246
246
}
247
247
$ code = '' ;
248
- $ state = (object ) array (
248
+ $ state = (object ) [
249
249
'regex ' => '' ,
250
250
'routes ' => '' ,
251
251
'mark ' => 0 ,
252
252
'markTail ' => 0 ,
253
- 'hostVars ' => array () ,
254
- 'vars ' => array () ,
255
- ) ;
253
+ 'hostVars ' => [] ,
254
+ 'vars ' => [] ,
255
+ ] ;
256
256
$ state ->getVars = static function ($ m ) use ($ state ) {
257
257
if ('_route ' === $ m [1 ]) {
258
258
return '?: ' ;
@@ -265,26 +265,26 @@ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHo
265
265
266
266
$ chunkSize = 0 ;
267
267
$ prev = null ;
268
- $ perModifiers = array () ;
268
+ $ perModifiers = [] ;
269
269
foreach ($ collection ->all () as $ name => $ route ) {
270
270
preg_match ('#[a-zA-Z]*$# ' , $ route ->compile ()->getRegex (), $ rx );
271
271
if ($ chunkLimit < ++$ chunkSize || $ prev !== $ rx [0 ] && $ route ->compile ()->getPathVariables ()) {
272
272
$ chunkSize = 1 ;
273
273
$ routes = new RouteCollection ();
274
- $ perModifiers [] = array ( $ rx [0 ], $ routes) ;
274
+ $ perModifiers [] = [ $ rx [0 ], $ routes] ;
275
275
$ prev = $ rx [0 ];
276
276
}
277
277
$ routes ->add ($ name , $ route );
278
278
}
279
279
280
280
foreach ($ perModifiers as list ($ modifiers , $ routes )) {
281
281
$ prev = false ;
282
- $ perHost = array () ;
282
+ $ perHost = [] ;
283
283
foreach ($ routes ->all () as $ name => $ route ) {
284
284
$ regex = $ route ->compile ()->getHostRegex ();
285
285
if ($ prev !== $ regex ) {
286
286
$ routes = new RouteCollection ();
287
- $ perHost [] = array ( $ regex , $ routes) ;
287
+ $ perHost [] = [ $ regex , $ routes] ;
288
288
$ prev = $ regex ;
289
289
}
290
290
$ routes ->add ($ name , $ route );
@@ -299,12 +299,12 @@ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHo
299
299
if ($ matchHost ) {
300
300
if ($ hostRegex ) {
301
301
preg_match ('#^.\^(.*)\$.[a-zA-Z]*$# ' , $ hostRegex , $ rx );
302
- $ state ->vars = array () ;
302
+ $ state ->vars = [] ;
303
303
$ hostRegex = '(?i: ' .preg_replace_callback ('#\?P<([^>]++)># ' , $ state ->getVars , $ rx [1 ]).')\. ' ;
304
304
$ state ->hostVars = $ state ->vars ;
305
305
} else {
306
306
$ hostRegex = '(?:(?:[^./]*+\.)++) ' ;
307
- $ state ->hostVars = array () ;
307
+ $ state ->hostVars = [] ;
308
308
}
309
309
$ state ->mark += \strlen ($ rx = ($ prev ? ') ' : '' )."| {$ hostRegex }(? " );
310
310
$ code .= "\n . " .self ::export ($ rx );
@@ -316,14 +316,14 @@ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHo
316
316
foreach ($ routes ->all () as $ name => $ route ) {
317
317
preg_match ('#^.\^(.*)\$.[a-zA-Z]*$# ' , $ route ->compile ()->getRegex (), $ rx );
318
318
319
- $ state ->vars = array () ;
319
+ $ state ->vars = [] ;
320
320
$ regex = preg_replace_callback ('#\?P<([^>]++)># ' , $ state ->getVars , $ rx [1 ]);
321
321
if ($ hasTrailingSlash = '/ ' !== $ regex && '/ ' === $ regex [-1 ]) {
322
322
$ regex = substr ($ regex , 0 , -1 );
323
323
}
324
324
$ hasTrailingVar = (bool ) preg_match ('#\{\w+\}/?$# ' , $ route ->getPath ());
325
325
326
- $ tree ->addRoute ($ regex , array ( $ name , $ regex , $ state ->vars , $ route , $ hasTrailingSlash , $ hasTrailingVar) );
326
+ $ tree ->addRoute ($ regex , [ $ name , $ regex , $ state ->vars , $ route , $ hasTrailingSlash , $ hasTrailingVar] );
327
327
}
328
328
329
329
$ code .= $ this ->compileStaticPrefixCollection ($ tree , $ state , 0 , $ conditions );
@@ -413,15 +413,15 @@ private function compileRoute(Route $route, string $name, $vars, bool $hasTraili
413
413
}
414
414
415
415
if ($ condition = $ route ->getCondition ()) {
416
- $ condition = $ this ->getExpressionLanguage ()->compile ($ condition , array ( 'context ' , 'request ' ) );
416
+ $ condition = $ this ->getExpressionLanguage ()->compile ($ condition , [ 'context ' , 'request ' ] );
417
417
$ condition = $ conditions [$ condition ] ?? $ conditions [$ condition ] = (false !== strpos ($ condition , '$request ' ) ? 1 : -1 ) * \count ($ conditions );
418
418
} else {
419
419
$ condition = 'null ' ;
420
420
}
421
421
422
422
return sprintf (
423
423
" array(%s, %s, %s, %s, %s, %s, %s), \n" ,
424
- self ::export (array ( '_route ' => $ name) + $ defaults ),
424
+ self ::export ([ '_route ' => $ name] + $ defaults ),
425
425
self ::export ($ vars ),
426
426
self ::export (array_flip ($ route ->getMethods ()) ?: null ),
427
427
self ::export (array_flip ($ route ->getSchemes ()) ?: null ),
0 commit comments