Skip to content

Avoid truncation on null bytes in class and function names - #206

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/reflection-tostring-nul-names
Closed

Avoid truncation on null bytes in class and function names#206
iliaal wants to merge 1 commit into
PHP-8.4from
fix/reflection-tostring-nul-names

Conversation

@iliaal

@iliaal iliaal commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Follow-up to phpGH-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.

$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.

Follow-up to phpGH-22681. _class_string() and _function_string() still
formatted the class name and the function name with %s, so
Reflection*::__toString() cut them at the first NUL. Anonymous class
names embed one, both directly and inside the name of a closure declared
in such a class.

Closes phpGH-22971
@iliaal
iliaal force-pushed the fix/reflection-tostring-nul-names branch from 455a1a0 to ccf2ce7 Compare July 31, 2026 13:27
@iliaal

iliaal commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream as php#22971.

@iliaal iliaal closed this Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant