Skip to content

Commit d7b7a99

Browse files
committed
Improve docs.
1 parent 63c7b63 commit d7b7a99

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
@@ -6432,14 +6432,20 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
64326432
zend_ast *operand_ast = ast->child[0];
64336433
zend_ast *callable_ast = ast->child[1];
64346434

6435+
/* Compile the left hand side down to a value first. */
64356436
znode operand_result;
64366437
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+
*/
64376442
znode wrapped_operand_result;
64386443
zend_emit_op_tmp(&wrapped_operand_result, ZEND_QM_ASSIGN, &operand_result, NULL);
64396444

6445+
/* Turn the operand into a function parameter list. */
64406446
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;
64426447

6448+
zend_ast *fcall_ast;
64436449
znode callable_result;
64446450

64456451
/* Turn $foo |> bar(...) into bar($foo). */
@@ -6451,13 +6457,13 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
64516457
} else if (callable_ast->kind == ZEND_AST_METHOD_CALL
64526458
&& callable_ast->child[2]->kind == ZEND_AST_CALLABLE_CONVERT) {
64536459
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);
64556461
/* Turn $foo |> $expr into ($expr)($foo) */
64566462
} else {
64576463
zend_compile_expr(&callable_result, callable_ast);
64586464
callable_ast = zend_ast_create_znode(&callable_result);
64596465
fcall_ast = zend_ast_create(ZEND_AST_CALL,
6460-
callable_ast, arg_list_ast);
6466+
callable_ast, arg_list_ast);
64616467
}
64626468

64636469
zend_compile_expr(result, fcall_ast);

0 commit comments

Comments
 (0)