From 1e7715ca4e4404bab07fab4f0c80922ea1331dfa Mon Sep 17 00:00:00 2001 From: PrinsFrank <25006490+PrinsFrank@users.noreply.github.com> Date: Sun, 24 May 2026 15:10:17 +0200 Subject: [PATCH 1/2] Add changelog and warning about updated exit code bahaviour since PHP 8.4.0 --- .../funchand/functions/register-shutdown-function.xml | 7 +++++++ reference/misc/functions/exit.xml | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/reference/funchand/functions/register-shutdown-function.xml b/reference/funchand/functions/register-shutdown-function.xml index b8befded201d..ae5fb4843e27 100644 --- a/reference/funchand/functions/register-shutdown-function.xml +++ b/reference/funchand/functions/register-shutdown-function.xml @@ -24,6 +24,13 @@ function, processing will stop completely and no other registered shutdown functions will be called. + + + Calling exit within a registered shutdown function + overwrites any exit code of previous exit calls + since PHP 8.4.0 + + Shutdown functions may also call register_shutdown_function themselves to add a shutdown function to the end of the queue. diff --git a/reference/misc/functions/exit.xml b/reference/misc/functions/exit.xml index 39ec19cd1f40..10d7c57fbd94 100644 --- a/reference/misc/functions/exit.xml +++ b/reference/misc/functions/exit.xml @@ -109,6 +109,15 @@ variable functions. + + 8.4.0 + + When calling exit within + Shutdown functions + or object destructors + any previous exit code gets overwritten + + From cee02b743aabcc9a8ba0062f35163cc3f8e5c236 Mon Sep 17 00:00:00 2001 From: PrinsFrank <25006490+PrinsFrank@users.noreply.github.com> Date: Mon, 25 May 2026 15:41:59 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Louis-Arnaud --- .../funchand/functions/register-shutdown-function.xml | 7 ++++--- reference/misc/functions/exit.xml | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/reference/funchand/functions/register-shutdown-function.xml b/reference/funchand/functions/register-shutdown-function.xml index ae5fb4843e27..dc799e3f005c 100644 --- a/reference/funchand/functions/register-shutdown-function.xml +++ b/reference/funchand/functions/register-shutdown-function.xml @@ -26,9 +26,10 @@ - Calling exit within a registered shutdown function - overwrites any exit code of previous exit calls - since PHP 8.4.0 + Since PHP 8.4.0, a parameterless exit call within a + registered shutdown function resets the exit code to 0. + Calling exit with an explicit status overwrites the + previous exit code in all versions. diff --git a/reference/misc/functions/exit.xml b/reference/misc/functions/exit.xml index 10d7c57fbd94..bec91ba23987 100644 --- a/reference/misc/functions/exit.xml +++ b/reference/misc/functions/exit.xml @@ -112,10 +112,11 @@ 8.4.0 - When calling exit within - Shutdown functions + A parameterless exit called within + shutdown functions or object destructors - any previous exit code gets overwritten + now resets the exit code to 0; previously the exit code + set by an earlier exit call was kept.