From f40d183271e1ed42a540a0e863131701f518eac6 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Wed, 29 Apr 2026 14:36:12 +0200 Subject: [PATCH] fix(controller): default $socketIds in whisper() to silence PHP 8.x deprecation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Optional parameter $payload (and $event) declared before required parameter $socketIds is implicitly treated as required by PHP 8.4+, emitting a deprecation on every class load: PHP Deprecated: Optional parameter $payload declared before required parameter $socketIds is implicitly treated as a required parameter Made $socketIds optional (= []) — empty matches no connections via array_flip lookup, so callers that intentionally omit it get a no-op which preserves the practical contract (you can't whisper to nobody). All four parameters are now optional. No call-site changes needed. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/Websocket/Controller.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Websocket/Controller.php b/src/Websocket/Controller.php index 40acf82..280949a 100644 --- a/src/Websocket/Controller.php +++ b/src/Websocket/Controller.php @@ -473,9 +473,14 @@ class Controller final public function whisper( array|string|null $payload = null, ?string $event = null, - array $socketIds, + array $socketIds = [], ?string $channel = null ) { + // PHP 8.x deprecates "optional before required" in parameter + // lists, so $socketIds is now defaulted. Empty $socketIds is a + // no-op (the array_flip-based lookup below matches no + // connections), preserving the existing behavior for callers + // that intentionally omit it. if (is_string($payload)) { $payload = [ 'message' => $payload,