[php-src] Issue #22658: `ReflectionConstant::__toString()` with a string value with null bytes truncates output

[email protected] (DanielEScherzer) Thu, 9 Jul 2026 18:33:12 +0000
Newsgroups php.bugs
Message-ID <[email protected]>
Issue: https://github.com/php/php-src/issues/22658
Author: DanielEScherzer

### Description

The following code:

```php
<?php

define('DEMO', "f\0oo");
$r = new ReflectionConstant('DEMO');
echo $r;
var_dump( $r->getValue() );
```

Resulted in this output:
```
Constant [ string DEMO ] { f }
string(4) "foo"
```

But I expected this output instead (with a null byte in the first "foo" the same way that there is in the second)
```
Constant [ string DEMO ] { foo }
string(4) "foo"
```

https://3v4l.org/Au101#v


### PHP Version

```plain
8.4+
```

### Operating System

_No response_