Category
stdlib
Problem
unpack() (and enum operands passed into pack() for the data buffer) do not match Zend when a backed enum case is used where an int/string scalar is expected. Zend emits a Warning: Object of class E could not be converted to int and proceeds using the backing value. This compiler fatals via VmJson::export / unsupported value type (verified 2026-06-05).
Related: #5713 tracks pack() enum behavior; this issue covers unpack() and the full pack/unpack pipeline.
php-src reference
Repro (verified 2026-06-05)
<?php
enum E: int { case A = 1; }
$data = pack('c', E::A);
var_dump(unpack('c', $data));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro.php
php bin/vm.php repro.php
'
| Step |
Zend PHP 8.2 |
bin/vm.php (today) |
pack('c', E::A) |
Warning + packs byte 0x01 |
Warning path differs; may fatal ❌ |
unpack('c', $data) |
array(1 => int(1)) |
VM fatal: json_encode() value type not supported ❌ |
Direct enum into unpack format args should also TypeError per Z_PARAM_STR on format string — test separately.
Scope (PHP-in-PHP)
| Path |
Change |
ext/standard/unpack.php, ext/standard/pack.php |
scalar coercion via VmPack / UnpackEngine — enum case → backing with Zend warning |
ext/standard/VmPack.php, UnpackEngine.php |
never route enum cases through VmJson::export |
lib/JIT/Builtin/JitUnpack.php, JitPack.php |
mirror coercion when JIT lowered |
| Tests |
test/compliance/cases/stdlib/unpack_enum_case.phpt, extend pack_enum_case.phpt |
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter unpack_enum'
./script/ci-fast.sh --filter UnpackEnum
Links
Category
stdlibProblem
unpack()(and enum operands passed intopack()for the data buffer) do not match Zend when a backed enum case is used where an int/string scalar is expected. Zend emits aWarning: Object of class E could not be converted to intand proceeds using the backing value. This compiler fatals viaVmJson::export/ unsupported value type (verified 2026-06-05).Related: #5713 tracks
pack()enum behavior; this issue coversunpack()and the full pack/unpack pipeline.php-src reference
ext/standard/pack.c—php_pack,php_unpack, scalar coercion withzend_try_numeric/ object-to-scalar warningsRepro (verified 2026-06-05)
bin/vm.php(today)pack('c', E::A)0x01unpack('c', $data)array(1 => int(1))json_encode() value type not supported❌Direct enum into unpack format args should also
TypeErrorperZ_PARAM_STRon format string — test separately.Scope (PHP-in-PHP)
ext/standard/unpack.php,ext/standard/pack.phpVmPack/UnpackEngine— enum case → backing with Zend warningext/standard/VmPack.php,UnpackEngine.phpVmJson::exportlib/JIT/Builtin/JitUnpack.php,JitPack.phptest/compliance/cases/stdlib/unpack_enum_case.phpt, extendpack_enum_case.phptDone when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter unpack_enum' ./script/ci-fast.sh --filter UnpackEnumLinks