@@ -6422,19 +6422,29 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
6422
6422
znode wrapped_operand_result ;
6423
6423
zend_emit_op_tmp (& wrapped_operand_result , ZEND_QM_ASSIGN , & operand_result , NULL );
6424
6424
6425
+ zend_ast * arg_list_ast = zend_ast_create_list (1 , ZEND_AST_ARG_LIST , zend_ast_create_znode (& wrapped_operand_result ));
6426
+ zend_ast * fcall_ast ;
6427
+
6428
+ znode callable_result ;
6429
+
6425
6430
/* Turn $foo |> bar(...) into bar($foo). */
6426
6431
if (callable_ast -> kind == ZEND_AST_CALL
6427
6432
&& callable_ast -> child [1 ]-> kind == ZEND_AST_CALLABLE_CONVERT ) {
6428
- callable_ast = callable_ast -> child [0 ];
6433
+ fcall_ast = zend_ast_create (ZEND_AST_CALL ,
6434
+ callable_ast -> child [0 ], arg_list_ast );
6435
+ /* Turn $foo |> $bar->baz(...) into $bar->baz($foo). */
6436
+ } else if (callable_ast -> kind == ZEND_AST_METHOD_CALL
6437
+ && callable_ast -> child [2 ]-> kind == ZEND_AST_CALLABLE_CONVERT ) {
6438
+ fcall_ast = zend_ast_create (ZEND_AST_METHOD_CALL ,
6439
+ callable_ast -> child [0 ], callable_ast -> child [1 ], arg_list_ast );
6440
+ /* Turn $foo |> $expr into ($expr)($foo) */
6441
+ } else {
6442
+ zend_compile_expr (& callable_result , callable_ast );
6443
+ callable_ast = zend_ast_create_znode (& callable_result );
6444
+ fcall_ast = zend_ast_create (ZEND_AST_CALL ,
6445
+ callable_ast , arg_list_ast );
6429
6446
}
6430
6447
6431
- znode callable_result ;
6432
- zend_compile_expr (& callable_result , callable_ast );
6433
-
6434
- zend_ast * fcall_ast = zend_ast_create (ZEND_AST_CALL ,
6435
- zend_ast_create_znode (& callable_result ),
6436
- zend_ast_create_list (1 , ZEND_AST_ARG_LIST , zend_ast_create_znode (& wrapped_operand_result )));
6437
-
6438
6448
zend_compile_expr (result , fcall_ast );
6439
6449
}
6440
6450
0 commit comments