@@ -10027,6 +10027,19 @@ ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, const zval *op)
1002710027 }
1002810028 return Z_TYPE_P (op ) <= IS_TRUE || !zend_is_op_long_compatible (op );
1002910029 }
10030+ /* Can happen when called from zend_optimizer_eval_unary_op() */
10031+ if (
10032+ opcode == ZEND_IS_EQUAL
10033+ || opcode == ZEND_IS_NOT_EQUAL
10034+ || opcode == ZEND_BOOL
10035+ || opcode == ZEND_BOOL_NOT
10036+ ) {
10037+ /* BW_NOT on string does not convert the string into an integer. */
10038+ if (Z_TYPE_P (op ) == IS_DOUBLE ) {
10039+ return true;
10040+ }
10041+ return false;
10042+ }
1003010043
1003110044 return 0 ;
1003210045}
@@ -10210,7 +10223,7 @@ static void zend_compile_binary_op(znode *result, zend_ast *ast) /* {{{ */
1021010223 }
1021110224
1021210225 do {
10213- // TODO do not do this for NAN?
10226+ /* TODO: Do this optimization when other side is not float as NAN will warn and we don't want that
1021410227 if (opcode == ZEND_IS_EQUAL || opcode == ZEND_IS_NOT_EQUAL) {
1021510228 if (left_node.op_type == IS_CONST) {
1021610229 if (Z_TYPE(left_node.u.constant) == IS_FALSE) {
@@ -10233,7 +10246,8 @@ static void zend_compile_binary_op(znode *result, zend_ast *ast) /* {{{ */
1023310246 break;
1023410247 }
1023510248 }
10236- } else if (opcode == ZEND_IS_IDENTICAL || opcode == ZEND_IS_NOT_IDENTICAL ) {
10249+ } else */
10250+ if (opcode == ZEND_IS_IDENTICAL || opcode == ZEND_IS_NOT_IDENTICAL ) {
1023710251 /* convert $x === null to is_null($x) (i.e. ZEND_TYPE_CHECK opcode). Do the same thing for false/true. (covers IS_NULL, IS_FALSE, and IS_TRUE) */
1023810252 if (left_node .op_type == IS_CONST ) {
1023910253 if (Z_TYPE (left_node .u .constant ) <= IS_TRUE && Z_TYPE (left_node .u .constant ) >= IS_NULL ) {
@@ -12040,6 +12054,10 @@ static zend_op *zend_delayed_compile_var(znode *result, zend_ast *ast, uint32_t
1204012054
1204112055bool zend_try_ct_eval_cast (zval * result , uint32_t type , zval * op1 )
1204212056{
12057+ /* NAN warns when casting */
12058+ if (UNEXPECTED (Z_TYPE_P (op1 ) == IS_DOUBLE && zend_isnan (Z_DVAL_P (op1 )))) {
12059+ return false;
12060+ }
1204312061 switch (type ) {
1204412062 case _IS_BOOL :
1204512063 ZVAL_BOOL (result , zval_is_true (op1 ));
0 commit comments