SignalHandler: fixed dodgy setup logic

This commit is contained in:
Dylan K. Taylor 2025-01-06 23:06:19 +00:00
parent 9592f066f3
commit 73edb8799d
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -36,14 +36,12 @@ use const SIGTERM;
final class SignalHandler{
/** @phpstan-var (\Closure(int) : void)|null */
private ?\Closure $interruptCallback;
private ?\Closure $interruptCallback = null;
/**
* @phpstan-param \Closure() : void $interruptCallback
*/
public function __construct(\Closure $interruptCallback){
$this->interruptCallback = $interruptCallback;
if(function_exists('sapi_windows_set_ctrl_handler')){
sapi_windows_set_ctrl_handler($this->interruptCallback = function(int $signo) use ($interruptCallback) : void{
if($signo === PHP_WINDOWS_EVENT_CTRL_C || $signo === PHP_WINDOWS_EVENT_CTRL_BREAK){