Skip to content

Commit

Permalink
Bug fix: {% apply %} was not properly supported
Browse files Browse the repository at this point in the history
*Of course* the inaugural release had to have a blocking bug, right? 😏
  • Loading branch information
drjayvee committed Oct 28, 2024
1 parent d5e3ef3 commit c672040
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "Jeroen Versteeg"
}
],
"version": "1.0.0",
"version": "1.0.1",
"autoload": {
"psr-4": {
"AlisQI\\TwigQI\\": "src/"
Expand Down
4 changes: 4 additions & 0 deletions src/Inspection/InvalidDotOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ private function extractScopedVariableNames(ArrowFunctionExpression|ForNode|SetN
) {
$names = $node->getNode('names');

if (!$names->hasNode('0')) { // skip {% apply %} (see ApplyTokenParser)
return [];
}

$variables = [$names->getNode('0')->getAttribute('name')];
if ($names->hasNode('1')) {
$variables[] = $names->getNode('1')->getAttribute('name');
Expand Down
16 changes: 16 additions & 0 deletions tests/InvalidDotOperationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,20 @@ public function test_itSupportsNameOverloading(string $content, bool $isValid):
implode(', ', $this->errors)
);
}

public function test_applyTagDoesNotBreak(): void
{
$this->env->createTemplate(
<<<EOF
{% apply upper %}
{{ foo.bar }}
{% endapply %}
EOF
);

self::assertEmpty(
$this->errors,
"Error should not trigger when accessing dynamic object property"
);
}
}

0 comments on commit c672040

Please sign in to comment.