Skip to content

Commit 1b9c105

Browse files
committed
Merge branch '3.4' into 4.1
* 3.4: fixed CS fixed short array CS in comments fixed CS in ExpressionLanguage fixtures fixed CS in generated files fixed CS on generated container files fixed CS on Form PHP templates fixed CS on YAML fixtures fixed fixtures switched array() to []
2 parents 9708dbe + 76f0eb1 commit 1b9c105

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+630
-630
lines changed

Annotation/Route.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ class Route
2424
private $path;
2525
private $localizedPaths = array();
2626
private $name;
27-
private $requirements = array();
28-
private $options = array();
29-
private $defaults = array();
27+
private $requirements = [];
28+
private $options = [];
29+
private $defaults = [];
3030
private $host;
31-
private $methods = array();
32-
private $schemes = array();
31+
private $methods = [];
32+
private $schemes = [];
3333
private $condition;
3434

3535
/**
@@ -134,7 +134,7 @@ public function getDefaults()
134134

135135
public function setSchemes($schemes)
136136
{
137-
$this->schemes = \is_array($schemes) ? $schemes : array($schemes);
137+
$this->schemes = \is_array($schemes) ? $schemes : [$schemes];
138138
}
139139

140140
public function getSchemes()
@@ -144,7 +144,7 @@ public function getSchemes()
144144

145145
public function setMethods($methods)
146146
{
147-
$this->methods = \is_array($methods) ? $methods : array($methods);
147+
$this->methods = \is_array($methods) ? $methods : [$methods];
148148
}
149149

150150
public function getMethods()

CHANGELOG.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ CHANGELOG
4747
Before:
4848

4949
```php
50-
$router->generate('blog_show', array('slug' => 'my-blog-post'), true);
50+
$router->generate('blog_show', ['slug' => 'my-blog-post'], true);
5151
```
5252

5353
After:
5454

5555
```php
5656
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
5757

58-
$router->generate('blog_show', array('slug' => 'my-blog-post'), UrlGeneratorInterface::ABSOLUTE_URL);
58+
$router->generate('blog_show', ['slug' => 'my-blog-post'], UrlGeneratorInterface::ABSOLUTE_URL);
5959
```
6060

6161
2.5.0
@@ -120,7 +120,7 @@ CHANGELOG
120120
```php
121121
$route = new Route();
122122
$route->setPath('/article/{id}');
123-
$route->setMethods(array('POST', 'PUT'));
123+
$route->setMethods(['POST', 'PUT']);
124124
$route->setSchemes('https');
125125
```
126126

@@ -175,10 +175,10 @@ CHANGELOG
175175
used with a single parameter. The other params `$prefix`, `$default`, `$requirements` and `$options`
176176
will still work, but have been deprecated. The `addPrefix` method should be used for this
177177
use-case instead.
178-
Before: `$parentCollection->addCollection($collection, '/prefix', array(...), array(...))`
178+
Before: `$parentCollection->addCollection($collection, '/prefix', [...], [...])`
179179
After:
180180
```php
181-
$collection->addPrefix('/prefix', array(...), array(...));
181+
$collection->addPrefix('/prefix', [...], [...]);
182182
$parentCollection->addCollection($collection);
183183
```
184184
* added support for the method default argument values when defining a @Route
@@ -203,7 +203,7 @@ CHANGELOG
203203
(only relevant if you implemented your own RouteCompiler).
204204
* Added possibility to generate relative paths and network paths in the UrlGenerator, e.g.
205205
"../parent-file" and "//example.com/dir/file". The third parameter in
206-
`UrlGeneratorInterface::generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)`
206+
`UrlGeneratorInterface::generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)`
207207
now accepts more values and you should use the constants defined in `UrlGeneratorInterface` for
208208
claritiy. The old method calls with a Boolean parameter will continue to work because they
209209
equal the signature using the constants.

DependencyInjection/RoutingResolverPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function process(ContainerBuilder $container)
4343
$definition = $container->getDefinition($this->resolverServiceId);
4444

4545
foreach ($this->findAndSortTaggedServices($this->loaderTag, $container) as $id) {
46-
$definition->addMethodCall('addLoader', array(new Reference($id)));
46+
$definition->addMethodCall('addLoader', [new Reference($id)]);
4747
}
4848
}
4949
}

Exception/MethodNotAllowedException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class MethodNotAllowedException extends \RuntimeException implements ExceptionInterface
2222
{
23-
protected $allowedMethods = array();
23+
protected $allowedMethods = [];
2424

2525
public function __construct(array $allowedMethods, string $message = null, int $code = 0, \Exception $previous = null)
2626
{

Generator/Dumper/GeneratorDumperInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface GeneratorDumperInterface
2828
*
2929
* @return string Executable code
3030
*/
31-
public function dump(array $options = array());
31+
public function dump(array $options = []);
3232

3333
/**
3434
* Gets the routes to dump.

Generator/Dumper/PhpGeneratorDumper.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ class PhpGeneratorDumper extends GeneratorDumper
3333
*
3434
* @return string A PHP class representing the generator class
3535
*/
36-
public function dump(array $options = array())
36+
public function dump(array $options = [])
3737
{
38-
$options = array_merge(array(
38+
$options = array_merge([
3939
'class' => 'ProjectUrlGenerator',
4040
'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
41-
), $options);
41+
], $options);
4242

4343
return <<<EOF
4444
<?php
@@ -80,11 +80,11 @@ public function __construct(RequestContext \$context, LoggerInterface \$logger =
8080
*/
8181
private function generateDeclaredRoutes()
8282
{
83-
$routes = "array(\n";
83+
$routes = "[\n";
8484
foreach ($this->getRoutes()->all() as $name => $route) {
8585
$compiledRoute = $route->compile();
8686

87-
$properties = array();
87+
$properties = [];
8888
$properties[] = $compiledRoute->getVariables();
8989
$properties[] = $route->getDefaults();
9090
$properties[] = $route->getRequirements();
@@ -94,7 +94,7 @@ private function generateDeclaredRoutes()
9494

9595
$routes .= sprintf(" '%s' => %s,\n", $name, PhpMatcherDumper::export($properties));
9696
}
97-
$routes .= ' )';
97+
$routes .= ' ]';
9898

9999
return $routes;
100100
}
@@ -107,7 +107,7 @@ private function generateDeclaredRoutes()
107107
private function generateGenerateMethod()
108108
{
109109
return <<<'EOF'
110-
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
110+
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
111111
{
112112
$locale = $parameters['_locale']
113113
?? $this->context->getParameter('_locale')

Generator/UrlGenerator.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
4747
* "?" and "#" (would be interpreted wrongly as query and fragment identifier),
4848
* "'" and """ (are used as delimiters in HTML).
4949
*/
50-
protected $decodedChars = array(
50+
protected $decodedChars = [
5151
// the slash can be used to designate a hierarchical structure and we want allow using it with this meaning
5252
// some webservers don't allow the slash in encoded form in the path for security reasons anyway
5353
// 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
6565
'%21' => '!',
6666
'%2A' => '*',
6767
'%7C' => '|',
68-
);
68+
];
6969

7070
public function __construct(RouteCollection $routes, RequestContext $context, LoggerInterface $logger = null, string $defaultLocale = null)
7171
{
@@ -110,7 +110,7 @@ public function isStrictRequirements()
110110
/**
111111
* {@inheritdoc}
112112
*/
113-
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
113+
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
114114
{
115115
$locale = $parameters['_locale']
116116
?? $this->context->getParameter('_locale')
@@ -133,7 +133,7 @@ public function generate($name, $parameters = array(), $referenceType = self::AB
133133
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
134134
* it does not match the requirement
135135
*/
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 = [])
137137
{
138138
$variables = array_flip($variables);
139139
$mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters);
@@ -152,11 +152,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
152152
// check requirement
153153
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
154154
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]]]));
156156
}
157157

158158
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]]]);
160160
}
161161

162162
return;
@@ -182,7 +182,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
182182
// the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3
183183
// so we need to encode them as they are not used for this purpose here
184184
// 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/']);
186186
if ('/..' === substr($url, -3)) {
187187
$url = substr($url, 0, -2).'%2E%2E';
188188
} elseif ('/.' === substr($url, -2)) {
@@ -206,11 +206,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
206206
if ('variable' === $token[0]) {
207207
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#i'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
208208
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]]]));
210210
}
211211

212212
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]]]);
214214
}
215215

216216
return;
@@ -264,11 +264,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
264264
if ($extra && $query = http_build_query($extra, '', '&', PHP_QUERY_RFC3986)) {
265265
// "/" and "?" can be left decoded for better user experience, see
266266
// http://tools.ietf.org/html/rfc3986#section-3.4
267-
$url .= '?'.strtr($query, array('%2F' => '/'));
267+
$url .= '?'.strtr($query, ['%2F' => '/']);
268268
}
269269

270270
if ('' !== $fragment) {
271-
$url .= '#'.strtr(rawurlencode($fragment), array('%2F' => '/', '%3F' => '?'));
271+
$url .= '#'.strtr(rawurlencode($fragment), ['%2F' => '/', '%3F' => '?']);
272272
}
273273

274274
return $url;

Generator/UrlGeneratorInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,5 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
8282
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
8383
* it does not match the requirement
8484
*/
85-
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH);
85+
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH);
8686
}

Loader/AnnotationFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected function findClass($file)
104104

105105
if (true === $namespace && T_STRING === $token[0]) {
106106
$namespace = $token[1];
107-
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], array(T_NS_SEPARATOR, T_STRING))) {
107+
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], [T_NS_SEPARATOR, T_STRING])) {
108108
$namespace .= $tokens[$i][1];
109109
}
110110
$token = $tokens[$i];
@@ -121,7 +121,7 @@ protected function findClass($file)
121121
if (T_DOUBLE_COLON === $tokens[$j][0] || T_NEW === $tokens[$j][0]) {
122122
$skipClassToken = true;
123123
break;
124-
} elseif (!\in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
124+
} elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) {
125125
break;
126126
}
127127
}

Loader/Configurator/Traits/RouteTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ final public function methods(array $methods)
120120
*/
121121
final public function controller($controller)
122122
{
123-
$this->route->addDefaults(array('_controller' => $controller));
123+
$this->route->addDefaults(['_controller' => $controller]);
124124

125125
return $this;
126126
}

0 commit comments

Comments
 (0)