Skip to content

Commit 9b97370

Browse files
committed
fixed CS
1 parent 051c529 commit 9b97370

39 files changed

+560
-560
lines changed

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

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
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function loadChoicesForValues(array $values, $value = null)
2727
// Optimize
2828
$values = array_filter($values);
2929
if (empty($values)) {
30-
return array();
30+
return [];
3131
}
3232

3333
return $this->loadChoiceList($value)->getChoicesForValues($values);
@@ -41,7 +41,7 @@ public function loadValuesForChoices(array $choices, $value = null)
4141
// Optimize
4242
$choices = array_filter($choices);
4343
if (empty($choices)) {
44-
return array();
44+
return [];
4545
}
4646

4747
// If no callable is set, choices are the same as values

ChoiceList/View/ChoiceView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ChoiceView
3535
* @param string $label The label displayed to humans
3636
* @param array $attr Additional attributes for the HTML tag
3737
*/
38-
public function __construct($data, string $value, $label, array $attr = array())
38+
public function __construct($data, string $value, $label, array $attr = [])
3939
{
4040
$this->data = $data;
4141
$this->value = $value;

Extension/Core/DataTransformer/BooleanToStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class BooleanToStringTransformer implements DataTransformerInterface
3131
* @param string $trueValue The value emitted upon transform if the input is true
3232
* @param array $falseValues
3333
*/
34-
public function __construct(string $trueValue, array $falseValues = array(null))
34+
public function __construct(string $trueValue, array $falseValues = [null])
3535
{
3636
$this->trueValue = $trueValue;
3737
$this->falseValues = $falseValues;

Extension/Core/EventListener/ResizeFormListener.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ResizeFormListener implements EventSubscriberInterface
3838
* @param bool $allowDelete Whether children could be removed from the group
3939
* @param bool|callable $deleteEmpty
4040
*/
41-
public function __construct(string $type, array $options = array(), bool $allowAdd = false, bool $allowDelete = false, $deleteEmpty = false)
41+
public function __construct(string $type, array $options = [], bool $allowAdd = false, bool $allowDelete = false, $deleteEmpty = false)
4242
{
4343
$this->type = $type;
4444
$this->allowAdd = $allowAdd;
@@ -49,12 +49,12 @@ public function __construct(string $type, array $options = array(), bool $allowA
4949

5050
public static function getSubscribedEvents()
5151
{
52-
return array(
52+
return [
5353
FormEvents::PRE_SET_DATA => 'preSetData',
5454
FormEvents::PRE_SUBMIT => 'preSubmit',
5555
// (MergeCollectionListener, MergeDoctrineCollectionListener)
56-
FormEvents::SUBMIT => array('onSubmit', 50),
57-
);
56+
FormEvents::SUBMIT => ['onSubmit', 50],
57+
];
5858
}
5959

6060
public function preSetData(FormEvent $event)
@@ -63,7 +63,7 @@ public function preSetData(FormEvent $event)
6363
$data = $event->getData();
6464

6565
if (null === $data) {
66-
$data = array();
66+
$data = [];
6767
}
6868

6969
if (!\is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
@@ -77,9 +77,9 @@ public function preSetData(FormEvent $event)
7777

7878
// Then add all rows again in the correct order
7979
foreach ($data as $name => $value) {
80-
$form->add($name, $this->type, array_replace(array(
80+
$form->add($name, $this->type, array_replace([
8181
'property_path' => '['.$name.']',
82-
), $this->options));
82+
], $this->options));
8383
}
8484
}
8585

@@ -89,7 +89,7 @@ public function preSubmit(FormEvent $event)
8989
$data = $event->getData();
9090

9191
if (!\is_array($data)) {
92-
$data = array();
92+
$data = [];
9393
}
9494

9595
// Remove all empty rows
@@ -105,9 +105,9 @@ public function preSubmit(FormEvent $event)
105105
if ($this->allowAdd) {
106106
foreach ($data as $name => $value) {
107107
if (!$form->has($name)) {
108-
$form->add($name, $this->type, array_replace(array(
108+
$form->add($name, $this->type, array_replace([
109109
'property_path' => '['.$name.']',
110-
), $this->options));
110+
], $this->options));
111111
}
112112
}
113113
}
@@ -123,7 +123,7 @@ public function onSubmit(FormEvent $event)
123123
// entries, so we need to manually unset removed entries in the collection.
124124

125125
if (null === $data) {
126-
$data = array();
126+
$data = [];
127127
}
128128

129129
if (!\is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
@@ -149,7 +149,7 @@ public function onSubmit(FormEvent $event)
149149
// The data mapper only adds, but does not remove items, so do this
150150
// here
151151
if ($this->allowDelete) {
152-
$toDelete = array();
152+
$toDelete = [];
153153

154154
foreach ($data as $name => $child) {
155155
if (!$form->has($name)) {

Extension/Core/Type/CheckboxType.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
4040
*/
4141
public function buildView(FormView $view, FormInterface $form, array $options)
4242
{
43-
$view->vars = array_replace($view->vars, array(
43+
$view->vars = array_replace($view->vars, [
4444
'value' => $options['value'],
4545
'checked' => null !== $form->getViewData(),
46-
));
46+
]);
4747
}
4848

4949
/**
@@ -55,12 +55,12 @@ public function configureOptions(OptionsResolver $resolver)
5555
return $viewData;
5656
};
5757

58-
$resolver->setDefaults(array(
58+
$resolver->setDefaults([
5959
'value' => '1',
6060
'empty_data' => $emptyData,
6161
'compound' => false,
62-
'false_values' => array(null),
63-
));
62+
'false_values' => [null],
63+
]);
6464

6565
$resolver->setAllowedTypes('false_values', 'array');
6666
}

Extension/Core/Type/ChoiceType.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
7070

7171
// Check if the choices already contain the empty value
7272
// Only add the placeholder option if this is not the case
73-
if (null !== $options['placeholder'] && 0 === \count($choiceList->getChoicesForValues(array('')))) {
73+
if (null !== $options['placeholder'] && 0 === \count($choiceList->getChoicesForValues(['']))) {
7474
$placeholderView = new ChoiceView(null, '', $options['placeholder']);
7575

7676
// "placeholder" is a reserved name
@@ -108,7 +108,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
108108
$unknownValues = $valueMap;
109109

110110
// Reconstruct the data as mapping from child names to values
111-
$data = array();
111+
$data = [];
112112

113113
/** @var FormInterface $child */
114114
foreach ($form as $child) {
@@ -184,15 +184,15 @@ public function buildView(FormView $view, FormInterface $form, array $options)
184184
? $form->getConfig()->getAttribute('choice_list_view')
185185
: $this->createChoiceListView($choiceList, $options);
186186

187-
$view->vars = array_replace($view->vars, array(
187+
$view->vars = array_replace($view->vars, [
188188
'multiple' => $options['multiple'],
189189
'expanded' => $options['expanded'],
190190
'preferred_choices' => $choiceListView->preferredChoices,
191191
'choices' => $choiceListView->choices,
192192
'separator' => '-------------------',
193193
'placeholder' => null,
194194
'choice_translation_domain' => $choiceTranslationDomain,
195-
));
195+
]);
196196

197197
// The decision, whether a choice is selected, is potentially done
198198
// thousand of times during the rendering of a template. Provide a
@@ -255,7 +255,7 @@ public function configureOptions(OptionsResolver $resolver)
255255
}
256256

257257
if ($options['multiple']) {
258-
return array();
258+
return [];
259259
}
260260

261261
return '';
@@ -296,16 +296,16 @@ public function configureOptions(OptionsResolver $resolver)
296296
return $choiceTranslationDomain;
297297
};
298298

299-
$resolver->setDefaults(array(
299+
$resolver->setDefaults([
300300
'multiple' => false,
301301
'expanded' => false,
302-
'choices' => array(),
302+
'choices' => [],
303303
'choice_loader' => null,
304304
'choice_label' => null,
305305
'choice_name' => null,
306306
'choice_value' => null,
307307
'choice_attr' => null,
308-
'preferred_choices' => array(),
308+
'preferred_choices' => [],
309309
'group_by' => null,
310310
'empty_data' => $emptyData,
311311
'placeholder' => $placeholderDefault,
@@ -317,20 +317,20 @@ public function configureOptions(OptionsResolver $resolver)
317317
'data_class' => null,
318318
'choice_translation_domain' => true,
319319
'trim' => false,
320-
));
320+
]);
321321

322322
$resolver->setNormalizer('placeholder', $placeholderNormalizer);
323323
$resolver->setNormalizer('choice_translation_domain', $choiceTranslationDomainNormalizer);
324324

325-
$resolver->setAllowedTypes('choices', array('null', 'array', '\Traversable'));
326-
$resolver->setAllowedTypes('choice_translation_domain', array('null', 'bool', 'string'));
327-
$resolver->setAllowedTypes('choice_loader', array('null', 'Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'));
328-
$resolver->setAllowedTypes('choice_label', array('null', 'bool', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
329-
$resolver->setAllowedTypes('choice_name', array('null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
330-
$resolver->setAllowedTypes('choice_value', array('null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
331-
$resolver->setAllowedTypes('choice_attr', array('null', 'array', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
332-
$resolver->setAllowedTypes('preferred_choices', array('array', '\Traversable', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
333-
$resolver->setAllowedTypes('group_by', array('null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
325+
$resolver->setAllowedTypes('choices', ['null', 'array', '\Traversable']);
326+
$resolver->setAllowedTypes('choice_translation_domain', ['null', 'bool', 'string']);
327+
$resolver->setAllowedTypes('choice_loader', ['null', 'Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface']);
328+
$resolver->setAllowedTypes('choice_label', ['null', 'bool', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath']);
329+
$resolver->setAllowedTypes('choice_name', ['null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath']);
330+
$resolver->setAllowedTypes('choice_value', ['null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath']);
331+
$resolver->setAllowedTypes('choice_attr', ['null', 'array', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath']);
332+
$resolver->setAllowedTypes('preferred_choices', ['array', '\Traversable', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath']);
333+
$resolver->setAllowedTypes('group_by', ['null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath']);
334334
}
335335

336336
/**
@@ -367,13 +367,13 @@ private function addSubForms(FormBuilderInterface $builder, array $choiceViews,
367367
*/
368368
private function addSubForm(FormBuilderInterface $builder, string $name, ChoiceView $choiceView, array $options)
369369
{
370-
$choiceOpts = array(
370+
$choiceOpts = [
371371
'value' => $choiceView->value,
372372
'label' => $choiceView->label,
373373
'attr' => $choiceView->attr,
374374
'translation_domain' => $options['translation_domain'],
375375
'block_name' => 'entry',
376-
);
376+
];
377377

378378
if ($options['multiple']) {
379379
$choiceType = __NAMESPACE__.'\CheckboxType';
@@ -397,7 +397,7 @@ private function createChoiceList(array $options)
397397
}
398398

399399
// Harden against NULL values (like in EntityType and ModelType)
400-
$choices = null !== $options['choices'] ? $options['choices'] : array();
400+
$choices = null !== $options['choices'] ? $options['choices'] : [];
401401

402402
return $this->choiceListFactory->createListFromChoices($choices, $options['choice_value']);
403403
}

0 commit comments

Comments
 (0)