@@ -47,7 +47,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
47
47
* "?" and "#" (would be interpreted wrongly as query and fragment identifier),
48
48
* "'" and """ (are used as delimiters in HTML).
49
49
*/
50
- protected $ decodedChars = array (
50
+ protected $ decodedChars = [
51
51
// the slash can be used to designate a hierarchical structure and we want allow using it with this meaning
52
52
// some webservers don't allow the slash in encoded form in the path for security reasons anyway
53
53
// see http://stackoverflow.com/questions/4069002/http-400-if-2f-part-of-get-url-in-jboss
@@ -65,7 +65,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
65
65
'%21 ' => '! ' ,
66
66
'%2A ' => '* ' ,
67
67
'%7C ' => '| ' ,
68
- ) ;
68
+ ] ;
69
69
70
70
public function __construct (RouteCollection $ routes , RequestContext $ context , LoggerInterface $ logger = null , string $ defaultLocale = null )
71
71
{
@@ -110,7 +110,7 @@ public function isStrictRequirements()
110
110
/**
111
111
* {@inheritdoc}
112
112
*/
113
- public function generate ($ name , $ parameters = array () , $ referenceType = self ::ABSOLUTE_PATH )
113
+ public function generate ($ name , $ parameters = [] , $ referenceType = self ::ABSOLUTE_PATH )
114
114
{
115
115
$ locale = $ parameters ['_locale ' ]
116
116
?? $ this ->context ->getParameter ('_locale ' )
@@ -133,7 +133,7 @@ public function generate($name, $parameters = array(), $referenceType = self::AB
133
133
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
134
134
* it does not match the requirement
135
135
*/
136
- protected function doGenerate ($ variables , $ defaults , $ requirements , $ tokens , $ parameters , $ name , $ referenceType , $ hostTokens , array $ requiredSchemes = array () )
136
+ protected function doGenerate ($ variables , $ defaults , $ requirements , $ tokens , $ parameters , $ name , $ referenceType , $ hostTokens , array $ requiredSchemes = [] )
137
137
{
138
138
$ variables = array_flip ($ variables );
139
139
$ mergedParams = array_replace ($ defaults , $ this ->context ->getParameters (), $ parameters );
@@ -152,11 +152,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
152
152
// check requirement
153
153
if (null !== $ this ->strictRequirements && !preg_match ('#^ ' .$ token [2 ].'$# ' .(empty ($ token [4 ]) ? '' : 'u ' ), $ mergedParams [$ token [3 ]])) {
154
154
if ($ this ->strictRequirements ) {
155
- throw new InvalidParameterException (strtr ($ message , array ( '{parameter} ' => $ token [3 ], '{route} ' => $ name , '{expected} ' => $ token [2 ], '{given} ' => $ mergedParams [$ token [3 ]]) ));
155
+ throw new InvalidParameterException (strtr ($ message , [ '{parameter} ' => $ token [3 ], '{route} ' => $ name , '{expected} ' => $ token [2 ], '{given} ' => $ mergedParams [$ token [3 ]]] ));
156
156
}
157
157
158
158
if ($ this ->logger ) {
159
- $ this ->logger ->error ($ message , array ( 'parameter ' => $ token [3 ], 'route ' => $ name , 'expected ' => $ token [2 ], 'given ' => $ mergedParams [$ token [3 ]]) );
159
+ $ this ->logger ->error ($ message , [ 'parameter ' => $ token [3 ], 'route ' => $ name , 'expected ' => $ token [2 ], 'given ' => $ mergedParams [$ token [3 ]]] );
160
160
}
161
161
162
162
return ;
@@ -182,7 +182,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
182
182
// the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3
183
183
// so we need to encode them as they are not used for this purpose here
184
184
// otherwise we would generate a URI that, when followed by a user agent (e.g. browser), does not match this route
185
- $ url = strtr ($ url , array ( '/../ ' => '/%2E%2E/ ' , '/./ ' => '/%2E/ ' ) );
185
+ $ url = strtr ($ url , [ '/../ ' => '/%2E%2E/ ' , '/./ ' => '/%2E/ ' ] );
186
186
if ('/.. ' === substr ($ url , -3 )) {
187
187
$ url = substr ($ url , 0 , -2 ).'%2E%2E ' ;
188
188
} elseif ('/. ' === substr ($ url , -2 )) {
@@ -206,11 +206,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
206
206
if ('variable ' === $ token [0 ]) {
207
207
if (null !== $ this ->strictRequirements && !preg_match ('#^ ' .$ token [2 ].'$#i ' .(empty ($ token [4 ]) ? '' : 'u ' ), $ mergedParams [$ token [3 ]])) {
208
208
if ($ this ->strictRequirements ) {
209
- throw new InvalidParameterException (strtr ($ message , array ( '{parameter} ' => $ token [3 ], '{route} ' => $ name , '{expected} ' => $ token [2 ], '{given} ' => $ mergedParams [$ token [3 ]]) ));
209
+ throw new InvalidParameterException (strtr ($ message , [ '{parameter} ' => $ token [3 ], '{route} ' => $ name , '{expected} ' => $ token [2 ], '{given} ' => $ mergedParams [$ token [3 ]]] ));
210
210
}
211
211
212
212
if ($ this ->logger ) {
213
- $ this ->logger ->error ($ message , array ( 'parameter ' => $ token [3 ], 'route ' => $ name , 'expected ' => $ token [2 ], 'given ' => $ mergedParams [$ token [3 ]]) );
213
+ $ this ->logger ->error ($ message , [ 'parameter ' => $ token [3 ], 'route ' => $ name , 'expected ' => $ token [2 ], 'given ' => $ mergedParams [$ token [3 ]]] );
214
214
}
215
215
216
216
return ;
@@ -264,11 +264,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
264
264
if ($ extra && $ query = http_build_query ($ extra , '' , '& ' , PHP_QUERY_RFC3986 )) {
265
265
// "/" and "?" can be left decoded for better user experience, see
266
266
// http://tools.ietf.org/html/rfc3986#section-3.4
267
- $ url .= '? ' .strtr ($ query , array ( '%2F ' => '/ ' ) );
267
+ $ url .= '? ' .strtr ($ query , [ '%2F ' => '/ ' ] );
268
268
}
269
269
270
270
if ('' !== $ fragment ) {
271
- $ url .= '# ' .strtr (rawurlencode ($ fragment ), array ( '%2F ' => '/ ' , '%3F ' => '? ' ) );
271
+ $ url .= '# ' .strtr (rawurlencode ($ fragment ), [ '%2F ' => '/ ' , '%3F ' => '? ' ] );
272
272
}
273
273
274
274
return $ url ;
0 commit comments