Skip to content

Commit dcd7d83

Browse files
committed
Merge branch '2.x' into 3.0
* 2.x: make StyleCI happy
2 parents 2c8bcf8 + 6667096 commit dcd7d83

Some content is hidden

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

48 files changed

+212
-226
lines changed

Context/Context.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
final class Context
2222
{
23-
private $attributes = array();
23+
private $attributes = [];
2424
private $version;
2525
private $groups;
2626
private $isMaxDepthEnabled;
@@ -29,7 +29,7 @@ final class Context
2929
/**
3030
* @var ExclusionStrategyInterface[]
3131
*/
32-
private $exclusionStrategies = array();
32+
private $exclusionStrategies = [];
3333

3434
public function setAttribute(string $key, $value): self
3535
{

Controller/Annotations/AbstractParam.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract class AbstractParam implements ParamInterface
4141
public $nullable = false;
4242

4343
/** @var array */
44-
public $incompatibles = array();
44+
public $incompatibles = [];
4545

4646
/** {@inheritdoc} */
4747
public function getName()
@@ -70,7 +70,7 @@ public function getIncompatibilities()
7070
/** {@inheritdoc} */
7171
public function getConstraints()
7272
{
73-
$constraints = array();
73+
$constraints = [];
7474
if (!$this->nullable) {
7575
$constraints[] = new Constraints\NotNull();
7676
}

Controller/Annotations/AbstractScalarParam.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ public function getConstraints()
4141
if ($this->requirements instanceof Constraint) {
4242
$constraints[] = $this->requirements;
4343
} elseif (is_scalar($this->requirements)) {
44-
$constraints[] = new Regex(array(
44+
$constraints[] = new Regex([
4545
'pattern' => '#^(?:'.$this->requirements.')$#xsu',
4646
'message' => sprintf(
4747
'Parameter \'%s\' value, does not match requirements \'%s\'',
4848
$this->getName(),
4949
$this->requirements
5050
),
51-
));
51+
]);
5252
} elseif (is_array($this->requirements) && isset($this->requirements['rule']) && $this->requirements['error_message']) {
53-
$constraints[] = new Regex(array(
53+
$constraints[] = new Regex([
5454
'pattern' => '#^(?:'.$this->requirements['rule'].')$#xsu',
5555
'message' => $this->requirements['error_message'],
56-
));
56+
]);
5757
} elseif (is_array($this->requirements)) {
5858
foreach ($this->requirements as $index => $requirement) {
5959
if ($requirement instanceof Constraint) {
@@ -75,9 +75,9 @@ public function getConstraints()
7575
// If the user wants to map the value, apply all constraints to every
7676
// value of the map
7777
if ($this->map) {
78-
$constraints = array(
79-
new All(array('constraints' => $constraints)),
80-
);
78+
$constraints = [
79+
new All(['constraints' => $constraints]),
80+
];
8181
if (false === $this->nullable) {
8282
$constraints[] = new NotNull();
8383
}

Controller/Annotations/FileParam.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getConstraints()
4949
$constraints[] = $this->requirements;
5050
}
5151

52-
$options = is_array($this->requirements) ? $this->requirements : array();
52+
$options = is_array($this->requirements) ? $this->requirements : [];
5353
if ($this->image) {
5454
$constraints[] = new Image($options);
5555
} else {
@@ -58,9 +58,9 @@ public function getConstraints()
5858

5959
// If the user wants to map the value
6060
if ($this->map) {
61-
$constraints = array(
62-
new All(array('constraints' => $constraints)),
63-
);
61+
$constraints = [
62+
new All(['constraints' => $constraints]),
63+
];
6464
}
6565

6666
return $constraints;

Controller/Annotations/ParamInterface.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ public function isStrict();
5858
/**
5959
* Get param value in function of the current request.
6060
*
61-
* @param Request $request
62-
* @param mixed $default value
61+
* @param mixed $default value
6362
*
6463
* @return mixed
6564
*/

DependencyInjection/Compiler/FormatListenerRulesPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function process(ContainerBuilder $container): void
4141
'path' => "^/$path/",
4242
'priorities' => ['html', 'json'],
4343
'fallback_format' => 'html',
44-
'attributes' => array(),
44+
'attributes' => [],
4545
'prefer_extension' => true,
4646
];
4747

@@ -75,7 +75,7 @@ private function addRule(array $rule, ContainerBuilder $container): void
7575
->addMethodCall('add', [$matcher, $rule]);
7676
}
7777

78-
private function createRequestMatcher(ContainerBuilder $container, ?string $path = null, ?string $host = null, ?array $methods = null, array $attributes = array()): Reference
78+
private function createRequestMatcher(ContainerBuilder $container, ?string $path = null, ?string $host = null, ?array $methods = null, array $attributes = []): Reference
7979
{
8080
$arguments = [$path, $host, $methods, null, $attributes];
8181
$serialized = serialize($arguments);

DependencyInjection/Configuration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function getConfigTreeBuilder(): TreeBuilder
131131
->end()
132132
->arrayNode('ips')
133133
->beforeNormalization()->ifString()->then(function ($v) {
134-
return array($v);
134+
return [$v];
135135
})->end()
136136
->prototype('scalar')->end()
137137
->end()
@@ -178,7 +178,7 @@ private function addViewSection(ArrayNodeDefinition $rootNode): void
178178
->prototype('array')
179179
->beforeNormalization()
180180
->ifString()
181-
->then(function ($v) { return array($v); })
181+
->then(function ($v) { return [$v]; })
182182
->end()
183183
->prototype('scalar')->end()
184184
->end()
@@ -376,7 +376,7 @@ private function addExceptionSection(ArrayNodeDefinition $rootNode): void
376376
->always()
377377
->then(function ($v) {
378378
if (!$v['enabled']) {
379-
return $v;
379+
return $v;
380380
}
381381

382382
if ($v['exception_listener']) {

DependencyInjection/FOSRestExtension.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ private function loadBodyListener(array $config, XmlFileLoader $loader, Containe
118118
}
119119

120120
$service->replaceArgument(1, $config['body_listener']['throw_exception_on_unsupported_content_type']);
121-
$service->addMethodCall('setDefaultFormat', array($config['body_listener']['default_format']));
121+
$service->addMethodCall('setDefaultFormat', [$config['body_listener']['default_format']]);
122122

123123
$container->getDefinition('fos_rest.decoder_provider')->replaceArgument(1, $config['body_listener']['decoders']);
124124

125-
$decoderServicesMap = array();
125+
$decoderServicesMap = [];
126126

127127
foreach ($config['body_listener']['decoders'] as $id) {
128128
$decoderServicesMap[$id] = new Reference($id);
@@ -344,7 +344,7 @@ private function loadSerializer(array $config, ContainerBuilder $container): voi
344344
{
345345
$bodyConverter = $container->hasDefinition('fos_rest.converter.request_body') ? $container->getDefinition('fos_rest.converter.request_body') : null;
346346
$viewHandler = $container->getDefinition('fos_rest.view_handler.default');
347-
$options = array();
347+
$options = [];
348348

349349
if (!empty($config['serializer']['version'])) {
350350
if ($bodyConverter) {
@@ -379,22 +379,22 @@ private function loadZoneMatcherListener(array $config, XmlFileLoader $loader, C
379379
$zone['ips']
380380
);
381381

382-
$zoneMatcherListener->addMethodCall('addRequestMatcher', array($matcher));
382+
$zoneMatcherListener->addMethodCall('addRequestMatcher', [$matcher]);
383383
}
384384
}
385385
}
386386

387-
private function createZoneRequestMatcher(ContainerBuilder $container, ?string $path = null, ?string $host = null, array $methods = array(), array $ips = null): Reference
387+
private function createZoneRequestMatcher(ContainerBuilder $container, ?string $path = null, ?string $host = null, array $methods = [], array $ips = null): Reference
388388
{
389389
if ($methods) {
390390
$methods = array_map('strtoupper', (array) $methods);
391391
}
392392

393-
$serialized = serialize(array($path, $host, $methods, $ips));
393+
$serialized = serialize([$path, $host, $methods, $ips]);
394394
$id = 'fos_rest.zone_request_matcher.'.md5($serialized).sha1($serialized);
395395

396396
// only add arguments that are necessary
397-
$arguments = array($path, $host, $methods, $ips);
397+
$arguments = [$path, $host, $methods, $ips];
398398
while (count($arguments) > 0 && !end($arguments)) {
399399
array_pop($arguments);
400400
}

EventListener/ViewResponseListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public function onKernelView(ViewEvent $event): void
8989
public static function getSubscribedEvents(): array
9090
{
9191
// Must be executed before SensioFrameworkExtraBundle's listener
92-
return array(
93-
KernelEvents::VIEW => array('onKernelView', 30),
94-
);
92+
return [
93+
KernelEvents::VIEW => ['onKernelView', 30],
94+
];
9595
}
9696
}

EventListener/ZoneMatcherListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
class ZoneMatcherListener
2626
{
27-
private $requestMatchers = array();
27+
private $requestMatchers = [];
2828

2929
public function addRequestMatcher(RequestMatcherInterface $requestMatcher)
3030
{

Form/Extension/DisableCSRFExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ public function configureOptions(OptionsResolver $resolver): void
5454

5555
public static function getExtendedTypes(): iterable
5656
{
57-
return array(FormType::class);
57+
return [FormType::class];
5858
}
5959
}

Negotiation/FormatNegotiator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class FormatNegotiator extends BaseNegotiator
2828
private $requestStack;
2929
private $mimeTypes;
3030

31-
public function __construct(RequestStack $requestStack, array $mimeTypes = array())
31+
public function __construct(RequestStack $requestStack, array $mimeTypes = [])
3232
{
3333
$this->requestStack = $requestStack;
3434
$this->mimeTypes = $mimeTypes;
@@ -118,7 +118,7 @@ private function normalizePriorities(Request $request, array $priorities): array
118118
{
119119
$priorities = $this->sanitize($priorities);
120120

121-
$mimeTypes = array();
121+
$mimeTypes = [];
122122
foreach ($priorities as $priority) {
123123
if (strpos($priority, '/')) {
124124
$mimeTypes[] = $priority;

Normalizer/CamelKeysNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function normalize(array $data)
3434

3535
private function normalizeArray(array &$data)
3636
{
37-
$normalizedData = array();
37+
$normalizedData = [];
3838

3939
foreach ($data as $key => $val) {
4040
$normalizedKey = $this->normalizeString($key);

Request/ParamFetcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ private function cleanParamWithRequirements(ParamInterface $param, $paramValue,
118118
$violation = new ConstraintViolation(
119119
$e->getMessage(),
120120
$e->getMessage(),
121-
array(),
121+
[],
122122
$paramValue,
123123
'',
124124
null,
125125
null,
126126
$e->getCode()
127127
);
128-
$errors = new ConstraintViolationList(array($violation));
128+
$errors = new ConstraintViolationList([$violation]);
129129
}
130130

131131
if (0 < count($errors)) {

Request/ParamReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function getParamsFromClass(\ReflectionClass $class): array
7070
*/
7171
private function getParamsFromAnnotationArray(array $annotations): array
7272
{
73-
$params = array();
73+
$params = [];
7474
foreach ($annotations as $annotation) {
7575
if ($annotation instanceof ParamInterface) {
7676
$params[$annotation->getName()] = $annotation;

Request/ParameterBag.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
final class ParameterBag
2424
{
2525
private $paramReader;
26-
private $params = array();
26+
private $params = [];
2727

2828
public function __construct(ParamReaderInterface $paramReader)
2929
{
@@ -54,10 +54,10 @@ public function addParam(Request $request, ParamInterface $param): void
5454
public function setController(Request $request, callable $controller): void
5555
{
5656
$requestId = spl_object_hash($request);
57-
$this->params[$requestId] = array(
57+
$this->params[$requestId] = [
5858
'controller' => $controller,
5959
'params' => null,
60-
);
60+
];
6161
}
6262

6363
/**

Serializer/SymfonySerializerAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function deserialize(string $data, string $type, string $format, Context
5050

5151
private function convertContext(Context $context): array
5252
{
53-
$newContext = array();
53+
$newContext = [];
5454
foreach ($context->getAttributes() as $key => $value) {
5555
$newContext[$key] = $value;
5656
}

Tests/Context/ContextTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testAttributes()
5151

5252
public function testGroupAddition()
5353
{
54-
$this->context->addGroups(array('quz', 'foo'));
54+
$this->context->addGroups(['quz', 'foo']);
5555
$this->context->addGroup('foo');
5656
$this->context->addGroup('bar');
5757

@@ -60,12 +60,12 @@ public function testGroupAddition()
6060

6161
public function testSetGroups()
6262
{
63-
$this->context->setGroups(array('quz', 'foo'));
63+
$this->context->setGroups(['quz', 'foo']);
6464

65-
$this->assertEquals(array('quz', 'foo'), $this->context->getGroups());
65+
$this->assertEquals(['quz', 'foo'], $this->context->getGroups());
6666

67-
$this->context->setGroups(array('foo'));
68-
$this->assertEquals(array('foo'), $this->context->getGroups());
67+
$this->context->setGroups(['foo']);
68+
$this->assertEquals(['foo'], $this->context->getGroups());
6969
}
7070

7171
public function testAlreadyExistentGroupAddition()
@@ -74,7 +74,7 @@ public function testAlreadyExistentGroupAddition()
7474
$this->context->addGroup('foo');
7575
$this->context->addGroup('bar');
7676

77-
$this->assertEquals(array('foo', 'bar'), $this->context->getGroups());
77+
$this->assertEquals(['foo', 'bar'], $this->context->getGroups());
7878
}
7979

8080
public function testVersion()

Tests/Controller/Annotations/AbstractParamTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testDefaultValues()
4141
$this->assertNull($this->param->description);
4242
$this->assertFalse($this->param->strict);
4343
$this->assertFalse($this->param->nullable);
44-
$this->assertEquals(array(), $this->param->incompatibles);
44+
$this->assertEquals([], $this->param->incompatibles);
4545
}
4646

4747
public function testNameGetter()
@@ -67,8 +67,8 @@ public function testDescriptionGetter()
6767

6868
public function testIncompatiblesGetter()
6969
{
70-
$this->param->incompatibles = array('c', 'd');
71-
$this->assertEquals(array('c', 'd'), $this->param->getIncompatibilities());
70+
$this->param->incompatibles = ['c', 'd'];
71+
$this->assertEquals(['c', 'd'], $this->param->getIncompatibilities());
7272
}
7373

7474
public function testStrictGetter()
@@ -79,9 +79,9 @@ public function testStrictGetter()
7979

8080
public function testNotNullConstraint()
8181
{
82-
$this->assertEquals(array(new NotNull()), $this->param->getConstraints(''));
82+
$this->assertEquals([new NotNull()], $this->param->getConstraints(''));
8383

8484
$this->param->nullable = true;
85-
$this->assertEquals(array(), $this->param->getConstraints());
85+
$this->assertEquals([], $this->param->getConstraints());
8686
}
8787
}

0 commit comments

Comments
 (0)