@@ -4934,6 +4934,9 @@ ZEND_API zend_result zend_ssa_inference(zend_arena **arena, const zend_op_array
49344934}
49354935/* }}} */
49364936
4937+ /* Key types whose conversion to an array offset may emit a diagnostic */
4938+ #define MAY_BE_THROWING_KEY (MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)
4939+
49374940ZEND_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 )
49384941{
49394942 if (opline -> op1_type == IS_CV ) {
@@ -5213,7 +5216,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
52135216 return 1 ;
52145217 }
52155218 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 ||
5216- (t2 & (MAY_BE_UNDEF |MAY_BE_ARRAY | MAY_BE_OBJECT | MAY_BE_RESOURCE ));
5219+ (t2 & (MAY_BE_UNDEF |MAY_BE_THROWING_KEY ));
52175220 case ZEND_ASSIGN_OBJ :
52185221 if (t1 & (MAY_BE_ANY - MAY_BE_OBJECT )) {
52195222 return 1 ;
@@ -5265,9 +5268,9 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
52655268 case ZEND_ROPE_END :
52665269 return t2 & (MAY_BE_ARRAY |MAY_BE_OBJECT );
52675270 case ZEND_INIT_ARRAY :
5268- return (opline -> op2_type != IS_UNUSED ) && (t2 & ( MAY_BE_ARRAY | MAY_BE_OBJECT | MAY_BE_RESOURCE ) );
5271+ return (opline -> op2_type != IS_UNUSED ) && (t2 & MAY_BE_THROWING_KEY );
52695272 case ZEND_ADD_ARRAY_ELEMENT :
5270- return (opline -> op2_type == IS_UNUSED ) || (t2 & ( MAY_BE_ARRAY | MAY_BE_OBJECT | MAY_BE_RESOURCE ) );
5273+ return (opline -> op2_type == IS_UNUSED ) || (t2 & MAY_BE_THROWING_KEY );
52715274 case ZEND_STRLEN :
52725275 return (t1 & MAY_BE_ANY ) != MAY_BE_STRING ;
52735276 case ZEND_COUNT :
@@ -5294,9 +5297,9 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
52945297 case ZEND_FETCH_IS :
52955298 return (t2 & (MAY_BE_ARRAY |MAY_BE_OBJECT ));
52965299 case ZEND_ISSET_ISEMPTY_DIM_OBJ :
5297- return (t1 & MAY_BE_OBJECT ) || (t2 & ( MAY_BE_DOUBLE | MAY_BE_ARRAY | MAY_BE_OBJECT ) );
5300+ return (t1 & MAY_BE_OBJECT ) || (t2 & MAY_BE_THROWING_KEY );
52985301 case ZEND_FETCH_DIM_IS :
5299- return (t1 & MAY_BE_OBJECT ) || (t2 & ( MAY_BE_DOUBLE | MAY_BE_ARRAY | MAY_BE_OBJECT | MAY_BE_RESOURCE ) );
5302+ return (t1 & MAY_BE_OBJECT ) || (t2 & MAY_BE_THROWING_KEY );
53005303 case ZEND_CAST :
53015304 switch (opline -> extended_value ) {
53025305 case IS_LONG :
@@ -5317,7 +5320,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
53175320 if ((t2 & MAY_BE_ANY ) != MAY_BE_ARRAY ) {
53185321 return 1 ;
53195322 }
5320- if (( t1 & ( MAY_BE_ARRAY | MAY_BE_OBJECT | MAY_BE_RESOURCE )) ) {
5323+ if (t1 & MAY_BE_THROWING_KEY ) {
53215324 return 1 ;
53225325 }
53235326 return 0 ;
@@ -5342,7 +5345,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
53425345 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 )) {
53435346 return 1 ;
53445347 }
5345- if (t2 & ( MAY_BE_RESOURCE | MAY_BE_ARRAY | MAY_BE_OBJECT ) ) {
5348+ if (t2 & MAY_BE_THROWING_KEY ) {
53465349 return 1 ;
53475350 }
53485351 if (opline -> op2_type == IS_UNUSED ) {
0 commit comments