@@ -4926,6 +4926,9 @@ ZEND_API zend_result zend_ssa_inference(zend_arena **arena, const zend_op_array
49264926}
49274927/* }}} */
49284928
4929+ /* Key types whose conversion to an array offset may emit a diagnostic */
4930+ #define MAY_BE_THROWING_KEY (MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)
4931+
49294932ZEND_API bool zend_may_throw_ex (const zend_op * opline , const zend_ssa_op * ssa_op , const zend_op_array * op_array , const zend_ssa * ssa , uint32_t t1 , uint32_t t2 )
49304933{
49314934 if (opline -> op1_type == IS_CV ) {
@@ -5205,7 +5208,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
52055208 return 1 ;
52065209 }
52075210 return (t1 & (MAY_BE_OBJECT |MAY_BE_RESOURCE |MAY_BE_TRUE |MAY_BE_FALSE |MAY_BE_STRING |MAY_BE_LONG |MAY_BE_DOUBLE )) || opline -> op2_type == IS_UNUSED ||
5208- (t2 & (MAY_BE_UNDEF |MAY_BE_ARRAY | MAY_BE_OBJECT | MAY_BE_RESOURCE ));
5211+ (t2 & (MAY_BE_UNDEF |MAY_BE_THROWING_KEY ));
52095212 case ZEND_ASSIGN_OBJ :
52105213 if (t1 & (MAY_BE_ANY - MAY_BE_OBJECT )) {
52115214 return 1 ;
@@ -5257,9 +5260,9 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
52575260 case ZEND_ROPE_END :
52585261 return t2 & (MAY_BE_ARRAY |MAY_BE_OBJECT );
52595262 case ZEND_INIT_ARRAY :
5260- return (opline -> op2_type != IS_UNUSED ) && (t2 & ( MAY_BE_ARRAY | MAY_BE_OBJECT | MAY_BE_RESOURCE ) );
5263+ return (opline -> op2_type != IS_UNUSED ) && (t2 & MAY_BE_THROWING_KEY );
52615264 case ZEND_ADD_ARRAY_ELEMENT :
5262- return (opline -> op2_type == IS_UNUSED ) || (t2 & ( MAY_BE_ARRAY | MAY_BE_OBJECT | MAY_BE_RESOURCE ) );
5265+ return (opline -> op2_type == IS_UNUSED ) || (t2 & MAY_BE_THROWING_KEY );
52635266 case ZEND_STRLEN :
52645267 return (t1 & MAY_BE_ANY ) != MAY_BE_STRING ;
52655268 case ZEND_COUNT :
@@ -5286,9 +5289,9 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
52865289 case ZEND_FETCH_IS :
52875290 return (t2 & (MAY_BE_ARRAY |MAY_BE_OBJECT ));
52885291 case ZEND_ISSET_ISEMPTY_DIM_OBJ :
5289- return (t1 & MAY_BE_OBJECT ) || (t2 & ( MAY_BE_DOUBLE | MAY_BE_ARRAY | MAY_BE_OBJECT ) );
5292+ return (t1 & MAY_BE_OBJECT ) || (t2 & MAY_BE_THROWING_KEY );
52905293 case ZEND_FETCH_DIM_IS :
5291- return (t1 & MAY_BE_OBJECT ) || (t2 & ( MAY_BE_DOUBLE | MAY_BE_ARRAY | MAY_BE_OBJECT | MAY_BE_RESOURCE ) );
5294+ return (t1 & MAY_BE_OBJECT ) || (t2 & MAY_BE_THROWING_KEY );
52925295 case ZEND_CAST :
52935296 switch (opline -> extended_value ) {
52945297 case IS_LONG :
@@ -5309,7 +5312,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
53095312 if ((t2 & MAY_BE_ANY ) != MAY_BE_ARRAY ) {
53105313 return 1 ;
53115314 }
5312- if (( t1 & ( MAY_BE_ARRAY | MAY_BE_OBJECT | MAY_BE_RESOURCE )) ) {
5315+ if (t1 & MAY_BE_THROWING_KEY ) {
53135316 return 1 ;
53145317 }
53155318 return 0 ;
@@ -5334,7 +5337,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
53345337 if (t1 & (MAY_BE_FALSE |MAY_BE_TRUE |MAY_BE_LONG |MAY_BE_DOUBLE |MAY_BE_STRING |MAY_BE_OBJECT |MAY_BE_RESOURCE |MAY_BE_REF )) {
53355338 return 1 ;
53365339 }
5337- if (t2 & ( MAY_BE_RESOURCE | MAY_BE_ARRAY | MAY_BE_OBJECT ) ) {
5340+ if (t2 & MAY_BE_THROWING_KEY ) {
53385341 return 1 ;
53395342 }
53405343 if (opline -> op2_type == IS_UNUSED ) {
0 commit comments