Skip to content

Commit

Permalink
Merge pull request #80 from mazarini/master
Browse files Browse the repository at this point in the history
Fix unused variable for tag "embed"
  • Loading branch information
OwlyCode authored Oct 7, 2019
2 parents 16ea015 + ec57526 commit e404c43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Rule/UnusedVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function check(\Twig_TokenStream $tokens)
$blockType = $tokens->look(2)->getValue();

switch ($blockType) {
case 'embed':
case 'include':
if ('with' === $tokens->look(6)->getValue()) {
$this->skip($tokens, 8);
Expand Down
4 changes: 4 additions & 0 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ public function getData()
['{% set bar %}1{% endset %}{% include "foo.html.twig" with {bar: foo} only %}', 'Unused variable "bar".'],
['{% include "foo.html.twig" %}', null],

// Check unused for embed
['{% set foo %}1{% endset %}{% embed "foo.html.twig" with {foo: foo} only %}{% endembed %}', null],
['{% set bar %}1{% endset %}{% embed "foo.html.twig" with {bar: foo} only %}{% endembed %}', 'Unused variable "bar".'],

// Check regression of https://github.com/friendsoftwig/twigcs/issues/62
['{%~ if foo ~%}', null],
['{%~ if foo ~%}', null],
Expand Down

0 comments on commit e404c43

Please sign in to comment.