Skip to content

Commit a69b153

Browse files
committed
Merge branch '4.1' into 4.2
* 4.1: 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 78a427a + 3fbfc13 commit a69b153

30 files changed

+458
-458
lines changed

Compiler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function repr($value)
127127
} elseif (\is_bool($value)) {
128128
$this->raw($value ? 'true' : 'false');
129129
} elseif (\is_array($value)) {
130-
$this->raw('array(');
130+
$this->raw('[');
131131
$first = true;
132132
foreach ($value as $key => $value) {
133133
if (!$first) {
@@ -138,7 +138,7 @@ public function repr($value)
138138
$this->raw(' => ');
139139
$this->repr($value);
140140
}
141-
$this->raw(')');
141+
$this->raw(']');
142142
} else {
143143
$this->string($value);
144144
}

ExpressionLanguage.php

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

29-
protected $functions = array();
29+
protected $functions = [];
3030

3131
/**
3232
* @param CacheItemPoolInterface $cache
3333
* @param ExpressionFunctionProviderInterface[] $providers
3434
*/
35-
public function __construct(CacheItemPoolInterface $cache = null, array $providers = array())
35+
public function __construct(CacheItemPoolInterface $cache = null, array $providers = [])
3636
{
3737
$this->cache = $cache ?: new ArrayAdapter();
3838
$this->registerFunctions();
@@ -49,7 +49,7 @@ public function __construct(CacheItemPoolInterface $cache = null, array $provide
4949
*
5050
* @return string The compiled PHP source code
5151
*/
52-
public function compile($expression, $names = array())
52+
public function compile($expression, $names = [])
5353
{
5454
return $this->getCompiler()->compile($this->parse($expression, $names)->getNodes())->getSource();
5555
}
@@ -62,7 +62,7 @@ public function compile($expression, $names = array())
6262
*
6363
* @return mixed The result of the evaluation of the expression
6464
*/
65-
public function evaluate($expression, $values = array())
65+
public function evaluate($expression, $values = [])
6666
{
6767
return $this->parse($expression, array_keys($values))->getNodes()->evaluate($this->functions, $values);
6868
}
@@ -82,7 +82,7 @@ public function parse($expression, $names)
8282
}
8383

8484
asort($names);
85-
$cacheKeyItems = array();
85+
$cacheKeyItems = [];
8686

8787
foreach ($names as $nameKey => $name) {
8888
$cacheKeyItems[] = \is_int($nameKey) ? $name : $nameKey.':'.$name;
@@ -118,7 +118,7 @@ public function register($name, callable $compiler, callable $evaluator)
118118
throw new \LogicException('Registering functions after calling evaluate(), compile() or parse() is not supported.');
119119
}
120120

121-
$this->functions[$name] = array('compiler' => $compiler, 'evaluator' => $evaluator);
121+
$this->functions[$name] = ['compiler' => $compiler, 'evaluator' => $evaluator];
122122
}
123123

124124
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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ public function addElement(Node $value, Node $key = null)
4141
*/
4242
public function compile(Compiler $compiler)
4343
{
44-
$compiler->raw('array(');
44+
$compiler->raw('[');
4545
$this->compileArguments($compiler);
46-
$compiler->raw(')');
46+
$compiler->raw(']');
4747
}
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(string $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, bool $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(string $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, int $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(string $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(string $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(): array
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)