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