Summary
get_object_vars() and get_mangled_object_vars() on an object with a declared but uninitialized public property must include that key mapped to NULL, matching Zend. VM returns an empty array (property dropped).
get_class_vars() already returns ['x' => NULL] correctly — only instance export helpers are wrong.
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_get_object_vars_uninitialized.php
php bin/vm.php test/repro/maintainer_gap_get_object_vars_uninitialized.php'
| Call |
Zend PHP 8.2 |
VM today |
get_object_vars(new C) where public $x; |
array('x' => NULL) |
array() ❌ |
get_mangled_object_vars(new C) |
array('x' => NULL) |
array() ❌ |
php-src reference
Implementation (PHP-in-PHP)
ext/standard/get_object_vars.php / VmVar.php (or shared property enumerator): walk declared default properties and include public keys even when slot is unset
- Mirror for
get_mangled_object_vars() mangled-name export
- No new C runtime — reuse existing property metadata from compile/runtime object layout
Done when (php-src-strict)
Verification
./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_get_object_vars_uninitialized.php
Related: #9419 (get_object_vars TypeError regression), #5203 (property hooks), #1492
Summary
get_object_vars()andget_mangled_object_vars()on an object with a declared but uninitialized public property must include that key mapped toNULL, matching Zend. VM returns an empty array (property dropped).get_class_vars()already returns['x' => NULL]correctly — only instance export helpers are wrong.Repro
get_object_vars(new C)wherepublic $x;array('x' => NULL)array()❌get_mangled_object_vars(new C)array('x' => NULL)array()❌php-src reference
ext/standard/var.c—add_property_info, default property table includes declared properties with unset valuesImplementation (PHP-in-PHP)
ext/standard/get_object_vars.php/VmVar.php(or shared property enumerator): walk declared default properties and include public keys even when slot is unsetget_mangled_object_vars()mangled-name exportDone when (php-src-strict)
array('x' => NULL)for both functions on VMtest/compliance/cases/stdlib/Verification
Related: #9419 (
get_object_varsTypeError regression), #5203 (property hooks), #1492