Skip to content

Commit 8254f72

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 b939e31 + be39df1 commit 8254f72

File tree

222 files changed

+5772
-5772
lines changed

Some content is hidden

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

222 files changed

+5772
-5772
lines changed

AbstractExtension.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function getTypeExtensions($name)
8686

8787
return isset($this->typeExtensions[$name])
8888
? $this->typeExtensions[$name]
89-
: array();
89+
: [];
9090
}
9191

9292
/**
@@ -120,7 +120,7 @@ public function getTypeGuesser()
120120
*/
121121
protected function loadTypes()
122122
{
123-
return array();
123+
return [];
124124
}
125125

126126
/**
@@ -130,7 +130,7 @@ protected function loadTypes()
130130
*/
131131
protected function loadTypeExtensions()
132132
{
133-
return array();
133+
return [];
134134
}
135135

136136
/**
@@ -149,7 +149,7 @@ protected function loadTypeGuesser()
149149
*/
150150
private function initTypes()
151151
{
152-
$this->types = array();
152+
$this->types = [];
153153

154154
foreach ($this->loadTypes() as $type) {
155155
if (!$type instanceof FormTypeInterface) {
@@ -168,23 +168,23 @@ private function initTypes()
168168
*/
169169
private function initTypeExtensions()
170170
{
171-
$this->typeExtensions = array();
171+
$this->typeExtensions = [];
172172

173173
foreach ($this->loadTypeExtensions() as $extension) {
174174
if (!$extension instanceof FormTypeExtensionInterface) {
175175
throw new UnexpectedTypeException($extension, 'Symfony\Component\Form\FormTypeExtensionInterface');
176176
}
177177

178178
if (method_exists($extension, 'getExtendedTypes')) {
179-
$extendedTypes = array();
179+
$extendedTypes = [];
180180

181181
foreach ($extension::getExtendedTypes() as $extendedType) {
182182
$extendedTypes[] = $extendedType;
183183
}
184184
} else {
185185
@trigger_error(sprintf('Not implementing the static getExtendedTypes() method in %s when implementing the %s is deprecated since Symfony 4.2. The method will be added to the interface in 5.0.', \get_class($extension), FormTypeExtensionInterface::class), E_USER_DEPRECATED);
186186

187-
$extendedTypes = array($extension->getExtendedType());
187+
$extendedTypes = [$extension->getExtendedType()];
188188
}
189189

190190
foreach ($extendedTypes as $extendedType) {

AbstractRendererEngine.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface
2424
const CACHE_KEY_VAR = 'cache_key';
2525

2626
protected $defaultThemes;
27-
protected $themes = array();
28-
protected $useDefaultThemes = array();
29-
protected $resources = array();
27+
protected $themes = [];
28+
protected $useDefaultThemes = [];
29+
protected $resources = [];
3030

31-
private $resourceHierarchyLevels = array();
31+
private $resourceHierarchyLevels = [];
3232

3333
/**
3434
* Creates a new renderer engine.
3535
*
3636
* @param array $defaultThemes The default themes. The type of these
3737
* themes is open to the implementation.
3838
*/
39-
public function __construct(array $defaultThemes = array())
39+
public function __construct(array $defaultThemes = [])
4040
{
4141
$this->defaultThemes = $defaultThemes;
4242
}
@@ -49,7 +49,7 @@ public function setTheme(FormView $view, $themes, $useDefaultThemes = true)
4949
$cacheKey = $view->vars[self::CACHE_KEY_VAR];
5050

5151
// Do not cast, as casting turns objects into arrays of properties
52-
$this->themes[$cacheKey] = \is_array($themes) ? $themes : array($themes);
52+
$this->themes[$cacheKey] = \is_array($themes) ? $themes : [$themes];
5353
$this->useDefaultThemes[$cacheKey] = (bool) $useDefaultThemes;
5454

5555
// Unset instead of resetting to an empty array, in order to allow

Button.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function getParent()
132132
*
133133
* @throws BadMethodCallException
134134
*/
135-
public function add($child, $type = null, array $options = array())
135+
public function add($child, $type = null, array $options = [])
136136
{
137137
throw new BadMethodCallException('Buttons cannot have children.');
138138
}
@@ -182,15 +182,15 @@ public function remove($name)
182182
*/
183183
public function all()
184184
{
185-
return array();
185+
return [];
186186
}
187187

188188
/**
189189
* {@inheritdoc}
190190
*/
191191
public function getErrors($deep = false, $flatten = true)
192192
{
193-
return new FormErrorIterator($this, array());
193+
return new FormErrorIterator($this, []);
194194
}
195195

196196
/**
@@ -234,7 +234,7 @@ public function getViewData()
234234
*/
235235
public function getExtraData()
236236
{
237-
return array();
237+
return [];
238238
}
239239

240240
/**

ButtonBuilder.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
4545
/**
4646
* @var array
4747
*/
48-
private $attributes = array();
48+
private $attributes = [];
4949

5050
/**
5151
* @var array
@@ -55,7 +55,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
5555
/**
5656
* @throws InvalidArgumentException if the name is empty
5757
*/
58-
public function __construct(?string $name, array $options = array())
58+
public function __construct(?string $name, array $options = [])
5959
{
6060
if ('' === $name || null === $name) {
6161
throw new InvalidArgumentException('Buttons cannot have empty names.');
@@ -76,7 +76,7 @@ public function __construct(?string $name, array $options = array())
7676
*
7777
* @throws BadMethodCallException
7878
*/
79-
public function add($child, $type = null, array $options = array())
79+
public function add($child, $type = null, array $options = [])
8080
{
8181
throw new BadMethodCallException('Buttons cannot have children.');
8282
}
@@ -92,7 +92,7 @@ public function add($child, $type = null, array $options = array())
9292
*
9393
* @throws BadMethodCallException
9494
*/
95-
public function create($name, $type = null, array $options = array())
95+
public function create($name, $type = null, array $options = [])
9696
{
9797
throw new BadMethodCallException('Buttons cannot have children.');
9898
}
@@ -144,7 +144,7 @@ public function has($name)
144144
*/
145145
public function all()
146146
{
147-
return array();
147+
return [];
148148
}
149149

150150
/**
@@ -582,7 +582,7 @@ public function getType()
582582
*/
583583
public function getViewTransformers()
584584
{
585-
return array();
585+
return [];
586586
}
587587

588588
/**
@@ -592,7 +592,7 @@ public function getViewTransformers()
592592
*/
593593
public function getModelTransformers()
594594
{
595-
return array();
595+
return [];
596596
}
597597

598598
/**

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ CHANGELOG
3333
{
3434
public static function getExtendedTypes(): iterable
3535
{
36-
return array(FormType::class);
36+
return [FormType::class];
3737
}
3838

3939
// ...

ChoiceList/ArrayChoiceList.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function getOriginalKeys()
132132
*/
133133
public function getChoicesForValues(array $values)
134134
{
135-
$choices = array();
135+
$choices = [];
136136

137137
foreach ($values as $i => $givenValue) {
138138
if (array_key_exists($givenValue, $this->choices)) {
@@ -148,11 +148,11 @@ public function getChoicesForValues(array $values)
148148
*/
149149
public function getValuesForChoices(array $choices)
150150
{
151-
$values = array();
151+
$values = [];
152152

153153
// Use the value callback to compare choices by their values, if present
154154
if ($this->valueCallback) {
155-
$givenValues = array();
155+
$givenValues = [];
156156

157157
foreach ($choices as $i => $givenChoice) {
158158
$givenValues[$i] = (string) ($this->valueCallback)($givenChoice);
@@ -190,9 +190,9 @@ public function getValuesForChoices(array $choices)
190190
protected function flatten(array $choices, $value, &$choicesByValues, &$keysByValues, &$structuredValues)
191191
{
192192
if (null === $choicesByValues) {
193-
$choicesByValues = array();
194-
$keysByValues = array();
195-
$structuredValues = array();
193+
$choicesByValues = [];
194+
$keysByValues = [];
195+
$structuredValues = [];
196196
}
197197

198198
foreach ($choices as $key => $choice) {
@@ -219,7 +219,7 @@ protected function flatten(array $choices, $value, &$choicesByValues, &$keysByVa
219219
* @return bool returns true if the choices can be cast to strings and
220220
* false otherwise
221221
*/
222-
private function castableToString(array $choices, array &$cache = array())
222+
private function castableToString(array $choices, array &$cache = [])
223223
{
224224
foreach ($choices as $choice) {
225225
if (\is_array($choice)) {

ChoiceList/ChoiceListInterface.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ public function getValues();
4848
* keys of the choices. If the original array contained nested arrays, these
4949
* nested arrays are represented here as well:
5050
*
51-
* $form->add('field', 'choice', array(
52-
* 'choices' => array(
53-
* 'Decided' => array('Yes' => true, 'No' => false),
54-
* 'Undecided' => array('Maybe' => null),
55-
* ),
56-
* ));
51+
* $form->add('field', 'choice', [
52+
* 'choices' => [
53+
* 'Decided' => ['Yes' => true, 'No' => false],
54+
* 'Undecided' => ['Maybe' => null],
55+
* ],
56+
* ]);
5757
*
5858
* In this example, the result of this method is:
5959
*
60-
* array(
61-
* 'Decided' => array('Yes' => '0', 'No' => '1'),
62-
* 'Undecided' => array('Maybe' => '2'),
63-
* )
60+
* [
61+
* 'Decided' => ['Yes' => '0', 'No' => '1'],
62+
* 'Undecided' => ['Maybe' => '2'],
63+
* ]
6464
*
6565
* @return string[] The choice values
6666
*/
@@ -73,12 +73,12 @@ public function getStructuredValues();
7373
* "choice" option of the choice type. Note that this array may contain
7474
* duplicates if the "choice" option contained choice groups:
7575
*
76-
* $form->add('field', 'choice', array(
77-
* 'choices' => array(
78-
* 'Decided' => array(true, false),
79-
* 'Undecided' => array(null),
80-
* ),
81-
* ));
76+
* $form->add('field', 'choice', [
77+
* 'choices' => [
78+
* 'Decided' => [true, false],
79+
* 'Undecided' => [null],
80+
* ],
81+
* ]);
8282
*
8383
* In this example, the original key 0 appears twice, once for `true` and
8484
* once for `null`.

ChoiceList/Factory/CachingFactoryDecorator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ class CachingFactoryDecorator implements ChoiceListFactoryInterface
2727
/**
2828
* @var ChoiceListInterface[]
2929
*/
30-
private $lists = array();
30+
private $lists = [];
3131

3232
/**
3333
* @var ChoiceListView[]
3434
*/
35-
private $views = array();
35+
private $views = [];
3636

3737
/**
3838
* Generates a SHA-256 hash for the given value.
@@ -89,7 +89,7 @@ public function createListFromChoices($choices, $value = null)
8989
// The value is not validated on purpose. The decorated factory may
9090
// decide which values to accept and which not.
9191

92-
$hash = self::generateHash(array($choices, $value), 'fromChoices');
92+
$hash = self::generateHash([$choices, $value], 'fromChoices');
9393

9494
if (!isset($this->lists[$hash])) {
9595
$this->lists[$hash] = $this->decoratedFactory->createListFromChoices($choices, $value);
@@ -103,7 +103,7 @@ public function createListFromChoices($choices, $value = null)
103103
*/
104104
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null)
105105
{
106-
$hash = self::generateHash(array($loader, $value), 'fromLoader');
106+
$hash = self::generateHash([$loader, $value], 'fromLoader');
107107

108108
if (!isset($this->lists[$hash])) {
109109
$this->lists[$hash] = $this->decoratedFactory->createListFromLoader($loader, $value);
@@ -119,7 +119,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
119119
{
120120
// The input is not validated on purpose. This way, the decorated
121121
// factory may decide which input to accept and which not.
122-
$hash = self::generateHash(array($list, $preferredChoices, $label, $index, $groupBy, $attr));
122+
$hash = self::generateHash([$list, $preferredChoices, $label, $index, $groupBy, $attr]);
123123

124124
if (!isset($this->views[$hash])) {
125125
$this->views[$hash] = $this->decoratedFactory->createView(

ChoiceList/Factory/DefaultChoiceListFactory.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
4747
*/
4848
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null)
4949
{
50-
$preferredViews = array();
51-
$otherViews = array();
50+
$preferredViews = [];
51+
$otherViews = [];
5252
$choices = $list->getChoices();
5353
$keys = $list->getOriginalKeys();
5454

@@ -137,7 +137,7 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $
137137
$label,
138138
// The attributes may be a callable or a mapping from choice indices
139139
// to nested arrays
140-
\is_callable($attr) ? $attr($choice, $key, $value) : (isset($attr[$key]) ? $attr[$key] : array())
140+
\is_callable($attr) ? $attr($choice, $key, $value) : (isset($attr[$key]) ? $attr[$key] : [])
141141
);
142142

143143
// $isPreferred may be null if no choices are preferred
@@ -157,8 +157,8 @@ private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $key
157157

158158
// Add the contents of groups to new ChoiceGroupView instances
159159
if (\is_array($value)) {
160-
$preferredViewsForGroup = array();
161-
$otherViewsForGroup = array();
160+
$preferredViewsForGroup = [];
161+
$otherViewsForGroup = [];
162162

163163
self::addChoiceViewsGroupedBy(
164164
$value,

ChoiceList/Loader/CallbackChoiceLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function loadChoicesForValues(array $values, $value = null)
5656
{
5757
// Optimize
5858
if (empty($values)) {
59-
return array();
59+
return [];
6060
}
6161

6262
return $this->loadChoiceList($value)->getChoicesForValues($values);
@@ -69,7 +69,7 @@ public function loadValuesForChoices(array $choices, $value = null)
6969
{
7070
// Optimize
7171
if (empty($choices)) {
72-
return array();
72+
return [];
7373
}
7474

7575
return $this->loadChoiceList($value)->getValuesForChoices($choices);

0 commit comments

Comments
 (0)