[php-src] master: Zend: merge reserved_class_name and builtin_type_info structs

From: Date: Wed, 14 Oct 2026 21:48:51 +0000
Subject: [php-src] master: Zend: merge reserved_class_name and builtin_type_info structs
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142294@lists.php.net to get a copy of this message
Author: Gina Peter Banyard (Girgias) Date: 2026-10-14T22:48:35+01:00 Commit: https://github.com/php/php-src/commit/02f9b9635639af9f1e5cb5fa839a39ab6fa39c7e Raw diff: https://github.com/php/php-src/commit/02f9b9635639af9f1e5cb5fa839a39ab6fa39c7e.diff Zend: merge reserved_class_name and builtin_type_info structs As it's easy to forget to add it to one or the other Closes GH-23776 Changed paths: M Zend/zend_compile.c Diff: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index e4df321fb5e1..2633e7d536d3 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -199,44 +199,46 @@ static bool zend_get_unqualified_name(const zend_string *name, const char **resu } /* }}} */ -struct reserved_class_name { - const char *name; - size_t len; -}; -static const struct reserved_class_name reserved_class_names[] = { - {ZEND_STRL("bool")}, - {ZEND_STRL("false")}, - {ZEND_STRL("float")}, - {ZEND_STRL("int")}, - {ZEND_STRL("null")}, - {ZEND_STRL("parent")}, - {ZEND_STRL("self")}, - {ZEND_STRL("static")}, - {ZEND_STRL("string")}, - {ZEND_STRL("true")}, - {ZEND_STRL("void")}, - {ZEND_STRL("never")}, - {ZEND_STRL("iterable")}, - {ZEND_STRL("object")}, - {ZEND_STRL("mixed")}, - /* These are not usable as class names because they're proper tokens, - * but they are here for class aliases. */ - {ZEND_STRL("array")}, - {ZEND_STRL("callable")}, - {NULL, 0} +typedef struct builtin_type_info { + const char* name; + const size_t name_len; + const uint8_t type; +} builtin_type_info; + +static const builtin_type_info builtin_types[] = { + {ZEND_STRL("null"), IS_NULL}, + {ZEND_STRL("true"), IS_TRUE}, + {ZEND_STRL("false"), IS_FALSE}, + {ZEND_STRL("int"), IS_LONG}, + {ZEND_STRL("float"), IS_DOUBLE}, + {ZEND_STRL("string"), IS_STRING}, + {ZEND_STRL("bool"), _IS_BOOL}, + {ZEND_STRL("void"), IS_VOID}, + {ZEND_STRL("never"), IS_NEVER}, + {ZEND_STRL("iterable"), IS_ITERABLE}, + {ZEND_STRL("object"), IS_OBJECT}, + {ZEND_STRL("mixed"), IS_MIXED}, + /* Should be handled as ZEND_TYPE_ASTs but it may have a namespace component */ + {ZEND_STRL("array"), IS_ARRAY}, + {ZEND_STRL("callable"), IS_CALLABLE}, + {ZEND_STRL("static"), IS_STATIC}, + /* self and parent are effectively built-in types (and thus reserved), but they allow namespace components */ + {ZEND_STRL("self"), IS_UNDEF}, + {ZEND_STRL("parent"), IS_UNDEF}, + {NULL, 0, IS_UNDEF} }; static bool zend_is_reserved_class_name(const zend_string *name) /* {{{ */ { - const struct reserved_class_name *reserved = reserved_class_names; + const builtin_type_info *reserved = builtin_types; const char *uqname = ZSTR_VAL(name); size_t uqname_len = ZSTR_LEN(name); zend_get_unqualified_name(name, &uqname, &uqname_len); for (; reserved->name; ++reserved) { - if (uqname_len == reserved->len - && zend_binary_strcasecmp(uqname, uqname_len, reserved->name, reserved->len) == 0 + if (uqname_len == reserved->name_len + && zend_binary_strcasecmp(uqname, uqname_len, reserved->name, reserved->name_len) == 0 ) { return true; } @@ -262,32 +264,6 @@ void zend_assert_valid_class_name(const zend_string *name, const char *type) /* } /* }}} */ -typedef struct _builtin_type_info { - const char* name; - const size_t name_len; - const uint8_t type; -} builtin_type_info; - -static const builtin_type_info builtin_types[] = { - {ZEND_STRL("null"), IS_NULL}, - {ZEND_STRL("true"), IS_TRUE}, - {ZEND_STRL("false"), IS_FALSE}, - {ZEND_STRL("int"), IS_LONG}, - {ZEND_STRL("float"), IS_DOUBLE}, - {ZEND_STRL("string"), IS_STRING}, - {ZEND_STRL("bool"), _IS_BOOL}, - {ZEND_STRL("void"), IS_VOID}, - {ZEND_STRL("never"), IS_NEVER}, - {ZEND_STRL("iterable"), IS_ITERABLE}, - {ZEND_STRL("object"), IS_OBJECT}, - {ZEND_STRL("mixed"), IS_MIXED}, - /* Should be handled as ZEND_TYPE_ASTs but it may have a namespace component */ - {ZEND_STRL("array"), IS_ARRAY}, - {ZEND_STRL("callable"), IS_CALLABLE}, - {ZEND_STRL("static"), IS_STATIC}, - {NULL, 0, IS_UNDEF} -}; - typedef struct { const char *name; size_t name_len;

« previous php.cvs (#142294) next »