@@ -17,7 +17,7 @@ public function __construct(RequestContext $context)
17
17
18
18
public function match ($ rawPathinfo )
19
19
{
20
- $ allow = array () ;
20
+ $ allow = [] ;
21
21
$ pathinfo = rawurldecode ($ rawPathinfo );
22
22
$ trimmedPathinfo = rtrim ($ pathinfo , '/ ' );
23
23
$ context = $ this ->context ;
@@ -31,7 +31,7 @@ public function match($rawPathinfo)
31
31
if (0 === strpos ($ pathinfo , '/foo ' )) {
32
32
// foo
33
33
if (preg_match ('#^/foo/(?P<bar>baz|symfony)$#sD ' , $ pathinfo , $ matches )) {
34
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'foo ' ) ), array ( 'def ' => 'test ' ,));
34
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'foo ' ] ), array ( 'def ' => 'test ' ,));
35
35
}
36
36
37
37
// foofoo
@@ -44,9 +44,9 @@ public function match($rawPathinfo)
44
44
elseif (0 === strpos ($ pathinfo , '/bar ' )) {
45
45
// bar
46
46
if (preg_match ('#^/bar/(?P<foo>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
47
- $ ret = $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'bar ' ) ), array ());
48
- if (!in_array ($ canonicalMethod , array ( 'GET ' , 'HEAD ' ) )) {
49
- $ allow = array_merge ($ allow , array ( 'GET ' , 'HEAD ' ) );
47
+ $ ret = $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'bar ' ] ), array ());
48
+ if (!in_array ($ canonicalMethod , [ 'GET ' , 'HEAD ' ] )) {
49
+ $ allow = array_merge ($ allow , [ 'GET ' , 'HEAD ' ] );
50
50
goto not_bar;
51
51
}
52
52
@@ -56,9 +56,9 @@ public function match($rawPathinfo)
56
56
57
57
// barhead
58
58
if (0 === strpos ($ pathinfo , '/barhead ' ) && preg_match ('#^/barhead/(?P<foo>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
59
- $ ret = $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'barhead ' ) ), array ());
60
- if (!in_array ($ canonicalMethod , array ( 'GET ' ) )) {
61
- $ allow = array_merge ($ allow , array ( 'GET ' ) );
59
+ $ ret = $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'barhead ' ] ), array ());
60
+ if (!in_array ($ canonicalMethod , [ 'GET ' ] )) {
61
+ $ allow = array_merge ($ allow , [ 'GET ' ] );
62
62
goto not_barhead;
63
63
}
64
64
@@ -72,31 +72,31 @@ public function match($rawPathinfo)
72
72
if (0 === strpos ($ pathinfo , '/test/baz ' )) {
73
73
// baz
74
74
if ('/test/baz ' === $ pathinfo ) {
75
- return array ( '_route ' => 'baz ' ) ;
75
+ return [ '_route ' => 'baz ' ] ;
76
76
}
77
77
78
78
// baz2
79
79
if ('/test/baz.html ' === $ pathinfo ) {
80
- return array ( '_route ' => 'baz2 ' ) ;
80
+ return [ '_route ' => 'baz2 ' ] ;
81
81
}
82
82
83
83
// baz3
84
84
if ('/test/baz3/ ' === $ pathinfo ) {
85
- return array ( '_route ' => 'baz3 ' ) ;
85
+ return [ '_route ' => 'baz3 ' ] ;
86
86
}
87
87
88
88
}
89
89
90
90
// baz4
91
91
if (preg_match ('#^/test/(?P<foo>[^/]++)/$#sD ' , $ pathinfo , $ matches )) {
92
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'baz4 ' ) ), array ());
92
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'baz4 ' ] ), array ());
93
93
}
94
94
95
95
// baz5
96
96
if (preg_match ('#^/test/(?P<foo>[^/]++)/$#sD ' , $ pathinfo , $ matches )) {
97
- $ ret = $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'baz5 ' ) ), array ());
98
- if (!in_array ($ requestMethod , array ( 'POST ' ) )) {
99
- $ allow = array_merge ($ allow , array ( 'POST ' ) );
97
+ $ ret = $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'baz5 ' ] ), array ());
98
+ if (!in_array ($ requestMethod , [ 'POST ' ] )) {
99
+ $ allow = array_merge ($ allow , [ 'POST ' ] );
100
100
goto not_baz5;
101
101
}
102
102
@@ -106,9 +106,9 @@ public function match($rawPathinfo)
106
106
107
107
// baz.baz6
108
108
if (preg_match ('#^/test/(?P<foo>[^/]++)/$#sD ' , $ pathinfo , $ matches )) {
109
- $ ret = $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'baz.baz6 ' ) ), array ());
110
- if (!in_array ($ requestMethod , array ( 'PUT ' ) )) {
111
- $ allow = array_merge ($ allow , array ( 'PUT ' ) );
109
+ $ ret = $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'baz.baz6 ' ] ), array ());
110
+ if (!in_array ($ requestMethod , [ 'PUT ' ] )) {
111
+ $ allow = array_merge ($ allow , [ 'PUT ' ] );
112
112
goto not_bazbaz6;
113
113
}
114
114
@@ -120,42 +120,42 @@ public function match($rawPathinfo)
120
120
121
121
// quoter
122
122
if (preg_match ('#^/(?P<quoter>[ \']+)$#sD ' , $ pathinfo , $ matches )) {
123
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'quoter ' ) ), array ());
123
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'quoter ' ] ), array ());
124
124
}
125
125
126
126
// space
127
127
if ('/spa ce ' === $ pathinfo ) {
128
- return array ( '_route ' => 'space ' ) ;
128
+ return [ '_route ' => 'space ' ] ;
129
129
}
130
130
131
131
if (0 === strpos ($ pathinfo , '/a ' )) {
132
132
if (0 === strpos ($ pathinfo , '/a/b \'b ' )) {
133
133
// foo1
134
134
if (preg_match ('#^/a/b \'b/(?P<foo>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
135
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'foo1 ' ) ), array ());
135
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'foo1 ' ] ), array ());
136
136
}
137
137
138
138
// bar1
139
139
if (preg_match ('#^/a/b \'b/(?P<bar>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
140
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'bar1 ' ) ), array ());
140
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'bar1 ' ] ), array ());
141
141
}
142
142
143
143
}
144
144
145
145
// overridden
146
146
if (preg_match ('#^/a/(?P<var>.*)$#sD ' , $ pathinfo , $ matches )) {
147
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'overridden ' ) ), array ());
147
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'overridden ' ] ), array ());
148
148
}
149
149
150
150
if (0 === strpos ($ pathinfo , '/a/b \'b ' )) {
151
151
// foo2
152
152
if (preg_match ('#^/a/b \'b/(?P<foo1>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
153
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'foo2 ' ) ), array ());
153
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'foo2 ' ] ), array ());
154
154
}
155
155
156
156
// bar2
157
157
if (preg_match ('#^/a/b \'b/(?P<bar1>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
158
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'bar2 ' ) ), array ());
158
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'bar2 ' ] ), array ());
159
159
}
160
160
161
161
}
@@ -165,40 +165,40 @@ public function match($rawPathinfo)
165
165
elseif (0 === strpos ($ pathinfo , '/multi ' )) {
166
166
// helloWorld
167
167
if (0 === strpos ($ pathinfo , '/multi/hello ' ) && preg_match ('#^/multi/hello(?:/(?P<who>[^/]++))?$#sD ' , $ pathinfo , $ matches )) {
168
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'helloWorld ' ) ), array ( 'who ' => 'World! ' ,));
168
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'helloWorld ' ] ), array ( 'who ' => 'World! ' ,));
169
169
}
170
170
171
171
// hey
172
172
if ('/multi/hey/ ' === $ pathinfo ) {
173
- return array ( '_route ' => 'hey ' ) ;
173
+ return [ '_route ' => 'hey ' ] ;
174
174
}
175
175
176
176
// overridden2
177
177
if ('/multi/new ' === $ pathinfo ) {
178
- return array ( '_route ' => 'overridden2 ' ) ;
178
+ return [ '_route ' => 'overridden2 ' ] ;
179
179
}
180
180
181
181
}
182
182
183
183
// foo3
184
184
if (preg_match ('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
185
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'foo3 ' ) ), array ());
185
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'foo3 ' ] ), array ());
186
186
}
187
187
188
188
// bar3
189
189
if (preg_match ('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
190
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'bar3 ' ) ), array ());
190
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'bar3 ' ] ), array ());
191
191
}
192
192
193
193
if (0 === strpos ($ pathinfo , '/aba ' )) {
194
194
// ababa
195
195
if ('/ababa ' === $ pathinfo ) {
196
- return array ( '_route ' => 'ababa ' ) ;
196
+ return [ '_route ' => 'ababa ' ] ;
197
197
}
198
198
199
199
// foo4
200
200
if (preg_match ('#^/aba/(?P<foo>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
201
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'foo4 ' ) ), array ());
201
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'foo4 ' ] ), array ());
202
202
}
203
203
204
204
}
@@ -208,65 +208,65 @@ public function match($rawPathinfo)
208
208
if (preg_match ('#^a \\.example \\.com$#sDi ' , $ host , $ hostMatches )) {
209
209
// route1
210
210
if ('/route1 ' === $ pathinfo ) {
211
- return array ( '_route ' => 'route1 ' ) ;
211
+ return [ '_route ' => 'route1 ' ] ;
212
212
}
213
213
214
214
// route2
215
215
if ('/c2/route2 ' === $ pathinfo ) {
216
- return array ( '_route ' => 'route2 ' ) ;
216
+ return [ '_route ' => 'route2 ' ] ;
217
217
}
218
218
219
219
}
220
220
221
221
if (preg_match ('#^b \\.example \\.com$#sDi ' , $ host , $ hostMatches )) {
222
222
// route3
223
223
if ('/c2/route3 ' === $ pathinfo ) {
224
- return array ( '_route ' => 'route3 ' ) ;
224
+ return [ '_route ' => 'route3 ' ] ;
225
225
}
226
226
227
227
}
228
228
229
229
if (preg_match ('#^a \\.example \\.com$#sDi ' , $ host , $ hostMatches )) {
230
230
// route4
231
231
if ('/route4 ' === $ pathinfo ) {
232
- return array ( '_route ' => 'route4 ' ) ;
232
+ return [ '_route ' => 'route4 ' ] ;
233
233
}
234
234
235
235
}
236
236
237
237
if (preg_match ('#^c \\.example \\.com$#sDi ' , $ host , $ hostMatches )) {
238
238
// route5
239
239
if ('/route5 ' === $ pathinfo ) {
240
- return array ( '_route ' => 'route5 ' ) ;
240
+ return [ '_route ' => 'route5 ' ] ;
241
241
}
242
242
243
243
}
244
244
245
245
// route6
246
246
if ('/route6 ' === $ pathinfo ) {
247
- return array ( '_route ' => 'route6 ' ) ;
247
+ return [ '_route ' => 'route6 ' ] ;
248
248
}
249
249
250
250
if (preg_match ('#^(?P<var1>[^ \\.]++) \\.example \\.com$#sDi ' , $ host , $ hostMatches )) {
251
251
if (0 === strpos ($ pathinfo , '/route1 ' )) {
252
252
// route11
253
253
if ('/route11 ' === $ pathinfo ) {
254
- return $ this ->mergeDefaults (array_replace ($ hostMatches , array ( '_route ' => 'route11 ' ) ), array ());
254
+ return $ this ->mergeDefaults (array_replace ($ hostMatches , [ '_route ' => 'route11 ' ] ), array ());
255
255
}
256
256
257
257
// route12
258
258
if ('/route12 ' === $ pathinfo ) {
259
- return $ this ->mergeDefaults (array_replace ($ hostMatches , array ( '_route ' => 'route12 ' ) ), array ( 'var1 ' => 'val ' ,));
259
+ return $ this ->mergeDefaults (array_replace ($ hostMatches , [ '_route ' => 'route12 ' ] ), array ( 'var1 ' => 'val ' ,));
260
260
}
261
261
262
262
// route13
263
263
if (0 === strpos ($ pathinfo , '/route13 ' ) && preg_match ('#^/route13/(?P<name>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
264
- return $ this ->mergeDefaults (array_replace ($ hostMatches , $ matches , array ( '_route ' => 'route13 ' ) ), array ());
264
+ return $ this ->mergeDefaults (array_replace ($ hostMatches , $ matches , [ '_route ' => 'route13 ' ] ), array ());
265
265
}
266
266
267
267
// route14
268
268
if (0 === strpos ($ pathinfo , '/route14 ' ) && preg_match ('#^/route14/(?P<name>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
269
- return $ this ->mergeDefaults (array_replace ($ hostMatches , $ matches , array ( '_route ' => 'route14 ' ) ), array ( 'var1 ' => 'val ' ,));
269
+ return $ this ->mergeDefaults (array_replace ($ hostMatches , $ matches , [ '_route ' => 'route14 ' ] ), array ( 'var1 ' => 'val ' ,));
270
270
}
271
271
272
272
}
@@ -276,35 +276,35 @@ public function match($rawPathinfo)
276
276
if (preg_match ('#^c \\.example \\.com$#sDi ' , $ host , $ hostMatches )) {
277
277
// route15
278
278
if (0 === strpos ($ pathinfo , '/route15 ' ) && preg_match ('#^/route15/(?P<name>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
279
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'route15 ' ) ), array ());
279
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'route15 ' ] ), array ());
280
280
}
281
281
282
282
}
283
283
284
284
// route16
285
285
if (0 === strpos ($ pathinfo , '/route16 ' ) && preg_match ('#^/route16/(?P<name>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
286
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'route16 ' ) ), array ( 'var1 ' => 'val ' ,));
286
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'route16 ' ] ), array ( 'var1 ' => 'val ' ,));
287
287
}
288
288
289
289
// route17
290
290
if ('/route17 ' === $ pathinfo ) {
291
- return array ( '_route ' => 'route17 ' ) ;
291
+ return [ '_route ' => 'route17 ' ] ;
292
292
}
293
293
294
294
// a
295
295
if ('/a/a... ' === $ pathinfo ) {
296
- return array ( '_route ' => 'a ' ) ;
296
+ return [ '_route ' => 'a ' ] ;
297
297
}
298
298
299
299
if (0 === strpos ($ pathinfo , '/a/b ' )) {
300
300
// b
301
301
if (preg_match ('#^/a/b/(?P<var>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
302
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'b ' ) ), array ());
302
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'b ' ] ), array ());
303
303
}
304
304
305
305
// c
306
306
if (0 === strpos ($ pathinfo , '/a/b/c ' ) && preg_match ('#^/a/b/c/(?P<var>[^/]++)$#sD ' , $ pathinfo , $ matches )) {
307
- return $ this ->mergeDefaults (array_replace ($ matches , array ( '_route ' => 'c ' ) ), array ());
307
+ return $ this ->mergeDefaults (array_replace ($ matches , [ '_route ' => 'c ' ] ), array ());
308
308
}
309
309
310
310
}
0 commit comments