Commit 7c55b0d2906 for php.net
commit 7c55b0d2906e14889b3fa8038e002dee5970a59d
Merge: a184a512507 4a8028ce4f0
Author: Ilia Alshanetsky <ilia@ilia.ws>
Date: Fri Jul 31 12:02:52 2026 -0400
Merge branch 'PHP-8.5'
* PHP-8.5:
Parse qualified reflection names with a length-aware search
Master already carries the const declarations the backport introduces, so
the resolution keeps them and takes only the two zend_memnstr() calls.
diff --cc ext/reflection/php_reflection.c
index 42ab6dcd8ae,13723ed5173..2bd8018ab6a
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@@ -3198,9 -3362,10 +3198,9 @@@ static void instantiate_reflection_meth
method_name_len = ZSTR_LEN(arg2_str);
} else {
const char *tmp;
- size_t tmp_len;
const char *name = ZSTR_VAL(arg1_str);
- if ((tmp = strstr(name, "::")) == NULL) {
+ if ((tmp = zend_memnstr(name, "::", 2, name + ZSTR_LEN(arg1_str))) == NULL) {
zend_argument_error(reflection_exception_ptr, 1, "must be a valid method name");
RETURN_THROWS();
}
@@@ -4564,15 -4705,14 +4564,15 @@@ ZEND_METHOD(ReflectionClass, getPropert
return;
}
}
- str_name = ZSTR_VAL(name);
+ const char *str_name = ZSTR_VAL(name);
+ const char *tmp;
- if ((tmp = strstr(ZSTR_VAL(name), "::")) != NULL) {
+ if ((tmp = zend_memnstr(ZSTR_VAL(name), "::", 2, ZSTR_VAL(name) + ZSTR_LEN(name))) != NULL) {
- classname_len = tmp - ZSTR_VAL(name);
- classname = zend_string_init(ZSTR_VAL(name), classname_len, 0);
- str_name_len = ZSTR_LEN(name) - (classname_len + 2);
+ size_t classname_len = tmp - ZSTR_VAL(name);
+ zend_string *classname = zend_string_init(ZSTR_VAL(name), classname_len, false);
+ size_t str_name_len = ZSTR_LEN(name) - (classname_len + 2);
str_name = tmp + 2;
- ce2 = zend_lookup_class(classname);
+ zend_class_entry *ce2 = zend_lookup_class(classname);
if (!ce2) {
if (!EG(exception)) {
zend_throw_exception_ex(reflection_exception_ptr, -1, "Class \"%s\" does not exist", ZSTR_VAL(classname));