Repository navigation
Closed
Labels
area:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsPhase 4 – stdlib for web apps
Description
Category
stdlib
Problem
var_export() is registered in VM/JIT/AOT but only exports bool and null. Arrays, strings, integers, floats, and objects fatal with LogicException — blocking debug output, return=true capture, and __set_state round-trip used by cache serializers.
Verified May 2026 (Docker php-compiler:22.04-dev):
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "var_export([1,2]);"'
# LogicException: var_export() does not support this value type in this compiler build
# ext/standard/var_export.php:87php-src reference
- php/php-src
ext/standard/var.c—php_var_export(),php_var_export_ex() php_var_export()object branch — calls__set_statewhen class defines it
Repro
Arrays and scalars
<?php
var_export([1, 2]);
echo "\n";
var_export(42);Zend: array (0 => 1, 1 => 2) and 42
VM: fatal on first line
Objects with __set_state
<?php
class C {
public int $x = 1;
public static function __set_state(array $a): self {
$o = new self();
$o->x = $a['x'];
return $o;
}
}
echo var_export(C::class, true);Zend: 'C::__set_state(array(...))'
VM: LogicException: var_export() does not support this value type
return=true
<?php
$s = var_export(['a' => 1], true);
echo $s;Zend: returns export string without echoing
VM: fatal before return
Scope (this repo)
| Module | Path |
|---|---|
| VM | ext/standard/var_export.php — port recursive export (arrays, scalars, objects) |
| Helper | new ext/standard/VmVarExport.php mirroring Zend php_var_export |
| JIT/AOT | extend exportJit() beyond bool/null |
| Tests | test/compliance/cases/stdlib/var_export*.phpt + AOT fixture |
Do not use permanent internal_* shims.
Done when
- Array/scalar repro matches Zend output on VM
-
var_export($x, true)returns string without echo - Objects with
__set_stateexport callable form; without it export(object) array(...)like Zend - Circular reference guard throws/recurses like Zend (document subset if deferred)
-
./script/ci-fast.sh --filter var_exportgreen -
php script/capability-matrix.phpnotes full export
Related
- Stdlib: print_r() and register var_dump() — debug output (ext/standard parity) #3133 —
print_r()/var_dump()registration - Stdlib: var_export() — arrays, scalars, and objects (ext/standard/var.c parity) #3594 — this issue
Metadata
Metadata
Assignees
Labels
area:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsPhase 4 – stdlib for web apps
Activity
PurHur commentedon Jun 14, 2026
claim: PHP Compiler STD Lib — starting this run (var_export object private/protected property export parity, ZEND_PROP_PURPOSE_VAR_EXPORT)
Fix var_export() to export all set object properties regardless of sc…
PurHur commentedon Jun 14, 2026
Merged via #8572.
Fix: var_export() object branch now uses ZEND_PROP_PURPOSE_VAR_EXPORT semantics (collectVarExportPropertiesForBuiltin) instead of get_object_vars() visibility filtering.
Verification:
PHPUnit: OK (4 tests, 4 assertions). VM/JIT output matches Zend for private/protected/public properties.
Umbrella may stay open for JIT object LLVM lowering (__compiler_var_export still NULL for objects) and other var_export gaps.