Closed (fixed)
Project:
SDC Devel
Version:
1.0.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Mar 2025 at 20:01 UTC
Updated:
22 Mar 2025 at 11:49 UTC
Jump to comment: Most recent
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.
Fix the warning.
Implement
Improved warning.
None.
None.
Comments
Comment #2
pdureau commentedHello 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:
is not nullis parsed as https://github.com/twigphp/Twig/blob/3.x/src/Node/Expression/Test/NullTe...variable ??is parsed as https://github.com/twigphp/Twig/blob/3.x/src/Node/Expression/Binary/Null...@mogtofu33: What do you thing about that?
Comment #3
pdureau commentedis it related to #3511772: Ternary and default tests update with Twig 3.19 ?
Comment #5
mogtofu33 commentedNullCoalesceBinary didn't exist before Twig 3.7, added as a new test and fix the false positive here.