@@ -6422,19 +6422,29 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
64226422 znode wrapped_operand_result ;
64236423 zend_emit_op_tmp (& wrapped_operand_result , ZEND_QM_ASSIGN , & operand_result , NULL );
64246424
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+
64256430 /* Turn $foo |> bar(...) into bar($foo). */
64266431 if (callable_ast -> kind == ZEND_AST_CALL
64276432 && 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 );
64296446 }
64306447
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-
64386448 zend_compile_expr (result , fcall_ast );
64396449}
64406450
0 commit comments