Commit 1b2c0abbdb3 for php.net

commit 1b2c0abbdb333cbe350aff69904f3312c55c18f1
Author: Daniel Scherzer <daniel.e.scherzer@gmail.com>
Date:   Mon Jul 13 14:34:10 2026 -0700

    GH-22681: avoid truncation on null bytes in `ReflectionEnum::__toString()`

diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index a3e996b654c..bf7fde62d49 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -677,7 +677,9 @@ static void _enum_case_string(smart_str *str, const zend_string *name, zend_clas
 	}

 	if (c->doc_comment) {
-		smart_str_append_printf(str, "%s%s\n", indent, ZSTR_VAL(c->doc_comment));
+		smart_str_appends(str, indent);
+		smart_str_append(str, c->doc_comment);
+		smart_str_appendc(str, '\n');
 	}
 	smart_str_append_printf(str, "%sCase %s", indent, ZSTR_VAL(name));
 	if (c->ce->enum_backing_type == IS_UNDEF) {
@@ -691,7 +693,9 @@ static void _enum_case_string(smart_str *str, const zend_string *name, zend_clas
 		zval *enum_val = zend_enum_fetch_case_value(Z_OBJ(c->value));
 		zend_string *tmp_value_str;
 		zend_string *value_str = zval_get_tmp_string(enum_val, &tmp_value_str);
-		smart_str_append_printf(str, " = %s\n", ZSTR_VAL(value_str));
+		smart_str_appends(str, " = ");
+		smart_str_append(str, value_str);
+		smart_str_appendc(str, '\n');
 		zend_tmp_string_release(tmp_value_str);
 	}
 }
diff --git a/ext/reflection/tests/gh22681/ReflectionEnum_backed_value.phpt b/ext/reflection/tests/gh22681/ReflectionEnum_backed_value.phpt
index 8131a3adafe..f28c39daa10 100644
--- a/ext/reflection/tests/gh22681/ReflectionEnum_backed_value.phpt
+++ b/ext/reflection/tests/gh22681/ReflectionEnum_backed_value.phpt
@@ -16,7 +16,7 @@ enum Demo: string {
   @@ %s %d-%d

   - Enum cases [1] {
-    Case DEMO = F
+    Case DEMO = F%0oo
   }

   - Constants [0] {
diff --git a/ext/reflection/tests/gh22681/ReflectionEnum_case_doc_comment.phpt b/ext/reflection/tests/gh22681/ReflectionEnum_case_doc_comment.phpt
index 68bde0bed63..3945ad8639e 100644
--- a/ext/reflection/tests/gh22681/ReflectionEnum_case_doc_comment.phpt
+++ b/ext/reflection/tests/gh22681/ReflectionEnum_case_doc_comment.phpt
@@ -20,7 +20,7 @@ enum Demo {
   @@ %s(%d) : eval()'d code %d-%d

   - Enum cases [1] {
-    /** F
+    /** F%0oo */
     Case C
   }