22
22
use Twig \Node \Expression \ConditionalExpression ;
23
23
use Twig \Node \Expression \ConstantExpression ;
24
24
use Twig \Node \Expression \NameExpression ;
25
+ use Twig \Node \Expression \Ternary \ConditionalTernary ;
25
26
use Twig \Node \Expression \Variable \ContextVariable ;
26
27
use Twig \Node \Node ;
27
28
use Twig \Node \Nodes ;
@@ -308,32 +309,32 @@ public function testCompileLabelWithLabelAndAttributes()
308
309
309
310
public function testCompileLabelWithLabelThatEvaluatesToNull ()
310
311
{
312
+ if (class_exists (ConditionalTernary::class)) {
313
+ $ conditional = new ConditionalTernary (
314
+ // if
315
+ new ConstantExpression (true , 0 ),
316
+ // then
317
+ new ConstantExpression (null , 0 ),
318
+ // else
319
+ new ConstantExpression (null , 0 ),
320
+ 0
321
+ );
322
+ } else {
323
+ $ conditional = new ConditionalExpression (
324
+ // if
325
+ new ConstantExpression (true , 0 ),
326
+ // then
327
+ new ConstantExpression (null , 0 ),
328
+ // else
329
+ new ConstantExpression (null , 0 ),
330
+ 0
331
+ );
332
+ }
333
+
311
334
if (class_exists (Nodes::class)) {
312
- $ arguments = new Nodes ([
313
- new ContextVariable ('form ' , 0 ),
314
- new ConditionalExpression (
315
- // if
316
- new ConstantExpression (true , 0 ),
317
- // then
318
- new ConstantExpression (null , 0 ),
319
- // else
320
- new ConstantExpression (null , 0 ),
321
- 0
322
- ),
323
- ]);
335
+ $ arguments = new Nodes ([new ContextVariable ('form ' , 0 ), $ conditional ]);
324
336
} else {
325
- $ arguments = new Node ([
326
- new NameExpression ('form ' , 0 ),
327
- new ConditionalExpression (
328
- // if
329
- new ConstantExpression (true , 0 ),
330
- // then
331
- new ConstantExpression (null , 0 ),
332
- // else
333
- new ConstantExpression (null , 0 ),
334
- 0
335
- ),
336
- ]);
337
+ $ arguments = new Node ([new NameExpression ('form ' , 0 ), $ conditional ]);
337
338
}
338
339
339
340
if (class_exists (FirstClassTwigCallableReady::class)) {
@@ -359,18 +360,32 @@ public function testCompileLabelWithLabelThatEvaluatesToNull()
359
360
360
361
public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes ()
361
362
{
363
+ if (class_exists (ConditionalTernary::class)) {
364
+ $ conditional = new ConditionalTernary (
365
+ // if
366
+ new ConstantExpression (true , 0 ),
367
+ // then
368
+ new ConstantExpression (null , 0 ),
369
+ // else
370
+ new ConstantExpression (null , 0 ),
371
+ 0
372
+ );
373
+ } else {
374
+ $ conditional = new ConditionalExpression (
375
+ // if
376
+ new ConstantExpression (true , 0 ),
377
+ // then
378
+ new ConstantExpression (null , 0 ),
379
+ // else
380
+ new ConstantExpression (null , 0 ),
381
+ 0
382
+ );
383
+ }
384
+
362
385
if (class_exists (Nodes::class)) {
363
386
$ arguments = new Nodes ([
364
387
new ContextVariable ('form '
57AE
, 0 ),
365
- new ConditionalExpression (
366
- // if
367
- new ConstantExpression (true , 0 ),
368
- // then
369
- new ConstantExpression (null , 0 ),
370
- // else
371
- new ConstantExpression (null , 0 ),
372
- 0
373
- ),
388
+ $ conditional ,
374
389
new ArrayExpression ([
375
390
new ConstantExpression ('foo ' , 0 ),
376
391
new ConstantExpression ('bar ' , 0 ),
@@ -381,12 +396,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
381
396
} else {
382
397
$ arguments = new Node ([
383
398
new NameExpression ('form ' , 0 ),
384
- new ConditionalExpression (
385
- new ConstantExpression (true , 0 ),
386
- new ConstantExpression (null , 0 ),
387
- new ConstantExpression (null , 0 ),
388
- 0
389
- ),
399
+ $ conditional ,
390
400
new ArrayExpression ([
391
401
new ConstantExpression ('foo ' , 0 ),
392
402
new ConstantExpression ('bar ' , 0 ),
0 commit comments