Commit 0338a00e94d for php.net
commit 0338a00e94d227e518e04e1365ce3a3a80a3c5f9
Author: Louis-Arnaud <la.catoire@gmail.com>
Date: Wed Sep 2 07:27:04 2026 +0200
ext/pcntl: fix declared signature of pcntl_signal($restart_syscalls) (#23531)
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.
Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com>
diff --git a/ext/pcntl/pcntl.stub.php b/ext/pcntl/pcntl.stub.php
index 4a4b8fe8693..1ab52d02503 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 2da7c8ad5db..a0ba6f712e5 100644
Binary files a/ext/pcntl/pcntl_arginfo.h and b/ext/pcntl/pcntl_arginfo.h differ
diff --git a/ext/pcntl/pcntl_decl.h b/ext/pcntl/pcntl_decl.h
index 7f8e5172ced..a0fdb4dde75 100644
Binary files a/ext/pcntl/pcntl_decl.h and b/ext/pcntl/pcntl_decl.h differ
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 00000000000..693f1efebf9
--- /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--
+<?php
+declare(strict_types=1);
+
+$parameter = (new ReflectionFunction('pcntl_signal'))->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 (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+var_dump(pcntl_signal(SIGALRM, SIG_DFL));
+?>
+--EXPECT--
+string(5) "?bool"
+bool(true)
+NULL
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+TypeError: pcntl_signal(): Argument #3 ($restart_syscalls) must be of type ?bool, int given
+bool(true)