Skip to content

Commit

Permalink
fix: compile filter string params not add quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Nov 16, 2021
1 parent dc9dcf6 commit 5615bee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Compiler/AbstractCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function parseInlineFilters(string $echoBody): string
} elseif ($arg[0] === '$') {
$fmtArgs[] = $arg;
} else {
$fmtArgs[] = Str::shellQuote($arg);
$fmtArgs[] = Str::paramQuotes($arg);
}
}

Expand Down
8 changes: 8 additions & 0 deletions test/Compiler/PregCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ public function testCompile_inline_echo_with_filters():void
foreach ($tests as [$in, $out]) {
$this->assertEquals($out, $p->compile($in));
}
}

public function testCompile_disableEchoFilter():void
{
$p = new PregCompiler();
$p->disableEchoFilter();

$tests = [
Expand All @@ -139,6 +143,10 @@ public function testCompile_inline_echo_with_filters():void
'{{ $name ?: "inhere" | substr:0,3 }}',
'<?= substr($name ?: "inhere", 0,3) ?>'
],
[
'{{ $name | append:, }}',
"<?= append(\$name, ',') ?>"
],
['{{ some_func() | raw }}', '<?= some_func() ?>'],
];
foreach ($tests as [$in, $out]) {
Expand Down

0 comments on commit 5615bee

Please sign in to comment.