Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 9, 2024
1 parent 46f4991 commit 6edb03d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Latte/Compiler/Nodes/Php/FilterNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function print(PrintContext $context): string

public function printSimple(PrintContext $context, string $expr): string
{
return '($this->filters->' . $this->name . ')('
return '($this->filters->' . $context->objectProperty($this->name) . ')('
. $expr
. ($this->args ? ', ' . $context->implode($this->args) : '')
. ')';
Expand Down
8 changes: 5 additions & 3 deletions src/Latte/Compiler/Nodes/Php/ModifierNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,21 @@ public function printSimple(PrintContext $context, string $expr): string
{
$escape = $this->escape;
$check = $this->check;
$expr = new Expression\AuxiliaryNode(fn() => $expr);
foreach ($this->filters as $filter) {
$name = $filter->name->name;
if (['nocheck' => 1, 'noCheck' => 1][$name] ?? null) {
if ($name === 'nocheck' || $name === 'noCheck') {
$check = false;
} elseif ($name === 'noescape') {
$escape = false;
} else {
if (['datastream' => 1, 'dataStream' => 1][$name] ?? null) {
if ($name === 'datastream' || $name === 'dataStream') {
$check = false;
}
$expr = $filter->printSimple($context, $expr);
$expr = new Expression\FilterCallNode($expr, $filter);
}
}
$expr = $expr->print($context);

$escaper = $context->getEscaper();
if ($check) {
Expand Down
2 changes: 1 addition & 1 deletion src/Latte/Compiler/PrintContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function ($m) use (&$pos) {
function ($m) use ($args) {
[, $pos, $fn, $var] = $m;
$var = substr($var, 1, -1);
/** @var Nodes\FilterNode[] $args */
/** @var Nodes\ModifierNode[] $args */
return match ($fn) {
'modify' => $args[$pos]->printSimple($this, $var),
'modifyContent' => $args[$pos]->printContentAware($this, $var),
Expand Down

0 comments on commit 6edb03d

Please sign in to comment.