@@ -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
$ route = null ;
116
116
$ locale = $ parameters ['_locale ' ]
@@ -141,7 +141,7 @@ public function generate($name, $parameters = array(), $referenceType = self::AB
141
141
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
142
142
* it does not match the requirement
143
143
*/
144
- protected function doGenerate ($ variables , $ defaults , $ requirements , $ tokens , $ parameters , $ name , $ referenceType , $ hostTokens , array $ requiredSchemes = array () )
144
+ protected function doGenerate ($ variables , $ defaults , $ requirements , $ tokens , $ parameters , $ name , $ referenceType , $ hostTokens , array $ requiredSchemes = [] )
145
145
{
146
146
$ variables = array_flip ($ variables );
147
147
$ mergedParams = array_replace ($ defaults , $ this ->context ->getParameters (), $ parameters );
@@ -165,11 +165,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
165
165
// check requirement
166
166
if (null !== $ this ->strictRequirements && !preg_match ('#^ ' .$ token [2 ].'$# ' .(empty ($ token [4 ]) ? '' : 'u ' ), $ mergedParams [$ varName ])) {
167
167
if ($ this ->strictRequirements ) {
168
- throw new InvalidParameterException (strtr ($ message , array ( '{parameter} ' => $ varName , '{route} ' => $ name , '{expected} ' => $ token [2 ], '{given} ' => $ mergedParams [$ varName ]) ));
168
+ throw new InvalidParameterException (strtr ($ message , [ '{parameter} ' => $ varName , '{route} ' => $ name , '{expected} ' => $ token [2 ], '{given} ' => $ mergedParams [$ varName ]] ));
169
169
}
170
170
171
171
if ($ this ->logger ) {
172
- $ this ->logger ->error ($ message , array ( 'parameter ' => $ varName , 'route ' => $ name , 'expected ' => $ token [2 ], 'given ' => $ mergedParams [$ varName ]) );
172
+ $ this ->logger ->error ($ message , [ 'parameter ' => $ varName , 'route ' => $ name , 'expected ' => $ token [2 ], 'given ' => $ mergedParams [$ varName ]] );
173
173
}
174
174
175
175
return ;
@@ -195,7 +195,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
195
195
// the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3
196
196
// so we need to encode them as they are not used for this purpose here
197
197
// otherwise we would generate a URI that, when followed by a user agent (e.g. browser), does not match this route
198
- $ url = strtr ($ url , array ( '/../ ' => '/%2E%2E/ ' , '/./ ' => '/%2E/ ' ) );
198
+ $ url = strtr ($ url , [ '/../ ' => '/%2E%2E/ ' , '/./ ' => '/%2E/ ' ] );
199
199
if ('/.. ' === substr ($ url , -3 )) {
200
200
$ url = substr ($ url , 0 , -2 ).'%2E%2E ' ;
201
201
} elseif ('/. ' === substr ($ url , -2 )) {
@@ -219,11 +219,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
219
219
if ('variable ' === $ token [0 ]) {
220
220
if (null !== $ this ->strictRequirements && !preg_match ('#^ ' .$ token [2 ].'$#i ' .(empty ($ token [4 ]) ? '' : 'u ' ), $ mergedParams [$ token [3 ]])) {
221
221
if ($ this ->strictRequirements ) {
222
- throw new InvalidParameterException (strtr ($ message , array ( '{parameter} ' => $ token [3 ], '{route} ' => $ name , '{expected} ' => $ token [2 ], '{given} ' => $ mergedParams [$ token [3 ]]) ));
222
+ throw new InvalidParameterException (strtr ($ message , [ '{parameter} ' => $ token [3 ], '{route} ' => $ name , '{expected} ' => $ token [2 ], '{given} ' => $ mergedParams [$ token [3 ]]] ));
223
223
}
224
224
225
225
if ($ this ->logger ) {
226
- $ this ->logger ->error ($ message , array ( 'parameter ' => $ token [3 ], 'route ' => $ name , 'expected ' => $ token [2 ], 'given ' => $ mergedParams [$ token [3 ]]) );
226
+ $ this ->logger ->error ($ message , [ 'parameter ' => $ token [3 ], 'route ' => $ name , 'expected ' => $ token [2 ], 'given ' => $ mergedParams [$ token [3 ]]] );
227
227
}
228
228
229
229
return ;
@@ -277,11 +277,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
277
277
if ($ extra && $ query = http_build_query ($ extra , '' , '& ' , PHP_QUERY_RFC3986 )) {
278
278
// "/" and "?" can be left decoded for better user experience, see
279
279
// http://tools.ietf.org/html/rfc3986#section-3.4
280
- $ url .= '? ' .strtr ($ query , array ( '%2F ' => '/ ' ) );
280
+ $ url .= '? ' .strtr ($ query , [ '%2F ' => '/ ' ] );
281
281
}
282
282
283
283
if ('' !== $ fragment ) {
284
- $ url .= '# ' .strtr (rawurlencode ($ fragment ), array ( '%2F ' => '/ ' , '%3F ' => '? ' ) );
284
+ $ url .= '# ' .strtr (rawurlencode ($ fragment ), [ '%2F ' => '/ ' , '%3F ' => '? ' ] );
285
285
}
286
286
287
287
return $ url ;
0 commit comments