Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85ac690

Browse files
committed
[ExpressionLanguage] Remove type-hints on Token
Added type-hints on Token break Parser when treating numbers (`object === 123` compile as `$object === "123"`)
1 parent 61b7534 commit 85ac690

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ public function testCachingForOverriddenVariableNames()
137137
$this->assertSame('($a + $B)', $result);
138138
}
139139

140+
public function testStrictEquality()
141+
{
142+
$expressionLanguage = new ExpressionLanguage();
143+
$expression = '123 === a';
144+
$result = $expressionLanguage->compile($expression, array('a'));
145+
$this->assertSame('(123 === $a)', $result);
146+
}
147+
140148
public function testCachingWithDifferentNamesOrder()
141149
{
142150
$cacheMock = $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock();

src/Symfony/Component/ExpressionLanguage/Token.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class Token
3030
const PUNCTUATION_TYPE = 'punctuation';
3131

3232
/**
33-
* @param string $type The type of the token (self::*_TYPE)
34-
* @param string $value The token value
35-
* @param int $cursor The cursor position in the source
33+
* @param string $type The type of the token (self::*_TYPE)
34+
* @param string|int|float $value The token value
35+
* @param int $cursor The cursor position in the source
3636
*/
37-
public function __construct(string $type, ?string $value, ?int $cursor)
37+
public function __construct(string $type, $value, ?int $cursor)
3838
{
3939
$this->type = $type;
4040
$this->value = $value;

0 commit comments

Comments
 (0)