@@ -105,6 +105,8 @@ static void zend_compile_expr(znode *result, zend_ast *ast);
105105static void zend_compile_stmt (zend_ast * ast );
106106static void zend_compile_assign (znode * result , zend_ast * ast );
107107
108+ static zend_ast * zend_partial_apply (zend_ast * callable_ast , zend_ast * pipe_arg );
109+
108110#ifdef ZEND_CHECK_STACK_LIMIT
109111zend_never_inline static void zend_stack_limit_error (void )
110112{
@@ -5165,43 +5167,20 @@ static zend_result zend_compile_func_array_map(znode *result, zend_ast_list *arg
51655167 }
51665168
51675169 zend_ast * callback = args -> child [0 ];
5168-
5169- /* Bail out if the callback is not a FCC/PFA. */
5170- zend_ast * args_ast ;
5171- switch (callback -> kind ) {
5172- case ZEND_AST_CALL :
5173- case ZEND_AST_STATIC_CALL :
5174- args_ast = zend_ast_call_get_args (callback );
5175- if (args_ast -> kind != ZEND_AST_CALLABLE_CONVERT ) {
5176- return FAILURE ;
5177- }
5178-
5179- break ;
5180- default :
5181- return FAILURE ;
5182- }
5183-
5184- /* Bail out if the callback is assert() due to the AST stringification logic
5185- * breaking for the generated call.
5186- */
5187- if (callback -> kind == ZEND_AST_CALL && zend_string_equals_literal_ci (zend_ast_get_str (callback -> child [0 ]), "assert" )) {
5170+ if (callback -> kind != ZEND_AST_CALL && callback -> kind != ZEND_AST_STATIC_CALL ) {
51885171 return FAILURE ;
51895172 }
51905173
51915174 znode value ;
51925175 value .op_type = IS_TMP_VAR ;
51935176 value .u .op .var = get_temporary_variable ();
51945177
5195- zend_ast_list * callback_args = zend_ast_get_list (((zend_ast_fcc * )args_ast )-> args );
5196- zend_ast * call_args = zend_ast_create_list (0 , ZEND_AST_ARG_LIST );
5197- for (uint32_t i = 0 ; i < callback_args -> children ; i ++ ) {
5198- zend_ast * child = callback_args -> child [i ];
5199- if (child -> kind == ZEND_AST_PLACEHOLDER_ARG ) {
5200- call_args = zend_ast_list_add (call_args , zend_ast_create_znode (& value ));
5201- } else {
5202- ZEND_ASSERT (0 && "not implemented" );
5203- call_args = zend_ast_list_add (call_args , child );
5204- }
5178+ zend_ast * call_args = zend_partial_apply (callback ,
5179+ zend_ast_create_znode (& value ));
5180+ if (!call_args ) {
5181+ CG (active_op_array )-> T -- ;
5182+ /* The callback is not a FCC/PFA, or is not optimizable */
5183+ return FAILURE ;
52055184 }
52065185
52075186 zend_op * opline ;
0 commit comments