Problem/Motivation

This condition:

{% if variavble is not null %}

raises the warning "Use `|default(foo)` filter instead of null ternary `??`."

It should not mention null ternaries when null ternaries are not in use.

Proposed resolution

Fix the warning.

Remaining tasks

Implement

User interface changes

Improved warning.

API changes

None.

Data model changes

None.

Comments

liam morland created an issue. See original summary.

pdureau’s picture

Assigned: Unassigned » mogtofu33

Hello Liam,

sdc_devel validator is working on the AST (abstract syntax tree) from the already parsed template, so sometimes 2 different template syntaxes are parsed as the same nodes and trigger the same warnings/errors.

However, it seems those expressions produces clearly different nodes:

@mogtofu33: What do you thing about that?

pdureau’s picture

  • mogtofu33 committed 007e22d9 on 1.0.x
    Issue #3511259 by liam morland, mogtofu33: Warning is raised about null...
mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Active » Fixed

NullCoalesceBinary didn't exist before Twig 3.7, added as a new test and fix the false positive here.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.