Skip to content

Commit ed58fc7

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Use ::class keyword when possible
2 parents a3f4e84 + c437826 commit ed58fc7

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

Tests/ExpressionFunctionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ class ExpressionFunctionTest extends TestCase
2323
{
2424
public function testFunctionDoesNotExist()
2525
{
26-
$this->expectException('InvalidArgumentException');
26+
$this->expectException(\InvalidArgumentException::class);
2727
$this->expectExceptionMessage('PHP function "fn_does_not_exist" does not exist.');
2828
ExpressionFunction::fromPhp('fn_does_not_exist');
2929
}
3030

3131
public function testFunctionNamespaced()
3232
{
33-
$this->expectException('InvalidArgumentException');
33+
$this->expectException(\InvalidArgumentException::class);
3434
$this->expectExceptionMessage('An expression function name must be defined when PHP function "Symfony\Component\ExpressionLanguage\Tests\fn_namespaced" is namespaced.');
3535
ExpressionFunction::fromPhp('Symfony\Component\ExpressionLanguage\Tests\fn_namespaced');
3636
}

Tests/ExpressionLanguageTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class ExpressionLanguageTest extends TestCase
2121
{
2222
public function testCachedParse()
2323
{
24-
$cacheMock = $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock();
25-
$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
24+
$cacheMock = $this->getMockBuilder(\Psr\Cache\CacheItemPoolInterface::class)->getMock();
25+
$cacheItemMock = $this->getMockBuilder(\Psr\Cache\CacheItemInterface::class)->getMock();
2626
$savedParsedExpression = null;
2727
$expressionLanguage = new ExpressionLanguage($cacheMock);
2828

@@ -107,15 +107,15 @@ public function testShortCircuitOperatorsCompile($expression, array $names, $exp
107107

108108
public function testParseThrowsInsteadOfNotice()
109109
{
110-
$this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
110+
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
111111
$this->expectExceptionMessage('Unexpected end of expression around position 6 for expression `node.`.');
112112
$expressionLanguage = new ExpressionLanguage();
113113
$expressionLanguage->parse('node.', ['node']);
114114
}
115115

116116
public function shortCircuitProviderEvaluate()
117117
{
118-
$object = $this->getMockBuilder('stdClass')->setMethods(['foo'])->getMock();
118+
$object = $this->getMockBuilder(\stdClass::class)->setMethods(['foo'])->getMock();
119119
$object->expects($this->never())->method('foo');
120120

121121
return [
@@ -155,8 +155,8 @@ public function testStrictEquality()
155155

156156
public function testCachingWithDifferentNamesOrder()
157157
{
158-
$cacheMock = $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock();
159-
$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
158+
$cacheMock = $this->getMockBuilder(\Psr\Cache\CacheItemPoolInterface::class)->getMock();
159+
$cacheItemMock = $this->getMockBuilder(\Psr\Cache\CacheItemInterface::class)->getMock();
160160
$expressionLanguage = new ExpressionLanguage($cacheMock);
161161
$savedParsedExpression = null;
162162

@@ -211,7 +211,7 @@ public function testOperatorCollisions()
211211
*/
212212
public function testRegisterAfterParse($registerCallback)
213213
{
214-
$this->expectException('LogicException');
214+
$this->expectException(\LogicException::class);
215215
$el = new ExpressionLanguage();
216216
$el->parse('1 + 1', []);
217217
$registerCallback($el);
@@ -222,15 +222,15 @@ public function testRegisterAfterParse($registerCallback)
222222
*/
223223
public function testRegisterAfterEval($registerCallback)
224224
{
225-
$this->expectException('LogicException');
225+
$this->expectException(\LogicException::class);
226226
$el = new ExpressionLanguage();
227227
$el->evaluate('1 + 1');
228228
$registerCallback($el);
229229
}
230230

231231
public function testCallBadCallable()
232232
{
233-
$this->expectException('RuntimeException');
233+
$this->expectException(\RuntimeException::class);
234234
$this->expectExceptionMessageMatches('/Unable to call method "\w+" of object "\w+"./');
235235
$el = new ExpressionLanguage();
236236
$el->evaluate('foo.myfunction()', ['foo' => new \stdClass()]);
@@ -241,7 +241,7 @@ public function testCallBadCallable()
241241
*/
242242
public function testRegisterAfterCompile($registerCallback)
243243
{
244-
$this->expectException('LogicException');
244+
$this->expectException(\LogicException::class);
245245
$el = new ExpressionLanguage();
246246
$el->compile('1 + 1');
247247
$registerCallback($el);

Tests/LexerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ public function testTokenize($tokens, $expression)
3939

4040
public function testTokenizeThrowsErrorWithMessage()
4141
{
42-
$this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
42+
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
4343
$this->expectExceptionMessage('Unexpected character "\'" around position 33 for expression `service(faulty.expression.example\').dummyMethod()`.');
4444
$expression = "service(faulty.expression.example').dummyMethod()";
4545
$this->lexer->tokenize($expression);
4646
}
4747

4848
public function testTokenizeThrowsErrorOnUnclosedBrace()
4949
{
50-
$this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
50+
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
5151
$this->expectExceptionMessage('Unclosed "(" around position 7 for expression `service(unclosed.expression.dummyMethod()`.');
5252
$expression = 'service(unclosed.expression.dummyMethod()';
5353
$this->lexer->tokenize($expression);

Tests/ParserTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ParserTest extends TestCase
2121
{
2222
public function testParseWithInvalidName()
2323
{
24-
$this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
24+
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
2525
$this->expectExceptionMessage('Variable "foo" is not valid around position 1 for expression `foo`.');
2626
$lexer = new Lexer();
2727
$parser = new Parser([]);
@@ -30,7 +30,7 @@ public function testParseWithInvalidName()
3030

3131
public function testParseWithZeroInNames()
3232
{
33-
$this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
33+
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
3434
$this->expectExceptionMessage('Variable "foo" is not valid around position 1 for expression `foo`.');
3535
$lexer = new Lexer();
3636
$parser = new Parser([]);
@@ -198,7 +198,7 @@ private function createGetAttrNode($node, $item, $type)
198198
*/
199199
public function testParseWithInvalidPostfixData($expr, $names = [])
200200
{
201-
$this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
201+
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
202202
$lexer = new Lexer();
203203
$parser = new Parser([]);
204204
$parser->parse($lexer->tokenize($expr), $names);
@@ -228,7 +228,7 @@ public function getInvalidPostfixData()
228228

229229
public function testNameProposal()
230230
{
231-
$this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
231+
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
232232
$this->expectExceptionMessage('Did you mean "baz"?');
233233
$lexer = new Lexer();
234234
$parser = new Parser([]);

0 commit comments

Comments
 (0)