From feb835c2f9565c1cf11713b6a0e044dba78a6780 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Wed, 15 Feb 2017 10:27:11 +0100 Subject: [PATCH] Fix mixin js-phpize unneeded call --- src/Jade/Compiler/ExpressionCompiler.php | 6 +++++- tests/features/expressionLanguage.php | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Jade/Compiler/ExpressionCompiler.php b/src/Jade/Compiler/ExpressionCompiler.php index 33ff831b..ff9a50a0 100644 --- a/src/Jade/Compiler/ExpressionCompiler.php +++ b/src/Jade/Compiler/ExpressionCompiler.php @@ -50,7 +50,11 @@ protected function getPhpCodeFromJs($arguments) { if ( preg_match('/^\s*array\s*' . Scanner::PARENTHESES . '\s*$/i', $arguments[0]) || - preg_match('/^\(*isset\(\$/i', $arguments[0]) + preg_match('/^\(*isset\(\$/i', $arguments[0]) || + ( + preg_match('/^\s*array_merge\s*' . Scanner::PARENTHESES . '/i', $arguments[0]) && + preg_match('/\s*array\s*' . Scanner::PARENTHESES . '\s*/i', $arguments[0]) + ) ) { return $arguments[0]; } diff --git a/tests/features/expressionLanguage.php b/tests/features/expressionLanguage.php index f788d83b..d90bf1fd 100644 --- a/tests/features/expressionLanguage.php +++ b/tests/features/expressionLanguage.php @@ -36,6 +36,9 @@ public function testJsExpression() $this->assertSame('array(1)', $actual); $actual = trim($compiler->callPhpizeExpression('addDollarIfNeeded', 'a')); $this->assertSame('$a', $actual); + + $actual = trim($jade->render("mixin test\n div&attributes(attributes)\nbody\n +test()(class='test')")); + $this->assertSame('
', $actual); } public function testPhpExpression()