@@ -6417,14 +6417,20 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
6417
6417
zend_ast * operand_ast = ast -> child [0 ];
6418
6418
zend_ast * callable_ast = ast -> child [1 ];
6419
6419
6420
+ /* Compile the left hand side down to a value first. */
6420
6421
znode operand_result ;
6421
6422
zend_compile_expr (& operand_result , operand_ast );
6423
+
6424
+ /* Wrap the value in a ZEND_QM_ASSIGN opcode to ensure references
6425
+ * always fail. Otherwise, they'd only fail in complex cases like arrays.
6426
+ */
6422
6427
znode wrapped_operand_result ;
6423
6428
zend_emit_op_tmp (& wrapped_operand_result , ZEND_QM_ASSIGN , & operand_result , NULL );
6424
6429
6430
+ /* Turn the operand into a function parameter list. */
6425
6431
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
6432
6433
+ zend_ast * fcall_ast ;
6428
6434
znode callable_result ;
6429
6435
6430
6436
/* Turn $foo |> bar(...) into bar($foo). */
@@ -6436,13 +6442,13 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
6436
6442
} else if (callable_ast -> kind == ZEND_AST_METHOD_CALL
6437
6443
&& callable_ast -> child [2 ]-> kind == ZEND_AST_CALLABLE_CONVERT ) {
6438
6444
fcall_ast = zend_ast_create (ZEND_AST_METHOD_CALL ,
6439
- callable_ast -> child [0 ], callable_ast -> child [1 ], arg_list_ast );
6445
+ callable_ast -> child [0 ], callable_ast -> child [1 ], arg_list_ast );
6440
6446
/* Turn $foo |> $expr into ($expr)($foo) */
6441
6447
} else {
6442
6448
zend_compile_expr (& callable_result , callable_ast );
6443
6449
callable_ast = zend_ast_create_znode (& callable_result );
6444
6450
fcall_ast = zend_ast_create (ZEND_AST_CALL ,
6445
- callable_ast , arg_list_ast );
6451
+ callable_ast , arg_list_ast );
6446
6452
}
6447
6453
6448
6454
zend_compile_expr (result , fcall_ast );
0 commit comments