[GIT-PULLS] [php-src] PR #22971: Avoid truncation on null bytes in class and function names

[email protected] (iliaal) Fri, 31 Jul 2026 13:27:00 +0000
Newsgroups php.git-pulls
Message-ID <[email protected]>
Pull Request: https://github.com/php/php-src/pull/22971
Author: iliaal

Follow-up to GH-22681. `_class_string()` and `_function_string()` still format the class name and the function name with %s, so Reflection*::__toString() cuts both at the first NUL byte. Anonymous class names embed one, directly and also inside the generated name of a closure declared in such a class.

```php
$obj = new class {
    public function make(): Closure { return function () {}; }
};
echo new ReflectionFunction($obj->make());
// Closure [ <user> public method {closure:class@anonymous ] {
```

master already appends the class name as a zend_string, so only the function name changes once this is merged up.