diff --git a/src/Latte/Compiler/PhpWriter.php b/src/Latte/Compiler/PhpWriter.php index 28af2fe68..38abaf52d 100644 --- a/src/Latte/Compiler/PhpWriter.php +++ b/src/Latte/Compiler/PhpWriter.php @@ -274,9 +274,7 @@ public function removeCommentsPass(MacroTokens $tokens): MacroTokens { $res = new MacroTokens; while ($tokens->nextToken()) { - if (!$tokens->isCurrent($tokens::T_COMMENT)) { - $res->append($tokens->currentToken()); - } + $res->append($tokens->isCurrent($tokens::T_COMMENT) ? ' ' : $tokens->currentToken()); } return $res; } diff --git a/tests/Latte/Compiler.special.phpt b/tests/Latte/Compiler.special.phpt index 087db559e..8f5d8e384 100644 --- a/tests/Latte/Compiler.special.phpt +++ b/tests/Latte/Compiler.special.phpt @@ -33,3 +33,8 @@ Assert::match( '%A%echo LR\Filters::escapeHtmlText(test(fn () => 1))%A%', $latte->compile('{test(fn () => 1)}') ); + +Assert::match( + "%A%('foo')/ **/('bar')%A%", + $latte->compile('{(foo)//**/**/(bar)}') +); diff --git a/tests/Latte/PhpWriter.formatArgs().phpt b/tests/Latte/PhpWriter.formatArgs().phpt index d3bce9a58..a8e74b4b9 100644 --- a/tests/Latte/PhpWriter.formatArgs().phpt +++ b/tests/Latte/PhpWriter.formatArgs().phpt @@ -87,10 +87,11 @@ test('special', function () { Assert::same("'symbol' => \$this->var, ", formatArgs('symbol => $this -> var, ')); Assert::same("'symbol' => \$this->VAR, ", formatArgs('symbol => $this -> VAR, ')); Assert::same("'symbol' => \$this->var", formatArgs('symbol => $this -> var')); - Assert::same("'symbol1' => 'value'", formatArgs('symbol1 => /*value,* /symbol2=>*/value/**/')); + Assert::same("'symbol1' => 'value' ", formatArgs('symbol1 => /*value,* /symbol2=>*/value/**/')); Assert::same('(array)', formatArgs('(array)')); Assert::same('func()[1]', formatArgs('func()[1]')); Assert::same('$var = match(7) {8 => true, default => false,}', formatArgs('$var = match(7) {8 => true, default => false,}')); + Assert::same('a b', formatArgs('a/**/b')); });