Skip to content

Commit 1fce830

Browse files
committed
switched array() to []
1 parent 55d6b84 commit 1fce830

32 files changed

+459
-459
lines changed

ExpressionLanguage.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ class ExpressionLanguage
2828
private $parser;
2929
private $compiler;
3030

31-
protected $functions = array();
31+
protected $functions = [];
3232

3333
/**
3434
* @param CacheItemPoolInterface $cache
3535
* @param ExpressionFunctionProviderInterface[] $providers
3636
*/
37-
public function __construct($cache = null, array $providers = array())
37+
public function __construct($cache = null, array $providers = [])
3838
{
3939
if (null !== $cache) {
4040
if ($cache instanceof ParserCacheInterface) {
@@ -60,7 +60,7 @@ public function __construct($cache = null, array $providers = array())
6060
*
6161
* @return string The compiled PHP source code
6262
*/
63-
public function compile($expression, $names = array())
63+
public function compile($expression, $names = [])
6464
{
6565
return $this->getCompiler()->compile($this->parse($expression, $names)->getNodes())->getSource();
6666
}
@@ -73,7 +73,7 @@ public function compile($expression, $names = array())
7373
*
7474
* @return mixed The result of the evaluation of the expression
7575
*/
76-
public function evaluate($expression, $values = array())
76+
public function evaluate($expression, $values = [])
7777
{
7878
return $this->parse($expression, array_keys($values))->getNodes()->evaluate($this->functions, $values);
7979
}
@@ -93,7 +93,7 @@ public function parse($expression, $names)
9393
}
9494

9595
asort($names);
96-
$cacheKeyItems = array();
96+
$cacheKeyItems = [];
9797

9898
foreach ($names as $nameKey => $name) {
9999
$cacheKeyItems[] = \is_int($nameKey) ? $name : $nameKey.':'.$name;
@@ -129,7 +129,7 @@ public function register($name, callable $compiler, callable $evaluator)
129129
throw new \LogicException('Registering functions after calling evaluate(), compile() or parse() is not supported.');
130130
}
131131

132-
$this->functions[$name] = array('compiler' => $compiler, 'evaluator' => $evaluator);
132+
$this->functions[$name] = ['compiler' => $compiler, 'evaluator' => $evaluator];
133133
}
134134

135135
public function addFunction(ExpressionFunction $function)

Lexer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class Lexer
2929
*/
3030
public function tokenize($expression)
3131
{
32-
$expression = str_replace(array("\r", "\n", "\t", "\v", "\f"), ' ', $expression);
32+
$expression = str_replace(["\r", "\n", "\t", "\v", "\f"], ' ', $expression);
3333
$cursor = 0;
34-
$tokens = array();
35-
$brackets = array();
34+
$tokens = [];
35+
$brackets = [];
3636
$end = \strlen($expression);
3737

3838
while ($cursor < $end) {
@@ -52,7 +52,7 @@ public function tokenize($expression)
5252
$cursor += \strlen($match[0]);
5353
} elseif (false !== strpos('([{', $expression[$cursor])) {
5454
// opening bracket
55-
$brackets[] = array($expression[$cursor], $cursor);
55+
$brackets[] = [$expression[$cursor], $cursor];
5656

5757
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
5858
++$cursor;

Node/ArgumentsNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function compile(Compiler $compiler)
2727

2828
public function toArray()
2929
{
30-
$array = array();
30+
$array = [];
3131

3232
foreach ($this->getKeyValuePairs() as $pair) {
3333
$array[] = $pair['value'];

Node/ArrayNode.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function compile(Compiler $compiler)
4848

4949
public function evaluate($functions, $values)
5050
{
51-
$result = array();
51+
$result = [];
5252
foreach ($this->getKeyValuePairs() as $pair) {
5353
$result[$pair['key']->evaluate($functions, $values)] = $pair['value']->evaluate($functions, $values);
5454
}
@@ -58,12 +58,12 @@ public function evaluate($functions, $values)
5858

5959
public function toArray()
6060
{
61-
$value = array();
61+
$value = [];
6262
foreach ($this->getKeyValuePairs() as $pair) {
6363
$value[$pair['key']->attributes['value']] = $pair['value'];
6464
}
6565

66-
$array = array();
66+
$array = [];
6767

6868
if ($this->isHash($value)) {
6969
foreach ($value as $k => $v) {
@@ -88,9 +88,9 @@ public function toArray()
8888

8989
protected function getKeyValuePairs()
9090
{
91-
$pairs = array();
91+
$pairs = [];
9292
foreach (array_chunk($this->nodes, 2) as $pair) {
93-
$pairs[] = array('key' => $pair[0], 'value' => $pair[1]);
93+
$pairs[] = ['key' => $pair[0], 'value' => $pair[1]];
9494
}
9595

9696
return $pairs;

Node/BinaryNode.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@
2020
*/
2121
class BinaryNode extends Node
2222
{
23-
private static $operators = array(
23+
private static $operators = [
2424
'~' => '.',
2525
'and' => '&&',
2626
'or' => '||',
27-
);
27+
];
2828

29-
private static $functions = array(
29+
private static $functions = [
3030
'**' => 'pow',
3131
'..' => 'range',
3232
'in' => 'in_array',
3333
'not in' => '!in_array',
34-
);
34+
];
3535

3636
public function __construct($operator, Node $left, Node $right)
3737
{
3838
parent::__construct(
39-
array('left' => $left, 'right' => $right),
40-
array('operator' => $operator)
39+
['left' => $left, 'right' => $right],
40+
['operator' => $operator]
4141
);
4242
}
4343

@@ -157,6 +157,6 @@ public function evaluate($functions, $values)
157157

158158
public function toArray()
159159
{
160-
return array('(', $this->nodes['left'], ' '.$this->attributes['operator'].' ', $this->nodes['right'], ')');
160+
return ['(', $this->nodes['left'], ' '.$this->attributes['operator'].' ', $this->nodes['right'], ')'];
161161
}
162162
}

Node/ConditionalNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ConditionalNode extends Node
2323
public function __construct(Node $expr1, Node $expr2, Node $expr3)
2424
{
2525
parent::__construct(
26-
array('expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3)
26+
['expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3]
2727
);
2828
}
2929

@@ -51,6 +51,6 @@ public function evaluate($functions, $values)
5151

5252
public function toArray()
5353
{
54-
return array('(', $this->nodes['expr1'], ' ? ', $this->nodes['expr2'], ' : ', $this->nodes['expr3'], ')');
54+
return ['(', $this->nodes['expr1'], ' ? ', $this->nodes['expr2'], ' : ', $this->nodes['expr3'], ')'];
5555
}
5656
}

Node/ConstantNode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public function __construct($value, $isIdentifier = false)
2626
{
2727
$this->isIdentifier = $isIdentifier;
2828
parent::__construct(
29-
array(),
30-
array('value' => $value)
29+
[],
30+
['value' => $value]
3131
);
3232
}
3333

@@ -43,7 +43,7 @@ public function evaluate($functions, $values)
4343

4444
public function toArray()
4545
{
46-
$array = array();
46+
$array = [];
4747
$value = $this->attributes['value'];
4848

4949
if ($this->isIdentifier) {

Node/FunctionNode.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ class FunctionNode extends Node
2323
public function __construct($name, Node $arguments)
2424
{
2525
parent::__construct(
26-
array('arguments' => $arguments),
27-
array('name' => $name)
26+
['arguments' => $arguments],
27+
['name' => $name]
2828
);
2929
}
3030

3131
public function compile(Compiler $compiler)
3232
{
33-
$arguments = array();
33+
$arguments = [];
3434
foreach ($this->nodes['arguments']->nodes as $node) {
3535
$arguments[] = $compiler->subcompile($node);
3636
}
@@ -42,7 +42,7 @@ public function compile(Compiler $compiler)
4242

4343
public function evaluate($functions, $values)
4444
{
45-
$arguments = array($values);
45+
$arguments = [$values];
4646
foreach ($this->nodes['arguments']->nodes as $node) {
4747
$arguments[] = $node->evaluate($functions, $values);
4848
}
@@ -52,7 +52,7 @@ public function evaluate($functions, $values)
5252

5353
public function toArray()
5454
{
55-
$array = array();
55+
$array = [];
5656
$array[] = $this->attributes['name'];
5757

5858
foreach ($this->nodes['arguments']->nodes as $node) {

Node/GetAttrNode.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class GetAttrNode extends Node
2727
public function __construct(Node $node, Node $attribute, ArrayNode $arguments, $type)
2828
{
2929
parent::__construct(
30-
array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments),
31-
array('type' => $type)
30+
['node' => $node, 'attribute' => $attribute, 'arguments' => $arguments],
31+
['type' => $type]
3232
);
3333
}
3434

@@ -82,7 +82,7 @@ public function evaluate($functions, $values)
8282
if (!\is_object($obj)) {
8383
throw new \RuntimeException('Unable to get a property on a non-object.');
8484
}
85-
if (!\is_callable($toCall = array($obj, $this->nodes['attribute']->attributes['value']))) {
85+
if (!\is_callable($toCall = [$obj, $this->nodes['attribute']->attributes['value']])) {
8686
throw new \RuntimeException(sprintf('Unable to call method "%s" of object "%s".', $this->nodes['attribute']->attributes['value'], \get_class($obj)));
8787
}
8888

@@ -102,13 +102,13 @@ public function toArray()
102102
{
103103
switch ($this->attributes['type']) {
104104
case self::PROPERTY_CALL:
105-
return array($this->nodes['node'], '.', $this->nodes['attribute']);
105+
return [$this->nodes['node'], '.', $this->nodes['attribute']];
106106

107107
case self::METHOD_CALL:
108-
return array($this->nodes['node'], '.', $this->nodes['attribute'], '(', $this->nodes['arguments'], ')');
108+
return [$this->nodes['node'], '.', $this->nodes['attribute'], '(', $this->nodes['arguments'], ')'];
109109

110110
case self::ARRAY_CALL:
111-
return array($this->nodes['node'], '[', $this->nodes['attribute'], ']');
111+
return [$this->nodes['node'], '[', $this->nodes['attribute'], ']'];
112112
}
113113
}
114114
}

Node/NameNode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class NameNode extends Node
2323
public function __construct($name)
2424
{
2525
parent::__construct(
26-
array(),
27-
array('name' => $name)
26+
[],
27+
['name' => $name]
2828
);
2929
}
3030

@@ -40,6 +40,6 @@ public function evaluate($functions, $values)
4040

4141
public function toArray()
4242
{
43-
return array($this->attributes['name']);
43+
return [$this->attributes['name']];
4444
}
4545
}

Node/Node.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,27 @@
2020
*/
2121
class Node
2222
{
23-
public $nodes = array();
24-
public $attributes = array();
23+
public $nodes = [];
24+
public $attributes = [];
2525

2626
/**
2727
* @param array $nodes An array of nodes
2828
* @param array $attributes An array of attributes
2929
*/
30-
public function __construct(array $nodes = array(), array $attributes = array())
30+
public function __construct(array $nodes = [], array $attributes = [])
3131
{
3232
$this->nodes = $nodes;
3333
$this->attributes = $attributes;
3434
}
3535

3636
public function __toString()
3737
{
38-
$attributes = array();
38+
$attributes = [];
3939
foreach ($this->attributes as $name => $value) {
4040
$attributes[] = sprintf('%s: %s', $name, str_replace("\n", '', var_export($value, true)));
4141
}
4242

43-
$repr = array(str_replace('Symfony\Component\ExpressionLanguage\Node\\', '', \get_class($this)).'('.implode(', ', $attributes));
43+
$repr = [str_replace('Symfony\Component\ExpressionLanguage\Node\\', '', \get_class($this)).'('.implode(', ', $attributes)];
4444

4545
if (\count($this->nodes)) {
4646
foreach ($this->nodes as $node) {
@@ -66,7 +66,7 @@ public function compile(Compiler $compiler)
6666

6767
public function evaluate($functions, $values)
6868
{
69-
$results = array();
69+
$results = [];
7070
foreach ($this->nodes as $node) {
7171
$results[] = $node->evaluate($functions, $values);
7272
}

Node/UnaryNode.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020
*/
2121
class UnaryNode extends Node
2222
{
23-
private static $operators = array(
23+
private static $operators = [
2424
'!' => '!',
2525
'not' => '!',
2626
'+' => '+',
2727
'-' => '-',
28-
);
28+
];
2929

3030
public function __construct($operator, Node $node)
3131
{
3232
parent::__construct(
33-
array('node' => $node),
34-
array('operator' => $operator)
33+
['node' => $node],
34+
['operator' => $operator]
3535
);
3636
}
3737

@@ -61,6 +61,6 @@ public function evaluate($functions, $values)
6161

6262
public function toArray()
6363
{
64-
return array('(', $this->attributes['operator'].' ', $this->nodes['node'], ')');
64+
return ['(', $this->attributes['operator'].' ', $this->nodes['node'], ')'];
6565
}
6666
}

0 commit comments

Comments
 (0)