Skip to content

Commit c0bc2cc

Browse files
committed
Merge branch '4.2' into short-array-master
* 4.2: fixed CS fixed CS fixed tests fixed CS fixed CS 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 a00a77c + c6a8f6c commit c0bc2cc

File tree

75 files changed

+2260
-2260
lines changed

Some content is hidden

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

75 files changed

+2260
-2260
lines changed

Annotation/Route.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
class Route
2323
{
2424
private $path;
25-
private $localizedPaths = array();
25+
private $localizedPaths = [];
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
@@ -52,15 +52,15 @@ CHANGELOG
5252
Before:
5353

5454
```php
55-
$router->generate('blog_show', array('slug' => 'my-blog-post'), true);
55+
$router->generate('blog_show', ['slug' => 'my-blog-post'], true);
5656
```
5757

5858
After:
5959

6060
```php
6161
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
6262

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

6666
2.5.0
@@ -125,7 +125,7 @@ CHANGELOG
125125
```php
126126
$route = new Route();
127127
$route->setPath('/article/{id}');
128-
$route->setMethods(array('POST', 'PUT'));
128+
$route->setMethods(['POST', 'PUT']);
129129
$route->setSchemes('https');
130130
```
131131

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

CompiledRoute.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CompiledRoute implements \Serializable
3737
* @param array $hostVariables An array of host variables
3838
* @param array $variables An array of variables (variables defined in the path and in the host patterns)
3939
*/
40-
public function __construct(string $staticPrefix, string $regex, array $tokens, array $pathVariables, string $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array())
40+
public function __construct(string $staticPrefix, string $regex, array $tokens, array $pathVariables, string $hostRegex = null, array $hostTokens = [], array $hostVariables = [], array $variables = [])
4141
{
4242
$this->staticPrefix = $staticPrefix;
4343
$this->regex = $regex;
@@ -54,7 +54,7 @@ public function __construct(string $staticPrefix, string $regex, array $tokens,
5454
*/
5555
public function serialize()
5656
{
57-
return serialize(array(
57+
return serialize([
5858
'vars' => $this->variables,
5959
'path_prefix' => $this->staticPrefix,
6060
'path_regex' => $this->regex,
@@ -63,15 +63,15 @@ public function serialize()
6363
'host_regex' => $this->hostRegex,
6464
'host_tokens' => $this->hostTokens,
6565
'host_vars' => $this->hostVariables,
66-
));
66+
]);
6767
}
6868

6969
/**
7070
* {@inheritdoc}
7171
*/
7272
public function unserialize($serialized)
7373
{
74-
$data = unserialize($serialized, array('allowed_classes' => false));
74+
$data = unserialize($serialized, ['allowed_classes' => false]);
7575

7676
$this->variables = $data['vars'];
7777
$this->staticPrefix = $data['path_prefix'];

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/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/AnnotationClassLoader.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ protected function addRoute(RouteCollection $collection, $annot, $globals, \Refl
165165

166166
$path = $annot->getLocalizedPaths() ?: $annot->getPath();
167167
$prefix = $globals['localized_paths'] ?: $globals['path'];
168-
$paths = array();
168+
$paths = [];
169169

170170
if (\is_array($path)) {
171171
if (!\is_array($prefix)) {
@@ -312,18 +312,18 @@ protected function getGlobals(\ReflectionClass $class)
312312

313313
private function resetGlobals()
314314
{
315-
return array(
315+
return [
316316
'path' => null,
317-
'localized_paths' => array(),
318-
'requirements' => array(),
319-
'options' => array(),
320-
'defaults' => array(),
321-
'schemes' => array(),
322-
'methods' => array(),
317+
'localized_paths' => [],
318+
'requirements' => [],
319+
'options' => [],
320+
'defaults' => [],
321+
'schemes' => [],
322+
'methods' => [],
323323
'host' => '',
324324
'condition' => '',
325325
'name' => '',
326-
);
326+
];
327327
}
328328

329329
protected function createRoute($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition)

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/AddTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ trait AddTrait
3434
*/
3535
final public function add(string $name, $path): RouteConfigurator
3636
{
37-
$paths = array();
37+
$paths = [];
3838
$parentConfigurator = $this instanceof CollectionConfigurator ? $this : ($this instanceof RouteConfigurator ? $this->parentConfigurator : null);
3939

4040
if (\is_array($path)) {

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
}

Loader/ObjectRouteLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function load($resource, $type = null)
6363
throw new \LogicException(sprintf('%s:getServiceObject() must return an object: %s returned', \get_class($this), \gettype($loaderObject)));
6464
}
6565

66-
if (!\is_callable(array($loaderObject, $method))) {
66+
if (!\is_callable([$loaderObject, $method])) {
6767
throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s"', $method, \get_class($loaderObject), $resource));
6868
}
6969

Loader/XmlFileLoader.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $
171171
$imported = $this->import($resource, ('' !== $type ? $type : null), false, $file);
172172

173173
if (!\is_array($imported)) {
174-
$imported = array($imported);
174+
$imported = [$imported];
175175
}
176176

177177
foreach ($imported as $subCollection) {
@@ -261,12 +261,12 @@ protected function loadFile($file)
261261
*/
262262
private function parseConfigs(\DOMElement $node, $path)
263263
{
264-
$defaults = array();
265-
$requirements = array();
266-
$options = array();
264+
$defaults = [];
265+
$requirements = [];
266+
$options = [];
267267
$condition = null;
268-
$prefixes = array();
269-
$paths = array();
268+
$prefixes = [];
269+
$paths = [];
270270

271271
foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
272272
if ($node !== $n->parentNode) {
@@ -312,7 +312,7 @@ private function parseConfigs(\DOMElement $node, $path)
312312
$defaults['_controller'] = $controller;
313313
}
314314

315-
return array($defaults, $requirements, $options, $condition, $paths, $prefixes);
315+
return [$defaults, $requirements, $options, $condition, $paths, $prefixes];
316316
}
317317

318318
/**
@@ -376,7 +376,7 @@ private function parseDefaultNode(\DOMElement $node, $path)
376376
case 'string':
377377
return trim($node->nodeValue);
378378
case 'list':
379-
$list = array();
379+
$list = [];
380380

381381
foreach ($node->childNodes as $element) {
382382
if (!$element instanceof \DOMElement) {
@@ -392,7 +392,7 @@ private function parseDefaultNode(\DOMElement $node, $path)
392392

393393
return $list;
394394
case 'map':
395-
$map = array();
395+
$map = [];
396396

397397
foreach ($node->childNodes as $element) {
398398
if (!$element instanceof \DOMElement) {

0 commit comments

Comments
 (0)