Allow constant folding bw_not on string

This will not actually error.
This commit is contained in:
Nikita Popov 2021-11-11 09:49:48 +01:00
parent 4aa73bbfc4
commit 4df15e8245

View file

@ -8373,6 +8373,10 @@ static inline bool zend_try_ct_eval_binary_op(zval *result, uint32_t opcode, zva
ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, zval *op)
{
if (opcode == ZEND_BW_NOT) {
/* BW_NOT on string does not convert the string into an integer. */
if (Z_TYPE_P(op) == IS_STRING) {
return 0;
}
return Z_TYPE_P(op) <= IS_TRUE || !zend_is_op_long_compatible(op);
}