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