Category
stdlib | implementation-ready (partial — see status)
Status (2026-06-06 audit)
| Method |
VM |
Notes |
getPrevious() |
green |
lib/VM/Builtin/ExceptionGetPrevious.php — three-arg ctor chain works |
getTrace() |
missing |
tracked in #7159 |
getTraceAsString() |
missing |
tracked in #7159 |
__toString() |
missing |
echo $e fatals — #7159 |
Keep this issue for constructor $previous wiring + regression tests; implement remaining Throwable surface in #7159.
Problem
Exception / Throwable instances need full Zend exception chain semantics. getPrevious() now works, but trace accessors and string casting remain broken, blocking real error handlers and echo $exception formatting.
php-src reference
- php/php-src
Zend/zend_exceptions.c — zend_exception_get_previous(), zend_exception_get_trace(), zend_std_cast_object_tostring
- Constructor
$previous argument wiring in zend_exception_ctor()
Repro — getPrevious (green)
test/repro-maintainer/exception_get_previous.php:
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/exception_get_previous.php
php bin/vm.php test/repro-maintainer/exception_get_previous.php'
| Check |
Zend |
VM |
getPrevious() instanceof Exception |
true |
true |
getPrevious()->getMessage() |
'inner' |
'inner' |
Repro — remaining gaps (see #7159)
<?php
$e = new Exception('outer', 0, new Exception('inner'));
echo $e, "\n"; // Zend: chained text; VM: fatal
Scope
| Path |
Work |
lib/VM/Builtin/ExceptionGetPrevious.php |
done |
lib/VM/Builtin/ExceptionConstruct.php |
ensure 3rd $previous stored on all Throwable types |
lib/Compiler.php |
pass previous into throw / new Exception with 3rd arg |
| #7159 |
getTrace, getTraceAsString, __toString |
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./vendor/bin/phpunit --filter exception_get_previous'
Links
Category
stdlib| implementation-ready (partial — see status)Status (2026-06-06 audit)
getPrevious()lib/VM/Builtin/ExceptionGetPrevious.php— three-arg ctor chain worksgetTrace()getTraceAsString()__toString()echo $efatals — #7159Keep this issue for constructor
$previouswiring + regression tests; implement remaining Throwable surface in #7159.Problem
Exception/Throwableinstances need full Zend exception chain semantics.getPrevious()now works, but trace accessors and string casting remain broken, blocking real error handlers andecho $exceptionformatting.php-src reference
Zend/zend_exceptions.c—zend_exception_get_previous(),zend_exception_get_trace(),zend_std_cast_object_tostring$previousargument wiring inzend_exception_ctor()Repro — getPrevious (green)
test/repro-maintainer/exception_get_previous.php:getPrevious() instanceof ExceptiontruetruegetPrevious()->getMessage()'inner''inner'Repro — remaining gaps (see #7159)
Scope
lib/VM/Builtin/ExceptionGetPrevious.phplib/VM/Builtin/ExceptionConstruct.php$previousstored on all Throwable typeslib/Compiler.phpthrow/new Exceptionwith 3rd arggetTrace,getTraceAsString,__toStringDone when
new Exception($msg, $code, $previous)preserves chaingetPrevious()returnsnullor previousThrowable__toStringparitytest/compliance/cases/stdlib/exception_previous_chain.phptVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./vendor/bin/phpunit --filter exception_get_previous'Links
__toString)