[php-src] Issue #25418: var_dump() and debug_zval_dump() print the full anonymous class name with a raw NUL byte

From: Date: Thu, 12 Nov 2026 12:22:38 +0000
Subject: [php-src] Issue #25418: var_dump() and debug_zval_dump() print the full anonymous class name with a raw NUL byte
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-254135@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/25418 Author: jorgsowa ### Description Since 5ed6625e4c0 (#23143, %pS migration of ext/standard), var_dump() and debug_zval_dump() print the internal name of an anonymous class, including the NUL byte and the defining file path. PHP 8.5 printed class@anonymous. The following code: ```php <?php $o = new class { public $a = 1; private $p; }; var_dump($o); print_r($o); ``` Resulted in this output (\0 is a raw NUL byte): ``` object(class@anonymous\0/in/test.php:2$0)#1 (2) { ["a"]=> int(1) ["p":"class@anonymous":private]=> NULL } class@anonymous Object ( [a] => 1 [p:class@anonymous:private] => ) ``` But I expected this output instead (as in PHP 8.5): ``` object(class@anonymous)#1 (2) { ["a"]=> int(1) ["p":"class@anonymous":private]=> NULL } class@anonymous Object ( [a] => 1 [p:class@anonymous:private] => ) ``` The commit changed php_printf("...object(%s)...", ZSTR_VAL(class_name)) to %pS, which prints the whole zend_string. The private property label (zend_unmangle_property_name() + %s) and print_r() still stop at the NUL, so the same dump now shows two different names for one class. The change is in 8.6.0RC6/RC7. The full name is a deliberate consequence of treating NUL truncation as a bug (#23142), but for dumpers it was not discussed: #23143 had no review, the change is not in NEWS or UPGRADING, and labels and print_r() were left truncated. For 8.6 I suggest restoring %s for the two object headers in ext/standard/var.c (8.5 output); printing the full name consistently in dumps could be discussed for master. @DanielEScherzer, what do you think? ### PHP Version ```plain PHP 8.6.0RC7 (PHP-8.6 and master also affected) ``` ### Operating System _No response_

« previous php.bugs (#254135) next »