From 82928fcff34b60e85bf6508bab8901ff49cb1ff1 Mon Sep 17 00:00:00 2001 From: lacatoire Date: Tue, 1 Sep 2026 17:31:26 +0200 Subject: [PATCH 1/3] ext/pcntl: fix declared signature of pcntl_signal($restart_syscalls) pcntl_signal() parses its third argument with Z_PARAM_BOOL_OR_NULL(), so null is accepted, and null is also what selects the SIGALRM specific default of false. The stub declared a non-nullable bool defaulting to true, so Reflection reported a signature the implementation does not honour. Every other Z_PARAM_BOOL_OR_NULL() user declares a nullable parameter defaulting to null: imageinterlace(), json_decode(), libxml_use_internal_errors() and sapi_windows_vt100_support(). Align pcntl_signal() with them. Runtime behaviour is unchanged: null was already accepted, and null and an omitted argument already took the same path. --- ext/pcntl/pcntl.stub.php | 2 +- ext/pcntl/pcntl_arginfo.h | 4 ++-- ext/pcntl/pcntl_decl.h | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ext/pcntl/pcntl.stub.php b/ext/pcntl/pcntl.stub.php index 4a4b8fe86931..1ab52d025036 100644 --- a/ext/pcntl/pcntl.stub.php +++ b/ext/pcntl/pcntl.stub.php @@ -1023,7 +1023,7 @@ function pcntl_waitid(int $idtype = P_ALL, ?int $id = null, &$info = [], int $fl function pcntl_wait(&$status, int $flags = 0, &$resource_usage = []): int {} /** @param callable|int $handler */ - function pcntl_signal(int $signal, $handler, bool $restart_syscalls = true): bool {} + function pcntl_signal(int $signal, $handler, ?bool $restart_syscalls = null): bool {} /** @return callable|int */ function pcntl_signal_get_handler(int $signal) {} diff --git a/ext/pcntl/pcntl_arginfo.h b/ext/pcntl/pcntl_arginfo.h index 2da7c8ad5db8..a0ba6f712e5f 100644 --- a/ext/pcntl/pcntl_arginfo.h +++ b/ext/pcntl/pcntl_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit pcntl.stub.php instead. - * Stub hash: 04e7b30c6fb23cf6ce6bc26fe094fd5b4dbfe826 + * Stub hash: ec6306e93fad6d127ff880fc01736ac287619cf7 * Has decl header: yes */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_fork, 0, 0, IS_LONG, 0) @@ -31,7 +31,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_signal, 0, 2, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, signal, IS_LONG, 0) ZEND_ARG_INFO(0, handler) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, restart_syscalls, _IS_BOOL, 0, "true") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, restart_syscalls, _IS_BOOL, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_signal_get_handler, 0, 0, 1) diff --git a/ext/pcntl/pcntl_decl.h b/ext/pcntl/pcntl_decl.h index 7f8e5172cedb..a0fdb4dde755 100644 --- a/ext/pcntl/pcntl_decl.h +++ b/ext/pcntl/pcntl_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit pcntl.stub.php instead. - * Stub hash: 04e7b30c6fb23cf6ce6bc26fe094fd5b4dbfe826 */ + * Stub hash: ec6306e93fad6d127ff880fc01736ac287619cf7 */ -#ifndef ZEND_PCNTL_DECL_04e7b30c6fb23cf6ce6bc26fe094fd5b4dbfe826_H -#define ZEND_PCNTL_DECL_04e7b30c6fb23cf6ce6bc26fe094fd5b4dbfe826_H +#ifndef ZEND_PCNTL_DECL_ec6306e93fad6d127ff880fc01736ac287619cf7_H +#define ZEND_PCNTL_DECL_ec6306e93fad6d127ff880fc01736ac287619cf7_H typedef enum zend_enum_Pcntl_QosClass { ZEND_ENUM_Pcntl_QosClass_UserInteractive = 1, @@ -12,4 +12,4 @@ typedef enum zend_enum_Pcntl_QosClass { ZEND_ENUM_Pcntl_QosClass_Background = 5, } zend_enum_Pcntl_QosClass; -#endif /* ZEND_PCNTL_DECL_04e7b30c6fb23cf6ce6bc26fe094fd5b4dbfe826_H */ +#endif /* ZEND_PCNTL_DECL_ec6306e93fad6d127ff880fc01736ac287619cf7_H */ From f5de1cf3d67aeda41b5836d48f8d4fc39d272172 Mon Sep 17 00:00:00 2001 From: lacatoire Date: Tue, 1 Sep 2026 21:26:26 +0200 Subject: [PATCH 2/3] ext/pcntl: test the declared signature of pcntl_signal($restart_syscalls) Covers the nullable third parameter under declare(strict_types=1): the reflected type and default, null/true/false and the omitted argument, and the TypeError raised for a non-bool. --- .../tests/pcntl_signal_restart_syscalls.phpt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ext/pcntl/tests/pcntl_signal_restart_syscalls.phpt diff --git a/ext/pcntl/tests/pcntl_signal_restart_syscalls.phpt b/ext/pcntl/tests/pcntl_signal_restart_syscalls.phpt new file mode 100644 index 000000000000..4ef315bfe225 --- /dev/null +++ b/ext/pcntl/tests/pcntl_signal_restart_syscalls.phpt @@ -0,0 +1,36 @@ +--TEST-- +pcntl_signal(): $restart_syscalls is nullable +--EXTENSIONS-- +pcntl +--FILE-- +getParameters()[2]; +var_dump((string) $parameter->getType()); +var_dump($parameter->allowsNull()); +var_dump($parameter->getDefaultValue()); + +var_dump(pcntl_signal(SIGALRM, SIG_IGN)); +var_dump(pcntl_signal(SIGALRM, SIG_IGN, null)); +var_dump(pcntl_signal(SIGALRM, SIG_IGN, true)); +var_dump(pcntl_signal(SIGALRM, SIG_IGN, false)); + +try { + pcntl_signal(SIGALRM, SIG_IGN, 1); +} catch (TypeError $exception) { + echo $exception->getMessage(), "\n"; +} + +var_dump(pcntl_signal(SIGALRM, SIG_DFL)); +?> +--EXPECT-- +string(5) "?bool" +bool(true) +NULL +bool(true) +bool(true) +bool(true) +bool(true) +pcntl_signal(): Argument #3 ($restart_syscalls) must be of type ?bool, int given +bool(true) From c567fa3a8a799a384477f0fb1408e71c3d6fd911 Mon Sep 17 00:00:00 2001 From: Louis-Arnaud Date: Tue, 1 Sep 2026 22:15:42 +0200 Subject: [PATCH 3/3] Update ext/pcntl/tests/pcntl_signal_restart_syscalls.phpt Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com> --- ext/pcntl/tests/pcntl_signal_restart_syscalls.phpt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/pcntl/tests/pcntl_signal_restart_syscalls.phpt b/ext/pcntl/tests/pcntl_signal_restart_syscalls.phpt index 4ef315bfe225..693f1efebf9b 100644 --- a/ext/pcntl/tests/pcntl_signal_restart_syscalls.phpt +++ b/ext/pcntl/tests/pcntl_signal_restart_syscalls.phpt @@ -18,8 +18,8 @@ var_dump(pcntl_signal(SIGALRM, SIG_IGN, false)); try { pcntl_signal(SIGALRM, SIG_IGN, 1); -} catch (TypeError $exception) { - echo $exception->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump(pcntl_signal(SIGALRM, SIG_DFL)); @@ -32,5 +32,5 @@ bool(true) bool(true) bool(true) bool(true) -pcntl_signal(): Argument #3 ($restart_syscalls) must be of type ?bool, int given +TypeError: pcntl_signal(): Argument #3 ($restart_syscalls) must be of type ?bool, int given bool(true)