Skip to content

Commit 59873a7

Browse files
committed
Improve docs.
1 parent ef2d1a0 commit 59873a7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Zend/zend_compile.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6417,14 +6417,20 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
64176417
zend_ast *operand_ast = ast->child[0];
64186418
zend_ast *callable_ast = ast->child[1];
64196419

6420+
/* Compile the left hand side down to a value first. */
64206421
znode operand_result;
64216422
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+
*/
64226427
znode wrapped_operand_result;
64236428
zend_emit_op_tmp(&wrapped_operand_result, ZEND_QM_ASSIGN, &operand_result, NULL);
64246429

6430+
/* Turn the operand into a function parameter list. */
64256431
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;
64276432

6433+
zend_ast *fcall_ast;
64286434
znode callable_result;
64296435

64306436
/* Turn $foo |> bar(...) into bar($foo). */
@@ -6436,13 +6442,13 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
64366442
} else if (callable_ast->kind == ZEND_AST_METHOD_CALL
64376443
&& callable_ast->child[2]->kind == ZEND_AST_CALLABLE_CONVERT) {
64386444
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);
64406446
/* Turn $foo |> $expr into ($expr)($foo) */
64416447
} else {
64426448
zend_compile_expr(&callable_result, callable_ast);
64436449
callable_ast = zend_ast_create_znode(&callable_result);
64446450
fcall_ast = zend_ast_create(ZEND_AST_CALL,
6445-
callable_ast, arg_list_ast);
6451+
callable_ast, arg_list_ast);
64466452
}
64476453

64486454
zend_compile_expr(result, fcall_ast);

0 commit comments

Comments
 (0)