Skip to content

Commit 9d16de6

Browse files
committed
Deprecate passing $ifexpr to ForNode
1 parent ce40c69 commit 9d16de6

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ parameters:
66
count: 1
77
path: src/Extension/CoreExtension.php
88

9-
- # Avoid BC-break
10-
message: '#^Constructor of class Twig\\Node\\ForNode has an unused parameter \$ifexpr\.$#'
11-
identifier: constructor.unusedParameter
12-
count: 1
13-
path: src/Node/ForNode.php
14-
159
- # 2 parameters will be required
1610
message: '#^Method Twig\\Node\\IncludeNode\:\:addGetTemplate\(\) invoked with 2 parameters, 1 required\.$#'
1711
identifier: arguments.count

src/Node/ForNode.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public function __construct(AssignContextVariable $keyTarget, AssignContextVaria
3131
{
3232
$body = new Nodes([$body, $this->loop = new ForLoopNode($lineno)]);
3333

34+
if (null !== $ifexpr) {
35+
trigger_deprecation('twig/twig', '3.19', \sprintf('Passing not-null to the "ifexpr" argument of the "%s" constructor is deprecated.', static::class));
36+
}
37+
3438
$nodes = ['key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body];
3539
if (null !== $else) {
3640
$nodes['else'] = $else;

0 commit comments

Comments
 (0)