feature #4552 Deprecate passing $ifexpr to ForNode (fabpot)

This PR was merged into the 3.x branch.

Discussion
----------

Deprecate passing $ifexpr to ForNode

Commits
-------

9d16de6e3d Deprecate passing $ifexpr to ForNode
This commit is contained in:
Fabien Potencier
2025-01-24 15:07:44 +01:00
2 changed files with 4 additions and 6 deletions
-6
View File
@@ -6,12 +6,6 @@ parameters:
count: 1
path: src/Extension/CoreExtension.php
- # Avoid BC-break
message: '#^Constructor of class Twig\\Node\\ForNode has an unused parameter \$ifexpr\.$#'
identifier: constructor.unusedParameter
count: 1
path: src/Node/ForNode.php
- # 2 parameters will be required
message: '#^Method Twig\\Node\\IncludeNode\:\:addGetTemplate\(\) invoked with 2 parameters, 1 required\.$#'
identifier: arguments.count
+4
View File
@@ -31,6 +31,10 @@ class ForNode extends Node
{
$body = new Nodes([$body, $this->loop = new ForLoopNode($lineno)]);
if (null !== $ifexpr) {
trigger_deprecation('twig/twig', '3.19', \sprintf('Passing not-null to the "ifexpr" argument of the "%s" constructor is deprecated.', static::class));
}
$nodes = ['key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body];
if (null !== $else) {
$nodes['else'] = $else;