[php-src] master: ext/standard: Simplify type alias handling in settype() (#24348)
| From: | Weilin Du via GitHub | Date: | Thu, 15 Oct 2026 16:21:47 +0000 |
| Subject: | [php-src] master: ext/standard: Simplify type alias handling in settype() (#24348) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142316@lists.php.net to get a copy of this message | ||
Author: Weilin Du (LamentXU123)
Committer: GitHub (web-flow)
Pusher: LamentXU123
Date: 2026-10-16T00:21:43+08:00
Commit: https://github.com/php/php-src/commit/3efeb2afedd673ee3dc05a650e64bd4ef926af72
Raw diff: https://github.com/php/php-src/commit/3efeb2afedd673ee3dc05a650e64bd4ef926af72.diff
ext/standard: Simplify type alias handling in settype() (#24348)
Changed paths:
M ext/standard/type.c
Diff:
diff --git a/ext/standard/type.c b/ext/standard/type.c
index dc99dac93dac..2755f08d88da 100644
--- a/ext/standard/type.c
+++ b/ext/standard/type.c
@@ -98,13 +98,11 @@ PHP_FUNCTION(settype)
} else {
ptr = Z_REFVAL_P(var);
}
- if (zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_INTEGER))) {
+ if (zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_INTEGER))
+ || zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_INT))) {
convert_to_long(ptr);
- } else if (zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_INT))) {
- convert_to_long(ptr);
- } else if (zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_FLOAT))) {
- convert_to_double(ptr);
- } else if (zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_DOUBLE))) {
+ } else if (zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_FLOAT))
+ || zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_DOUBLE))) {
convert_to_double(ptr);
} else if (zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_STRING))) {
convert_to_string(ptr);
@@ -112,9 +110,8 @@ PHP_FUNCTION(settype)
convert_to_array(ptr);
} else if (zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_OBJECT))) {
convert_to_object(ptr);
- } else if (zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_BOOL))) {
- convert_to_boolean(ptr);
- } else if (zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_BOOLEAN))) {
+ } else if (zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_BOOL))
+ || zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_BOOLEAN))) {
convert_to_boolean(ptr);
} else if (zend_string_equals_ci(type, ZSTR_KNOWN(ZEND_STR_NULL_LOWERCASE))) {
convert_to_null(ptr);