mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
tree-wide: Replace zval_is_true() by zend_is_true() (#20065)
* tree-wide: Replace `zval_is_true()` by `zend_is_true()` The former is a direct alias of the latter which is much more often used. * zend_operators: Remove `zval_is_true()`
This commit is contained in:
@@ -20,6 +20,8 @@ PHP 8.6 INTERNALS UPGRADE NOTES
|
||||
. The misnamed ZVAL_IS_NULL() has been removed. Use Z_ISNULL() instead.
|
||||
. New zend_class_entry.ce_flags2 and zend_function.fn_flags2 fields were
|
||||
added, given the primary flags were running out of bits.
|
||||
. The zval_is_true() alias of zend_is_true() has been removed. Call
|
||||
zend_is_true() directly instead.
|
||||
|
||||
========================
|
||||
2. Build system changes
|
||||
|
||||
@@ -12062,7 +12062,7 @@ bool zend_try_ct_eval_cast(zval *result, uint32_t type, zval *op1)
|
||||
}
|
||||
switch (type) {
|
||||
case _IS_BOOL:
|
||||
ZVAL_BOOL(result, zval_is_true(op1));
|
||||
ZVAL_BOOL(result, zend_is_true(op1));
|
||||
return true;
|
||||
case IS_LONG:
|
||||
if (Z_TYPE_P(op1) == IS_DOUBLE && !ZEND_DOUBLE_FITS_LONG(Z_DVAL_P((op1)))) {
|
||||
|
||||
@@ -1593,7 +1593,7 @@ ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1,
|
||||
}
|
||||
}
|
||||
ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BOOL_XOR);
|
||||
op1_val = zval_is_true(op1);
|
||||
op1_val = zend_is_true(op1);
|
||||
}
|
||||
} while (0);
|
||||
do {
|
||||
@@ -1613,7 +1613,7 @@ ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1,
|
||||
}
|
||||
}
|
||||
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BOOL_XOR);
|
||||
op2_val = zval_is_true(op2);
|
||||
op2_val = zend_is_true(op2);
|
||||
}
|
||||
} while (0);
|
||||
|
||||
@@ -1641,7 +1641,7 @@ ZEND_API zend_result ZEND_FASTCALL boolean_not_function(zval *result, zval *op1)
|
||||
}
|
||||
ZEND_TRY_UNARY_OBJECT_OPERATION(ZEND_BOOL_NOT);
|
||||
|
||||
ZVAL_BOOL(result, !zval_is_true(op1));
|
||||
ZVAL_BOOL(result, !zend_is_true(op1));
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -2433,13 +2433,13 @@ ZEND_API int ZEND_FASTCALL zend_compare(zval *op1, zval *op2) /* {{{ */
|
||||
converted = true;
|
||||
}
|
||||
} else if (Z_TYPE_P(op1) < IS_TRUE) {
|
||||
return zval_is_true(op2) ? -1 : 0;
|
||||
return zend_is_true(op2) ? -1 : 0;
|
||||
} else if (Z_TYPE_P(op1) == IS_TRUE) {
|
||||
return zval_is_true(op2) ? 0 : 1;
|
||||
return zend_is_true(op2) ? 0 : 1;
|
||||
} else if (Z_TYPE_P(op2) < IS_TRUE) {
|
||||
return zval_is_true(op1) ? 1 : 0;
|
||||
return zend_is_true(op1) ? 1 : 0;
|
||||
} else if (Z_TYPE_P(op2) == IS_TRUE) {
|
||||
return zval_is_true(op1) ? 0 : -1;
|
||||
return zend_is_true(op1) ? 0 : -1;
|
||||
} else {
|
||||
op1 = _zendi_convert_scalar_to_number_silent(op1, &op1_copy);
|
||||
op2 = _zendi_convert_scalar_to_number_silent(op2, &op2_copy);
|
||||
|
||||
@@ -404,9 +404,6 @@ static zend_always_inline bool try_convert_to_string(zval *op) {
|
||||
ZEND_API bool ZEND_FASTCALL zend_is_true(const zval *op);
|
||||
ZEND_API bool ZEND_FASTCALL zend_object_is_true(const zval *op);
|
||||
|
||||
#define zval_is_true(op) \
|
||||
zend_is_true(op)
|
||||
|
||||
static zend_always_inline bool i_zend_is_true(const zval *op)
|
||||
{
|
||||
bool result = 0;
|
||||
|
||||
@@ -316,7 +316,7 @@ static int mysqli_object_has_property(zend_object *object, zend_string *name, in
|
||||
zval rv;
|
||||
zval *value = mysqli_read_property(object, name, BP_VAR_IS, cache_slot, &rv);
|
||||
if (value != &EG(uninitialized_zval)) {
|
||||
has_property = zval_is_true(value);
|
||||
has_property = zend_is_true(value);
|
||||
zval_ptr_dtor(value);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -805,7 +805,7 @@ PDO_API bool pdo_get_bool_param(bool *bval, const zval *value)
|
||||
*bval = false;
|
||||
return true;
|
||||
case IS_LONG:
|
||||
*bval = zval_is_true(value);
|
||||
*bval = zend_is_true(value);
|
||||
return true;
|
||||
case IS_STRING: /* TODO Should string be allowed? */
|
||||
default:
|
||||
|
||||
@@ -803,7 +803,7 @@ static int odbc_stmt_set_param(pdo_stmt_t *stmt, zend_long attr, zval *val)
|
||||
return 0;
|
||||
|
||||
case PDO_ODBC_ATTR_ASSUME_UTF8:
|
||||
S->assume_utf8 = zval_is_true(val);
|
||||
S->assume_utf8 = zend_is_true(val);
|
||||
return 0;
|
||||
default:
|
||||
strcpy(S->einfo.last_err_msg, "Unknown Attribute");
|
||||
|
||||
@@ -4967,7 +4967,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
||||
break; /* break out for() */
|
||||
}
|
||||
|
||||
if (zval_is_true(is_enum)) {
|
||||
if (zend_is_true(is_enum)) {
|
||||
/* enums need to be treated like strings */
|
||||
data_type = PG_TEXT;
|
||||
} else {
|
||||
|
||||
@@ -1858,15 +1858,15 @@ PHP_FUNCTION(session_set_cookie_params)
|
||||
domain = zval_get_string(value);
|
||||
found++;
|
||||
} else if (zend_string_equals_literal_ci(key, "secure")) {
|
||||
secure = zval_is_true(value);
|
||||
secure = zend_is_true(value);
|
||||
secure_null = 0;
|
||||
found++;
|
||||
} else if (zend_string_equals_literal_ci(key, "partitioned")) {
|
||||
partitioned = zval_is_true(value);
|
||||
partitioned = zend_is_true(value);
|
||||
partitioned_null = 0;
|
||||
found++;
|
||||
} else if (zend_string_equals_literal_ci(key, "httponly")) {
|
||||
httponly = zval_is_true(value);
|
||||
httponly = zend_is_true(value);
|
||||
httponly_null = 0;
|
||||
found++;
|
||||
} else if (zend_string_equals_literal_ci(key, "samesite")) {
|
||||
|
||||
@@ -293,7 +293,7 @@ int php_do_setsockopt_ip_mcast(php_socket *php_sock,
|
||||
goto dosockopt;
|
||||
|
||||
case IP_MULTICAST_LOOP:
|
||||
ipv4_mcast_ttl_lback = (unsigned char) zval_is_true(arg4);
|
||||
ipv4_mcast_ttl_lback = (unsigned char) zend_is_true(arg4);
|
||||
goto ipv4_loop_ttl;
|
||||
|
||||
case IP_MULTICAST_TTL:
|
||||
@@ -357,7 +357,7 @@ int php_do_setsockopt_ipv6_mcast(php_socket *php_sock,
|
||||
goto dosockopt;
|
||||
|
||||
case IPV6_MULTICAST_LOOP:
|
||||
ov = (int) zval_is_true(arg4);
|
||||
ov = (int) zend_is_true(arg4);
|
||||
goto ipv6_loop_hops;
|
||||
case IPV6_MULTICAST_HOPS:
|
||||
convert_to_long(arg4);
|
||||
|
||||
@@ -213,13 +213,13 @@ static zend_result php_head_parse_cookie_options_array(HashTable *options, zend_
|
||||
} else if (zend_string_equals_literal_ci(key, "domain")) {
|
||||
*domain = zval_get_string(value);
|
||||
} else if (zend_string_equals_literal_ci(key, "secure")) {
|
||||
*secure = zval_is_true(value);
|
||||
*secure = zend_is_true(value);
|
||||
} else if (zend_string_equals_literal_ci(key, "httponly")) {
|
||||
*httponly = zval_is_true(value);
|
||||
*httponly = zend_is_true(value);
|
||||
} else if (zend_string_equals_literal_ci(key, "samesite")) {
|
||||
*samesite = zval_get_string(value);
|
||||
} else if (zend_string_equals_literal_ci(key, "partitioned")) {
|
||||
*partitioned = zval_is_true(value);
|
||||
*partitioned = zend_is_true(value);
|
||||
} else {
|
||||
zend_value_error("%s(): option \"%s\" is invalid", get_active_function_name(), ZSTR_VAL(key));
|
||||
return FAILURE;
|
||||
|
||||
@@ -276,7 +276,7 @@ static zend_string *php_stream_http_response_headers_parse(php_stream_wrapper *w
|
||||
if (!strncasecmp(last_header_line, "Location:", sizeof("Location:")-1)) {
|
||||
/* Check if the location should be followed. */
|
||||
if (context && (tmpzval = php_stream_context_get_option(context, "http", "follow_location")) != NULL) {
|
||||
header_info->follow_location = zval_is_true(tmpzval);
|
||||
header_info->follow_location = zend_is_true(tmpzval);
|
||||
} else if (!((response_code >= 300 && response_code < 304)
|
||||
|| 307 == response_code || 308 == response_code)) {
|
||||
/* The redirection should not be automatic if follow_location is not set and
|
||||
|
||||
@@ -346,7 +346,7 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char *
|
||||
zval_ptr_dtor(&args[3]);
|
||||
goto end;
|
||||
}
|
||||
if (zval_is_true(&zretval)) {
|
||||
if (zend_is_true(&zretval)) {
|
||||
/* the stream is now open! */
|
||||
stream = php_stream_alloc_rel(&php_stream_userspace_ops, us, 0, mode);
|
||||
|
||||
@@ -430,7 +430,7 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (zval_is_true(&zretval)) {
|
||||
if (zend_is_true(&zretval)) {
|
||||
/* the stream is now open! */
|
||||
stream = php_stream_alloc_rel(&php_stream_userspace_dir_ops, us, 0, mode);
|
||||
|
||||
@@ -672,7 +672,7 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (zval_is_true(&retval)) {
|
||||
if (zend_is_true(&retval)) {
|
||||
stream->eof = 1;
|
||||
}
|
||||
zval_ptr_dtor(&retval);
|
||||
@@ -720,7 +720,7 @@ static int php_userstreamop_flush(php_stream *stream)
|
||||
zend_result call_result = zend_call_method_if_exists(Z_OBJ(us->object), func_name, &retval, 0, NULL);
|
||||
zend_string_release_ex(func_name, false);
|
||||
|
||||
int ret = call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zval_is_true(&retval) ? 0 : -1;
|
||||
int ret = call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zend_is_true(&retval) ? 0 : -1;
|
||||
|
||||
zval_ptr_dtor(&retval);
|
||||
|
||||
@@ -755,7 +755,7 @@ static int php_userstreamop_seek(php_stream *stream, zend_off_t offset, int when
|
||||
|
||||
ret = -1;
|
||||
goto out;
|
||||
} else if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zval_is_true(&retval)) {
|
||||
} else if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zend_is_true(&retval)) {
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = -1;
|
||||
@@ -1090,7 +1090,7 @@ static int user_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int
|
||||
} else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) {
|
||||
ret = Z_TYPE(zretval) == IS_TRUE;
|
||||
}
|
||||
// TODO: Warn on invalid return type, or use zval_is_true()?
|
||||
// TODO: Warn on invalid return type, or use zend_is_true()?
|
||||
|
||||
zval_ptr_dtor(&zretval);
|
||||
|
||||
@@ -1128,7 +1128,7 @@ static int user_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
|
||||
} else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) {
|
||||
ret = Z_TYPE(zretval) == IS_TRUE;
|
||||
}
|
||||
// TODO: Warn on invalid return type, or use zval_is_true()?
|
||||
// TODO: Warn on invalid return type, or use zend_is_true()?
|
||||
|
||||
zval_ptr_dtor(&zretval);
|
||||
|
||||
@@ -1166,7 +1166,7 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url, int
|
||||
} else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) {
|
||||
ret = Z_TYPE(zretval) == IS_TRUE;
|
||||
}
|
||||
// TODO: Warn on invalid return type, or use zval_is_true()?
|
||||
// TODO: Warn on invalid return type, or use zend_is_true()?
|
||||
|
||||
zval_ptr_dtor(&zretval);
|
||||
|
||||
@@ -1203,7 +1203,7 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url,
|
||||
} else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) {
|
||||
ret = Z_TYPE(zretval) == IS_TRUE;
|
||||
}
|
||||
// TODO: Warn on invalid return type, or use zval_is_true()?
|
||||
// TODO: Warn on invalid return type, or use zend_is_true()?
|
||||
|
||||
zval_ptr_dtor(&zretval);
|
||||
|
||||
@@ -1265,7 +1265,7 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i
|
||||
} else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) {
|
||||
ret = Z_TYPE(zretval) == IS_TRUE;
|
||||
}
|
||||
// TODO: Warn on invalid return type, or use zval_is_true()?
|
||||
// TODO: Warn on invalid return type, or use zend_is_true()?
|
||||
|
||||
zval_ptr_dtor(&zretval);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user