diff --git a/src/Latte/Compiler/PhpWriter.php b/src/Latte/Compiler/PhpWriter.php index 129b0123b..a8cc43129 100644 --- a/src/Latte/Compiler/PhpWriter.php +++ b/src/Latte/Compiler/PhpWriter.php @@ -270,9 +270,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 7a895f505..6b29ca5b3 100644 --- a/tests/Latte/PhpWriter.formatArgs().phpt +++ b/tests/Latte/PhpWriter.formatArgs().phpt @@ -87,9 +87,10 @@ 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('a b', formatArgs('a/**/b')); });