@@ -6437,19 +6437,29 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
6437
6437
znode wrapped_operand_result ;
6438
6438
zend_emit_op_tmp (& wrapped_operand_result , ZEND_QM_ASSIGN , & operand_result , NULL );
6439
6439
6440
+ zend_ast * arg_list_ast = zend_ast_create_list (1 , ZEND_AST_ARG_LIST , zend_ast_create_znode (& wrapped_operand_result ));
6441
+ zend_ast * fcall_ast ;
6442
+
6443
+ znode callable_result ;
6444
+
6440
6445
/* Turn $foo |> bar(...) into bar($foo). */
6441
6446
if (callable_ast -> kind == ZEND_AST_CALL
6442
6447
&& callable_ast -> child [1 ]-> kind == ZEND_AST_CALLABLE_CONVERT ) {
6443
- callable_ast = callable_ast -> child [0 ];
6448
+ fcall_ast = zend_ast_create (ZEND_AST_CALL ,
6449
+ callable_ast -> child [0 ], arg_list_ast );
6450
+ /* Turn $foo |> $bar->baz(...) into $bar->baz($foo). */
6451
+ } else if (callable_ast -> kind == ZEND_AST_METHOD_CALL
6452
+ && callable_ast -> child [2 ]-> kind == ZEND_AST_CALLABLE_CONVERT ) {
6453
+ fcall_ast = zend_ast_create (ZEND_AST_METHOD_CALL ,
6454
+ callable_ast -> child [0 ], callable_ast -> child [1 ], arg_list_ast );
6455
+ /* Turn $foo |> $expr into ($expr)($foo) */
6456
+ } else {
6457
+ zend_compile_expr (& callable_result , callable_ast );
6458
+ callable_ast = zend_ast_create_znode (& callable_result );
6459
+ fcall_ast = zend_ast_create (ZEND_AST_CALL ,
6460
+ callable_ast , arg_list_ast );
6444
6461
}
6445
6462
6446
- znode callable_result ;
6447
- zend_compile_expr (& callable_result , callable_ast );
6448
-
6449
- zend_ast * fcall_ast = zend_ast_create (ZEND_AST_CALL ,
6450
- zend_ast_create_znode (& callable_result ),
6451
- zend_ast_create_list (1 , ZEND_AST_ARG_LIST , zend_ast_create_znode (& wrapped_operand_result )));
6452
-
6453
6463
zend_compile_expr (result , fcall_ast );
6454
6464
}
6455
6465
0 commit comments