Skip to content

Commit 3fbfc13

Browse files
committed
fixed CS
1 parent c32ba62 commit 3fbfc13

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

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)

Tests/ExpressionLanguageTest.php

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public function testCachedParse()
5656
->with($cacheItemMock)
5757
;
5858

59-
$parsedExpression = $expressionLanguage->parse('1 + 1', array());
59+
$parsedExpression = $expressionLanguage->parse('1 + 1', []);
6060
$this->assertSame($savedParsedExpression, $parsedExpression);
6161

62-
$parsedExpression = $expressionLanguage->parse('1 + 1', array());
62+
$parsedExpression = $expressionLanguage->parse('1 + 1', []);
6363
$this->assertSame($savedParsedExpression, $parsedExpression);
6464
}
6565

@@ -74,7 +74,7 @@ public function testConstantFunction()
7474

7575
public function testProviders()
7676
{
77-
$expressionLanguage = new ExpressionLanguage(null, array(new TestProvider()));
77+
$expressionLanguage = new ExpressionLanguage(null, [new TestProvider()]);
7878
$this->assertEquals('foo', $expressionLanguage->evaluate('identity("foo")'));
7979
$this->assertEquals('"foo"', $expressionLanguage->compile('identity("foo")'));
8080
$this->assertEquals('FOO', $expressionLanguage->evaluate('strtoupper("foo")'));
@@ -112,46 +112,46 @@ public function testShortCircuitOperatorsCompile($expression, array $names, $exp
112112
public function testParseThrowsInsteadOfNotice()
113113
{
114114
$expressionLanguage = new ExpressionLanguage();
115-
$expressionLanguage->parse('node.', array('node'));
115+
$expressionLanguage->parse('node.', ['node']);
116116
}
117117

118118
public function shortCircuitProviderEvaluate()
119119
{
120-
$object = $this->getMockBuilder('stdClass')->setMethods(array('foo'))->getMock();
120+
$object = $this->getMockBuilder('stdClass')->setMethods(['foo'])->getMock();
121121
$object->expects($this->never())->method('foo');
122122

123-
return array(
124-
array('false and object.foo()', array('object' => $object), false),
125-
array('false && object.foo()', array('object' => $object), false),
126-
array('true || object.foo()', array('object' => $object), true),
127-
array('true or object.foo()', array('object' => $object), true),
128-
);
123+
return [
124+
['false and object.foo()', ['object' => $object], false],
125+
['false && object.foo()', ['object' => $object], false],
126+
['true || object.foo()', ['object' => $object], true],
127+
['true or object.foo()', ['object' => $object], true],
128+
];
129129
}
130130

131131
public function shortCircuitProviderCompile()
132132
{
133-
return array(
134-
array('false and foo', array('foo' => 'foo'), false),
135-
array('false && foo', array('foo' => 'foo'), false),
136-
array('true || foo', array('foo' => 'foo'), true),
137-
array('true or foo', array('foo' => 'foo'), true),
138-
);
133+
return [
134+
['false and foo', ['foo' => 'foo'], false],
135+
['false && foo', ['foo' => 'foo'], false],
136+
['true || foo', ['foo' => 'foo'], true],
137+
['true or foo', ['foo' => 'foo'], true],
138+
];
139139
}
140140

141141
public function testCachingForOverriddenVariableNames()
142142
{
143143
$expressionLanguage = new ExpressionLanguage();
144144
$expression = 'a + b';
145-
$expressionLanguage->evaluate($expression, array('a' => 1, 'b' => 1));
146-
$result = $expressionLanguage->compile($expression, array('a', 'B' => 'b'));
145+
$expressionLanguage->evaluate($expression, ['a' => 1, 'b' => 1]);
146+
$result = $expressionLanguage->compile($expression, ['a', 'B' => 'b']);
147147
$this->assertSame('($a + $B)', $result);
148148
}
149149

150150
public function testStrictEquality()
151151
{
152152
$expressionLanguage = new ExpressionLanguage();
153153
$expression = '123 === a';
154-
$result = $expressionLanguage->compile($expression, array('a'));
154+
$result = $expressionLanguage->compile($expression, ['a']);
155155
$this->assertSame('(123 === $a)', $result);
156156
}
157157

@@ -160,7 +160,7 @@ public function testCachingWithDifferentNamesOrder()
160160
$cacheMock = $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock();
161161
$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
162162
$expressionLanguage = new ExpressionLanguage($cacheMock);
163-
$savedParsedExpressions = array();
163+
$savedParsedExpressions = [];
164164

165165
$cacheMock
166166
->expects($this->exactly(2))
@@ -193,8 +193,8 @@ public function testCachingWithDifferentNamesOrder()
193193
;
194194

195195
$expression = 'a + b';
196-
$expressionLanguage->compile($expression, array('a', 'B' => 'b'));
197-
$expressionLanguage->compile($expression, array('B' => 'b', 'a'));
196+
$expressionLanguage->compile($expression, ['a', 'B' => 'b']);
197+
$expressionLanguage->compile($expression, ['B' => 'b', 'a']);
198198
}
199199

200200
/**
@@ -204,7 +204,7 @@ public function testCachingWithDifferentNamesOrder()
204204
public function testRegisterAfterParse($registerCallback)
205205
{
206206
$el = new ExpressionLanguage();
207-
$el->parse('1 + 1', array());
207+
$el->parse('1 + 1', []);
208208
$registerCallback($el);
209209
}
210210

@@ -226,7 +226,7 @@ public function testRegisterAfterEval($registerCallback)
226226
public function testCallBadCallable()
227227
{
228228
$el = new ExpressionLanguage();
229-
$el->evaluate('foo.myfunction()', array('foo' => new \stdClass()));
229+
$el->evaluate('foo.myfunction()', ['foo' => new \stdClass()]);
230230
}
231231

232232
/**
@@ -242,22 +242,22 @@ public function testRegisterAfterCompile($registerCallback)
242242

243243
public function getRegisterCallbacks()
244244
{
245-
return array(
246-
array(
245+
return [
246+
[
247247
function (ExpressionLanguage $el) {
248248
$el->register('fn', function () {}, function () {});
249249
},
250-
),
251-
array(
250+
],
251+
[
252252
function (ExpressionLanguage $el) {
253253
$el->addFunction(new ExpressionFunction('fn', function () {}, function () {}));
254254
},
255-
),
256-
array(
255+
],
256+
[
257257
function (ExpressionLanguage $el) {
258258
$el->registerProvider(new TestProvider());
259259
},
260-
),
261-
);
260+
],
261+
];
262262
}
263263
}

0 commit comments

Comments
 (0)