Skip to content

Commit 0f1cbae

Browse files
committed
switched array() to []
1 parent 8a10e36 commit 0f1cbae

File tree

3 files changed

+201
-201
lines changed

3 files changed

+201
-201
lines changed

OptionsResolver.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,51 +29,51 @@ class OptionsResolver implements Options
2929
/**
3030
* The names of all defined options.
3131
*/
32-
private $defined = array();
32+
private $defined = [];
3333

3434
/**
3535
* The default option values.
3636
*/
37-
private $defaults = array();
37+
private $defaults = [];
3838

3939
/**
4040
* The names of required options.
4141
*/
42-
private $required = array();
42+
private $required = [];
4343

4444
/**
4545
* The resolved option values.
4646
*/
47-
private $resolved = array();
47+
private $resolved = [];
4848

4949
/**
5050
* A list of normalizer closures.
5151
*
5252
* @var \Closure[]
5353
*/
54-
private $normalizers = array();
54+
private $normalizers = [];
5555

5656
/**
5757
* A list of accepted values for each option.
5858
*/
59-
private $allowedValues = array();
59+
private $allowedValues = [];
6060

6161
/**
6262
* A list of accepted types for each option.
6363
*/
64-
private $allowedTypes = array();
64+
private $allowedTypes = [];
6565

6666
/**
6767
* A list of closures for evaluating lazy options.
6868
*/
69-
private $lazy = array();
69+
private $lazy = [];
7070

7171
/**
7272
* A list of lazy options whose closure is currently being called.
7373
*
7474
* This list helps detecting circular dependencies between lazy options.
7575
*/
76-
private $calling = array();
76+
private $calling = [];
7777

7878
/**
7979
* Whether the instance is locked for reading.
@@ -85,11 +85,11 @@ class OptionsResolver implements Options
8585
*/
8686
private $locked = false;
8787

88-
private static $typeAliases = array(
88+
private static $typeAliases = [
8989
'boolean' => 'bool',
9090
'integer' => 'int',
9191
'double' => 'float',
92-
);
92+
];
9393

9494
/**
9595
* Sets the default value of a given option.
@@ -154,7 +154,7 @@ public function setDefault($option, $value)
154154

155155
// Ignore previous lazy options if the closure has no second parameter
156156
if (!isset($this->lazy[$option]) || !isset($params[1])) {
157-
$this->lazy[$option] = array();
157+
$this->lazy[$option] = [];
158158
}
159159

160160
// Store closure for later evaluation
@@ -423,7 +423,7 @@ public function setAllowedValues($option, $allowedValues)
423423
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
424424
}
425425

426-
$this->allowedValues[$option] = \is_array($allowedValues) ? $allowedValues : array($allowedValues);
426+
$this->allowedValues[$option] = \is_array($allowedValues) ? $allowedValues : [$allowedValues];
427427

428428
// Make sure the option is processed
429429
unset($this->resolved[$option]);
@@ -465,7 +465,7 @@ public function addAllowedValues($option, $allowedValues)
465465
}
466466

467467
if (!\is_array($allowedValues)) {
468-
$allowedValues = array($allowedValues);
468+
$allowedValues = [$allowedValues];
469469
}
470470

471471
if (!isset($this->allowedValues[$option])) {
@@ -590,14 +590,14 @@ public function clear()
590590
throw new AccessException('Options cannot be cleared from a lazy option or normalizer.');
591591
}
592592

593-
$this->defined = array();
594-
$this->defaults = array();
595-
$this->required = array();
596-
$this->resolved = array();
597-
$this->lazy = array();
598-
$this->normalizers = array();
599-
$this->allowedTypes = array();
600-
$this->allowedValues = array();
593+
$this->defined = [];
594+
$this->defaults = [];
595+
$this->required = [];
596+
$this->resolved = [];
597+
$this->lazy = [];
598+
$this->normalizers = [];
599+
$this->allowedTypes = [];
600+
$this->allowedValues = [];
601601

602602
return $this;
603603
}
@@ -626,7 +626,7 @@ public function clear()
626626
* @throws NoSuchOptionException If a lazy option reads an unavailable option
627627
* @throws AccessException If called from a lazy option or normalizer
628628
*/
629-
public function resolve(array $options = array())
629+
public function resolve(array $options = [])
630630
{
631631
if ($this->locked) {
632632
throw new AccessException('Options cannot be resolved from a lazy option or normalizer.');
@@ -735,7 +735,7 @@ public function offsetGet($option)
735735
// Validate the type of the resolved option
736736
if (isset($this->allowedTypes[$option])) {
737737
$valid = false;
738-
$invalidTypes = array();
738+
$invalidTypes = [];
739739

740740
foreach ($this->allowedTypes[$option] as $type) {
741741
$type = isset(self::$typeAliases[$type]) ? self::$typeAliases[$type] : $type;
@@ -759,7 +759,7 @@ public function offsetGet($option)
759759
// Validate the value of the resolved option
760760
if (isset($this->allowedValues[$option])) {
761761
$success = false;
762-
$printableAllowedValues = array();
762+
$printableAllowedValues = [];
763763

764764
foreach ($this->allowedValues[$option] as $allowedValue) {
765765
if ($allowedValue instanceof \Closure) {
@@ -981,7 +981,7 @@ private function formatTypeOf($value, $type)
981981
}
982982

983983
if (\is_array($value)) {
984-
$subTypes = array();
984+
$subTypes = [];
985985
foreach ($value as $val) {
986986
$subTypes[$this->formatTypeOf($val, null)] = true;
987987
}

Tests/Debug/OptionsResolverIntrospectorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testGetDefaultThrowsOnNotDefinedOption()
6464
public function testGetLazyClosures()
6565
{
6666
$resolver = new OptionsResolver();
67-
$closures = array();
67+
$closures = [];
6868
$resolver->setDefault($option = 'foo', $closures[] = function (Options $options) {});
6969

7070
$debug = new OptionsResolverIntrospector($resolver);
@@ -100,7 +100,7 @@ public function testGetAllowedTypes()
100100
{
101101
$resolver = new OptionsResolver();
102102
$resolver->setDefined($option = 'foo');
103-
$resolver->setAllowedTypes($option = 'foo', $allowedTypes = array('string', 'bool'));
103+
$resolver->setAllowedTypes($option = 'foo', $allowedTypes = ['string', 'bool']);
104104

105105
$debug = new OptionsResolverIntrospector($resolver);
106106
$this->assertSame($allowedTypes, $debug->getAllowedTypes($option));
@@ -135,7 +135,7 @@ public function testGetAllowedValues()
135135
{
136136
$resolver = new OptionsResolver();
137137
$resolver->setDefined($option = 'foo');
138-
$resolver->setAllowedValues($option = 'foo', $allowedValues = array('bar', 'baz'));
138+
$resolver->setAllowedValues($option = 'foo', $allowedValues = ['bar', 'baz']);
139139

140140
$debug = new OptionsResolverIntrospector($resolver);
141141
$this->assertSame($allowedValues, $debug->getAllowedValues($option));

0 commit comments

Comments
 (0)