@@ -6432,14 +6432,20 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
6432
6432
zend_ast * operand_ast = ast -> child [0 ];
6433
6433
zend_ast * callable_ast = ast -> child [1 ];
6434
6434
6435
+ /* Compile the left hand side down to a value first. */
6435
6436
znode operand_result ;
6436
6437
zend_compile_expr (& operand_result , operand_ast );
6438
+
6439
+ /* Wrap the value in a ZEND_QM_ASSIGN opcode to ensure references
6440
+ * always fail. Otherwise, they'd only fail in complex cases like arrays.
6441
+ */
6437
6442
znode wrapped_operand_result ;
6438
6443
zend_emit_op_tmp (& wrapped_operand_result , ZEND_QM_ASSIGN , & operand_result , NULL );
6439
6444
6445
+ /* Turn the operand into a function parameter list. */
6440
6446
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
6447
6448
+ zend_ast * fcall_ast ;
6443
6449
znode callable_result ;
6444
6450
6445
6451
/* Turn $foo |> bar(...) into bar($foo). */
@@ -6451,13 +6457,13 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
6451
6457
} else if (callable_ast -> kind == ZEND_AST_METHOD_CALL
6452
6458
&& callable_ast -> child [2 ]-> kind == ZEND_AST_CALLABLE_CONVERT ) {
6453
6459
fcall_ast = zend_ast_create (ZEND_AST_METHOD_CALL ,
6454
- callable_ast -> child [0 ], callable_ast -> child [1 ], arg_list_ast );
6460
+ callable_ast -> child [0 ], callable_ast -> child [1 ], arg_list_ast );
6455
6461
/* Turn $foo |> $expr into ($expr)($foo) */
6456
6462
} else {
6457
6463
zend_compile_expr (& callable_result , callable_ast );
6458
6464
callable_ast = zend_ast_create_znode (& callable_result );
6459
6465
fcall_ast = zend_ast_create (ZEND_AST_CALL ,
6460
- callable_ast , arg_list_ast );
6466
+ callable_ast , arg_list_ast );
6461
6467
}
6462
6468
6463
6469
zend_compile_expr (result , fcall_ast );
0 commit comments