diff --git a/bin/opcode.php b/bin/opcode.php index 3910e434..a43f6619 100755 --- a/bin/opcode.php +++ b/bin/opcode.php @@ -9,4 +9,4 @@ if (!file_exists($file)) { echo "File not found: " . $file . "\n"; exit(1); } -shell_exec("php -d opcache.enable_cli=On -d opcache.opt_debug_level=0x10000 " . $file); \ No newline at end of file +shell_exec("php -d zend_extension=opcache -d opcache.enable_cli=On -d opcache.opt_debug_level=0x10000 " . $file); \ No newline at end of file diff --git a/src/Php/Parser/BinaryOpTrait.php b/src/Php/Parser/BinaryOpTrait.php index bb9fec06..f752e65d 100644 --- a/src/Php/Parser/BinaryOpTrait.php +++ b/src/Php/Parser/BinaryOpTrait.php @@ -142,15 +142,29 @@ trait BinaryOpTrait protected function parseBinaryOpConcat(Expr\BinaryOp\Concat $expr): string { - $left = $this->parseExpr($expr->left); - $right = $this->parseExpr($expr->right); + $items = []; + $this->flattenConcatExpr($expr, $items); + + $argList = []; + foreach ($items as $item) { + $type = $this->detectTypeOfExpr($item); + if ($type === self::TYPE_VOID) { + $this->fatalError($expr, 'Cannot concat void'); + } + $argList[] = $this->convertExprToStringByType($this->parseExpr($item), $type); + } - $leftType = $this->detectTypeOfExpr($expr->left); - $rightType = $this->detectTypeOfExpr($expr->right); - if ($leftType === self::TYPE_VOID or $rightType === self::TYPE_VOID) { - $this->fatalError($expr, 'Cannot concat void'); + return Symbol::concat() . '(' . Symbol::argList() . '{' . implode(', ', $argList) . '})'; + } + + private function flattenConcatExpr(NodeAbstract $expr, array &$items): void + { + if ($expr instanceof Expr\BinaryOp\Concat) { + $this->flattenConcatExpr($expr->left, $items); + $this->flattenConcatExpr($expr->right, $items); + } else { + $items[] = $expr; } - return Symbol::concat() . '(' . $this->convertExprToStringByType($left, $leftType) . ', ' . $this->convertExprToStringByType($right, $rightType) . ')'; } protected function parseBinaryOpSmaller(Expr\BinaryOp\Smaller $expr): string