8000 [ExpressionLanguage] Remove deprecated code paths · symfony/symfony@fc3126a · GitHub
[go: up one dir, main page]

Skip to content

Commit fc3126a

Browse files
[ExpressionLanguage] Remove deprecated code paths
1 parent 9e248b8 commit fc3126a

File tree

4 files changed

+17
-21
lines changed

4 files changed

+17
-21
lines changed

UPGRADE-7.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ DoctrineBridge
4545
* DoctrineBridge now requires `doctrine/event-manager:^2`
4646
* Add parameter `$isSameDatabase` to `DoctrineTokenProvider::configureSchema()`
4747

48+
ExpressionLanguage
49+
------------------
50+
51+
* The `in` operator now uses strict comparison
52+
4853
Filesystem
4954
----------
5055

src/Symfony/Component/ExpressionLanguage/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.0
5+
---
6+
7+
* The `in` operator now uses strict comparison
8+
49
6.3
510
---
611

src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,9 @@ public function toArray(): array
176176
return ['(', $this->nodes['left'], ' '.$this->attributes['operator'].' ', $this->nodes['right'], ')'];
177177
}
178178

179-
/**
180-
* @internal to be replaced by an inline strict call to in_array() in version 7.0
181-
*/
182179
public static function inArray($value, array $array): bool
183180
{
184-
if (false === $key = array_search($value, $array)) {
185-
return false;
186-
}
187-
188-
if (!\in_array($value, $array, true)) {
189-
trigger_deprecation('symfony/expression-language', '6.3', 'The "in" operator will use strict comparisons in Symfony 7.0. Loose match found with key "%s" for value %s. Normalize the array parameter so it only has the expected types or implement loose matching in your own expression function.', $key, json_encode($value));
190-
}
191-
192-
return true;
181+
return \in_array($value, $array, true);
193182
}
194183

195184
private function evaluateMatches(string $regexp, ?string $str): int

src/Symfony/Component/ExpressionLanguage/Tests/Node/BinaryNodeTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\ExpressionLanguage\Tests\Node;
1313

14-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1514
use Symfony\Component\ExpressionLanguage\Compiler;
1615
use Symfony\Component\ExpressionLanguage\Node\ArrayNode;
1716
use Symfony\Component\ExpressionLanguage\Node\BinaryNode;
@@ -21,8 +20,6 @@
2120

2221
class BinaryNodeTest extends AbstractNodeTestCase
2322
{
24-
use ExpectDeprecationTrait;
25-
2623
public static function getEvaluateData(): array
2724
{
2825
$array = new ArrayNode();
@@ -219,17 +216,17 @@ public function testCompileMatchesWithInvalidRegexpAsExpression()
219216
}
220217

221218
/**
222-
* @group legacy
219+
* @testWith [1]
220+
* ["true"]
223221
*/
224-
public function testInOperatorStrictness()
222+
public function testInOperatorStrictness(mixed $value)
225223
{
226224
$array = new ArrayNode();
227-
$array->addElement(new ConstantNode('a'));
225+
$array->addElement(new ConstantNode('1'));
228226
$array->addElement(new ConstantNode(true));
229227

230-
$node = new BinaryNode('in', new ConstantNode('b'), $array);
228+
$node = new BinaryNode('in', new ConstantNode($value), $array);
231229

232-
$this->expectDeprecation('Since symfony/expression-language 6.3: The "in" operator will use strict comparisons in Symfony 7.0. Loose match found with key "1" for value "b". Normalize the array parameter so it only has the expected types or implement loose matching in your own expression function.');
233-
$this->assertTrue($node->evaluate([], []));
230+
$this->assertFalse($node->evaluate([], []));
234231
}
235232
}

0 commit comments

Comments
 (0)
0