We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0f8b8b5 commit 69a6febCopy full SHA for 69a6feb
Zend/zend_ast.c
@@ -2211,17 +2211,10 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
2211
zend_ast_export_var(str, ast->child[1], 0, indent);
2212
break;
2213
case ZEND_AST_CALL:
2214
- if (ast->attr & ZEND_CALL_SYNTAX_PIPE) {
2215
- zend_ast_export_ex(str, ast->child[1], 0, indent);
2216
- smart_str_appends(str, " |> ");
2217
- zend_ast_export_ns_name(str, ast->child[0], 0, indent);
2218
- }
2219
- else {
2220
2221
- smart_str_appendc(str, '(');
2222
2223
- smart_str_appendc(str, ')');
2224
+ zend_ast_export_ns_name(str, ast->child[0], 0, indent);
+ smart_str_appendc(str, '(');
+ zend_ast_export_ex(str, ast->child[1], 0, indent);
+ smart_str_appendc(str, ')');
2225
2226
case ZEND_AST_PARENT_PROPERTY_HOOK_CALL:
2227
smart_str_append(str, Z_STR_P(zend_ast_get_zval(ast->child[0])));
Zend/zend_ast.h
@@ -153,6 +153,7 @@ enum _zend_ast_kind {
153
ZEND_AST_MATCH_ARM,
154
ZEND_AST_NAMED_ARG,
155
ZEND_AST_PARENT_PROPERTY_HOOK_CALL,
156
+ ZEND_AST_PIPE,
157
158
/* 3 child nodes */
159
ZEND_AST_METHOD_CALL = 3 << ZEND_AST_NUM_CHILDREN_SHIFT,
Zend/zend_compile.c
@@ -6598,6 +6598,30 @@ static void zend_compile_match(znode *result, zend_ast *ast)
6598
efree(jmp_end_opnums);
6599
}
6600
6601
+static void zend_compile_pipe(znode *result, zend_ast *ast)
6602
+{
6603
+ zend_ast *operand_ast = ast->child[0];
6604
+ zend_ast *callable_ast = ast->child[1];
6605
+
6606
+ znode operand_result;
6607
+ zend_compile_expr(&operand_result, operand_ast);
6608
6609
+ /* Turn $foo |> bar(...) into bar($foo). */
6610
+ if (callable_ast->kind == ZEND_AST_CALL
6611
+ && callable_ast->child[1]->kind == ZEND_AST_CALLABLE_CONVERT) {
6612
+ callable_ast = callable_ast->child[0];
6613
+ }
6614
6615
+ znode callable_result;
6616
+ zend_compile_expr(&callable_result, callable_ast);
6617
6618
+ zend_ast *fcall_ast = zend_ast_create(ZEND_AST_CALL,
6619
+ zend_ast_create_znode(&callable_result),
6620
+ zend_ast_create_list(1, ZEND_AST_ARG_LIST, zend_ast_create_znode(&operand_result)));
6621
6622
+ zend_compile_expr(result, fcall_ast);
6623
+}
6624
6625
static void zend_compile_try(zend_ast *ast) /* {{{ */
6626
{
6627
zend_ast *try_ast = ast->child[0];
@@ -11603,6 +11627,9 @@ static void zend_compile_expr_inner(znode *result, zend_ast *ast) /* {{{ */
11603
11627
case ZEND_AST_MATCH:
11604
11628
zend_compile_match(result, ast);
11605
11629
return;
11630
+ case ZEND_AST_PIPE:
11631
+ zend_compile_pipe(result, ast);
11632
+ return;
11606
11633
default:
11607
11634
ZEND_ASSERT(0 /* not supported */);
11608
11635
Zend/zend_compile.h
@@ -1030,7 +1030,6 @@ ZEND_API zend_string *zend_type_to_string(zend_type type);
1030
/* These should not clash with ZEND_ACC_PPP_MASK and ZEND_ACC_PPP_SET_MASK */
1031
#define ZEND_PARAM_REF (1<<3)
1032
#define ZEND_PARAM_VARIADIC (1<<4)
1033
-#define ZEND_CALL_SYNTAX_PIPE (1u << 2u)
1034
1035
#define ZEND_NAME_FQ 0
1036
#define ZEND_NAME_NOT_FQ 1
Zend/zend_language_parser.y
@@ -1281,7 +1281,7 @@ expr:
1281
| expr T_IS_NOT_EQUAL expr
1282
{ $$ = zend_ast_create_binary_op(ZEND_IS_NOT_EQUAL, $1, $3); }
1283
| expr T_PIPE expr
1284
- { $$ = zend_ast_create(ZEND_AST_CALL, $3, zend_ast_create_list(1, ZEND_AST_ARG_LIST, $1) ); $$->attr = ZEND_CALL_SYNTAX_PIPE; }
+ { $$ = zend_ast_create(ZEND_AST_PIPE, $1, $3); }
1285
| expr '<' expr
1286
{ $$ = zend_ast_create_binary_op(ZEND_IS_SMALLER, $1, $3); }
1287
| expr T_IS_SMALLER_OR_EQUAL expr
0 commit comments