twigcs icon indicating copy to clipboard operation
twigcs copied to clipboard

Unused variable should not be trigger if the child mutate a parent's variable.

Open RSickenberg opened this issue 1 year ago • 1 comments

Steps required to reproduce the problem

  1. Use a parent template with a variable A
  2. The child template extending the parent one reset the A to another value.
  3. The parser still thinks A is unused on the children.

Expected Result

  • No error is thrown when the children change the parent variable.

Actual Result

  • An error (or warning, whatsoever) is thrown thinking the children variable is not used.

RSickenberg avatar Aug 02 '22 13:08 RSickenberg

Noticed the same, here a code sample that does it:

{% extends 'base.html.twig' %}

{% set layoutTitle = 'Home' %}

{% block main %}
Test
{% endblock %}
<html>
<head>
  <title>{{ layoutTitle }}</title>
</head>
<body>
{% block main %}{% endblock %}
</body>
</html>

ruudk avatar Feb 24 '23 07:02 ruudk