[php-src] PHP-8.5: Add regression tests for `ReflectionConstant::__toString()` with null bytes

Daniel Scherzer <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Daniel Scherzer (DanielEScherzer)
Date: 2026-07-10T07:20:56-07:00

Commit: https://github.com/php/php-src/commit/5b00437a09de5bb0ae1631527d519e6ad9851a33
Raw diff: https://github.com/php/php-src/commit/5b00437a09de5bb0ae1631527d519e6ad9851a33.diff

Add regression tests for `ReflectionConstant::__toString()` with null bytes

So that when the output is fixed the change can be confirmed in tests

Changed paths:
  A  ext/reflection/tests/ReflectionConstant_null_byte_value.phpt


Diff:

diff --git a/ext/reflection/tests/ReflectionConstant_null_byte_value.phpt b/ext/reflection/tests/ReflectionConstant_null_byte_value.phpt
new file mode 100644
index 000000000000..5e1b855eed05
--- /dev/null
+++ b/ext/reflection/tests/ReflectionConstant_null_byte_value.phpt
@@ -0,0 +1,14 @@
+--TEST--
+GH-22658: ReflectionConstant with a string value with a null byte
+--FILE--
+<?php
+
+define('DEMO', "f\0oo");
+$r = new ReflectionConstant('DEMO');
+echo $r;
+var_dump( $r->getValue() );
+
+?>
+--EXPECTF--
+Constant [ string DEMO ] { f }
+string(4) "f%0oo"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.