Commit fd7e1e21613 for php.net
commit fd7e1e21613dc3e6b49a1098b471d8a4f8f0d56b
Merge: c559d6f24c4 4804d17a135
Author: Daniel Scherzer <daniel.e.scherzer@gmail.com>
Date: Mon Jul 13 14:19:59 2026 -0700
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
NEWS
GH-22681: avoid truncation on null bytes in `Reflection*::__toString()`
Add regression tests for `Reflection*::__toString()` with null bytes
diff --cc NEWS
index 947f2fdedd9,e71a94ac12e..93a4cf331b6
--- a/NEWS
+++ b/NEWS
@@@ -88,8 -67,8 +88,10 @@@ PH
dynamic properties shadowing a private parent property). (iliaal)
. Fixed bug GH-22658 (ReflectionConstant::__toString() with a string value
with null bytes truncates output). (DanielEScherzer)
+ . Fixed bug GH-22683 (Reflection(Class)Constant::__toString() should not warn
+ on NAN conversions). (Khaled Alam)
+ . Fixed bug GH-22681 (Reflection*::__toString() truncates on null bytes).
+ (DanielEScherzer)
- Session:
. Fixed bug GH-21314 (Different session garbage collector behavior between
diff --cc ext/reflection/php_reflection.c
index bc176cca16b,0945c9574c6..a3e996b654c
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@@ -302,11 -301,17 +302,11 @@@ static zend_object *reflection_objects_
}
/* }}} */
- static void _const_string(smart_str *str, const char *name, zval *value, const char *indent);
-static zval *reflection_instantiate(zend_class_entry *pce, zval *object) /* {{{ */
-{
- object_init_ex(object, pce);
- return object;
-}
-/* }}} */
-
+ static void _const_string(smart_str *str, const zend_string *name, zval *value, const char *indent);
static void _function_string(smart_str *str, zend_function *fptr, zend_class_entry *scope, const char* indent);
- static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, const char* indent);
+ static void _property_string(smart_str *str, zend_property_info *prop, const zend_string *prop_name, const char* indent);
static void _class_const_string(smart_str *str, const zend_string *name, zend_class_constant *c, const char* indent);
+static void _enum_case_string(smart_str *str, const zend_string *name, zend_class_constant *c, const char* indent);
static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, const char *indent);
static void _extension_string(smart_str *str, const zend_module_entry *module, const char *indent);
static void _zend_extension_string(smart_str *str, const zend_extension *extension, const char *indent);
@@@ -5778,9 -5917,11 +5805,9 @@@ ZEND_METHOD(ReflectionProperty, __toStr
property_reference *ref;
smart_str str = {0};
- if (zend_parse_parameters_none() == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_NONE();
GET_REFLECTION_OBJECT_PTR(ref);
- _property_string(&str, ref->prop, ZSTR_VAL(ref->unmangled_name), "");
+ _property_string(&str, ref->prop, ref->unmangled_name, "");
RETURN_STR(smart_str_extract(&str));
}
/* }}} */
@@@ -7933,10 -7977,12 +7960,10 @@@ ZEND_METHOD(ReflectionConstant, __toStr
zend_constant *const_;
smart_str str = {0};
- if (zend_parse_parameters_none() == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_NONE();
GET_REFLECTION_OBJECT_PTR(const_);
- _const_string(&str, ZSTR_VAL(const_->name), &const_->value, "");
+ _const_string(&str, const_->name, &const_->value, "");
RETURN_STR(smart_str_extract(&str));
}
diff --cc ext/reflection/tests/gh22681/ReflectionEnum_case_doc_comment.phpt
index 00000000000,10afacade8f..68bde0bed63
mode 000000,100644..100644
--- a/ext/reflection/tests/gh22681/ReflectionEnum_case_doc_comment.phpt
+++ b/ext/reflection/tests/gh22681/ReflectionEnum_case_doc_comment.phpt
@@@ -1,0 -1,46 +1,49 @@@
+ --TEST--
+ GH-22681: null bytes in doc comment truncate ReflectionEnum::__toString()
+ --FILE--
+ <?php
+
+ eval(<<<END
+ enum Demo {
+ /** F\0oo */
+ case C;
+ }
+ END
+ );
+
+ $r = new ReflectionEnum(Demo::class);
+ echo $r;
+ var_dump( new ReflectionEnumUnitCase(Demo::class, 'C')->getDocComment() );
+ ?>
+ --EXPECTF--
-Class [ <user> final class Demo implements UnitEnum ] {
++Enum [ <user> enum Demo implements UnitEnum ] {
+ @@ %s(%d) : eval()'d code %d-%d
+
- - Constants [1] {
- /** F%0oo */
- Constant [ public Demo C ] { Object }
++ - Enum cases [1] {
++ /** F
++ Case C
++ }
++
++ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [1] {
+ Method [ <internal, prototype UnitEnum> static public method cases ] {
+
+ - Parameters [0] {
+ }
+ - Return [ array ]
+ }
+ }
+
+ - Properties [1] {
+ Property [ public protected(set) readonly string $name ]
+ }
+
+ - Methods [0] {
+ }
+ }
+ string(11) "/** F%0oo */"