@@ -3674,30 +3674,12 @@ ZEND_API zend_uchar zend_get_call_op(const zend_op *init_op, zend_function *fbc)
3674
3674
}
3675
3675
/* }}} */
3676
3676
3677
- void zend_compile_call_common (znode * result , zend_ast * args_ast , zend_function * fbc ) /* {{{ */
3677
+ bool zend_compile_call_common (znode * result , zend_ast * args_ast , zend_function * fbc ) /* {{{ */
3678
3678
{
3679
3679
zend_op * opline ;
3680
3680
uint32_t opnum_init = get_next_op_number () - 1 ;
3681
3681
3682
- if (args_ast -> kind != ZEND_AST_CALLABLE_CONVERT ) {
3683
- bool may_have_extra_named_args ;
3684
- uint32_t arg_count = zend_compile_args (args_ast , fbc , & may_have_extra_named_args );
3685
-
3686
- zend_do_extended_fcall_begin ();
3687
-
3688
- opline = & CG (active_op_array )-> opcodes [opnum_init ];
3689
- opline -> extended_value = arg_count ;
3690
-
3691
- if (opline -> opcode == ZEND_INIT_FCALL ) {
3692
- opline -> op1 .num = zend_vm_calc_used_stack (arg_count , fbc );
3693
- }
3694
-
3695
- opline = zend_emit_op (result , zend_get_call_op (opline , fbc ), NULL , NULL );
3696
- if (may_have_extra_named_args ) {
3697
- opline -> extended_value = ZEND_FCALL_MAY_HAVE_EXTRA_NAMED_PARAMS ;
3698
- }
3699
- zend_do_extended_fcall_end ();
3700
- } else {
3682
+ if (args_ast -> kind == ZEND_AST_CALLABLE_CONVERT ) {
3701
3683
opline = & CG (active_op_array )-> opcodes [opnum_init ];
3702
3684
opline -> extended_value = 0 ;
3703
3685
@@ -3709,8 +3691,28 @@ void zend_compile_call_common(znode *result, zend_ast *args_ast, zend_function *
3709
3691
opline -> op1 .num = zend_vm_calc_used_stack (0 , fbc );
3710
3692
}
3711
3693
3712
- opline = zend_emit_op (result , ZEND_CALLABLE_CONVERT , NULL , NULL );
3694
+ zend_emit_op (result , ZEND_CALLABLE_CONVERT , NULL , NULL );
3695
+ return true;
3713
3696
}
3697
+
3698
+ bool may_have_extra_named_args ;
3699
+ uint32_t arg_count = zend_compile_args (args_ast , fbc , & may_have_extra_named_args );
3700
+
3701
+ zend_do_extended_fcall_begin ();
3702
+
3703
+ opline = & CG (active_op_array )-> opcodes [opnum_init ];
3704
+ opline -> extended_value = arg_count ;
3705
+
3706
+ if (opline -> opcode == ZEND_INIT_FCALL ) {
3707
+ opline -> op1 .num = zend_vm_calc_used_stack (arg_count , fbc );
3708
+ }
3709
+
3710
+ opline = zend_emit_op (result , zend_get_call_op (opline , fbc ), NULL , NULL );
3711
+ if (may_have_extra_named_args ) {
3712
+ opline -> extended_value = ZEND_FCALL_MAY_HAVE_EXTRA_NAMED_PARAMS ;
3713
+ }
3714
+ zend_do_extended_fcall_end ();
3715
+ return false;
3714
3716
}
3715
3717
/* }}} */
3716
3718
@@ -4499,6 +4501,7 @@ void zend_compile_method_call(znode *result, zend_ast *ast, uint32_t type) /* {{
4499
4501
zend_op * opline ;
4500
4502
zend_function * fbc = NULL ;
4501
4503
bool nullsafe = ast -> kind == ZEND_AST_NULLSAFE_METHOD_CALL ;
4504
+ uint32_t short_circuiting_checkpoint = zend_short_circuiting_checkpoint ();
4502
4505
4503
4506
if (is_this_fetch (obj_ast )) {
4504
4507
if (this_guaranteed_exists ()) {
@@ -4547,7 +4550,12 @@ void zend_compile_method_call(znode *result, zend_ast *ast, uint32_t type) /* {{
4547
4550
}
4548
4551
}
4549
4552
4550
- zend_compile_call_common (result , args_ast , fbc );
4553
+ if (zend_compile_call_common (result , args_ast , fbc )) {
4554
+ if (short_circuiting_checkpoint != zend_short_circuiting_checkpoint ()) {
4555
+ zend_error_noreturn (E_COMPILE_ERROR ,
4556
+ "Cannot combine nullsafe operator with Closure creation" );
4557
+ }
4558
+ }
4551
4559
}
4552
4560
/* }}} */
4553
4561
0 commit comments