Summary
json_decode() must reject backed enum case operands with TypeError under php-src-strict. VM currently coerces enum cases to backing scalars and decodes JSON from the backing string.
php-src reference: ext/json/php_json.c — php_json_decode() validates $json as string before parsing; enum cases are objects, not strings.
PHP implementation target: ext/json/ VM builtin + VmString::coerceStringBuiltinArg / JitStringBuiltinArg guard on the json operand (no new C runtime).
Repro
test/repro/maintainer_json_decode_enum.php:
php bin/vm.php test/repro/maintainer_json_decode_enum.php
# VM today: int(1) from backing string '{"x":1}'
php test/repro/maintainer_json_decode_enum.php
# Zend: TypeError
Observed (2026-06-15):
- Zend:
TypeError: json_decode(): Argument #1 ($json) must be of type string, E given
- VM:
int(1) — decodes backing scalar
Done when (php-src-strict)
Related
Summary
json_decode()must reject backed enum case operands with TypeError under php-src-strict. VM currently coerces enum cases to backing scalars and decodes JSON from the backing string.php-src reference: ext/json/php_json.c —
php_json_decode()validates$jsonas string before parsing; enum cases are objects, not strings.PHP implementation target:
ext/json/VM builtin +VmString::coerceStringBuiltinArg/JitStringBuiltinArgguard on the json operand (no new C runtime).Repro
test/repro/maintainer_json_decode_enum.php:Observed (2026-06-15):
TypeError: json_decode(): Argument #1 ($json) must be of type string, E givenint(1)— decodes backing scalarDone when (php-src-strict)
json_decode()throwsTypeErrorfor enum case$jsonoperand (VM; JIT/AOT if lowered)test/repro/ortest/compliance/json_validateonly)Related