From 25e2decf8b4c4b36a467ba5a91105e8badbb5781 Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 29 Sep 2025 23:05:36 +1000 Subject: [PATCH 1/6] Add `stream_socket_{client,server}` stubs for `@param-out` --- stubs/stream_socket_client.stub | 15 +++++++++++++++ stubs/stream_socket_server.stub | 14 ++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 stubs/stream_socket_client.stub create mode 100644 stubs/stream_socket_server.stub diff --git a/stubs/stream_socket_client.stub b/stubs/stream_socket_client.stub new file mode 100644 index 0000000000..6b269adb92 --- /dev/null +++ b/stubs/stream_socket_client.stub @@ -0,0 +1,15 @@ + Date: Tue, 30 Sep 2025 00:01:25 +1000 Subject: [PATCH 2/6] fix(conf): register the stubs --- conf/config.neon | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/config.neon b/conf/config.neon index 16bb587638..6f4076a3dd 100644 --- a/conf/config.neon +++ b/conf/config.neon @@ -136,6 +136,8 @@ parameters: - ../stubs/typeCheckingFunctions.stub - ../stubs/Countable.stub - ../stubs/file.stub + - ../stubs/stream_socket_client.stub + - ../stubs/stream_socket_server.stub earlyTerminatingMethodCalls: [] earlyTerminatingFunctionCalls: [] resultCachePath: %tmpDir%/resultCache.php From b883a48cd66dec965532c10b77090c582435dfb7 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 30 Sep 2025 00:03:25 +1000 Subject: [PATCH 3/6] fix(stubs): specify the parameters as actual references --- stubs/stream_socket_client.stub | 4 ++-- stubs/stream_socket_server.stub | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/stream_socket_client.stub b/stubs/stream_socket_client.stub index 6b269adb92..81a1e81835 100644 --- a/stubs/stream_socket_client.stub +++ b/stubs/stream_socket_client.stub @@ -6,8 +6,8 @@ */ function stream_socket_client( string $address, - int $error_code = null, - string $error_message = null, + int &$error_code = null, + string &$error_message = null, float $timeout = null, int $flags = STREAM_CLIENT_CONNECT, resource $context = null diff --git a/stubs/stream_socket_server.stub b/stubs/stream_socket_server.stub index 0733293638..f0736ce2ad 100644 --- a/stubs/stream_socket_server.stub +++ b/stubs/stream_socket_server.stub @@ -6,8 +6,8 @@ */ function stream_socket_server( string $address, - int $error_code = null, - string $error_message = null, + int &$error_code = null, + string &$error_message = null, int $flags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, resource $context = null ): resource|false { From 17dd8a637b489ed5de7efede36c56bf9b15a900a Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 30 Sep 2025 00:09:11 +1000 Subject: [PATCH 4/6] fix(stubs): type `resource` via PHPDoc --- stubs/stream_socket_client.stub | 6 ++++-- stubs/stream_socket_server.stub | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/stubs/stream_socket_client.stub b/stubs/stream_socket_client.stub index 81a1e81835..6145aa2908 100644 --- a/stubs/stream_socket_client.stub +++ b/stubs/stream_socket_client.stub @@ -3,6 +3,8 @@ /** * @param-out int $error_code * @param-out string $error_message + * @param resource|null $context + * @return resource|false */ function stream_socket_client( string $address, @@ -10,6 +12,6 @@ function stream_socket_client( string &$error_message = null, float $timeout = null, int $flags = STREAM_CLIENT_CONNECT, - resource $context = null -): resource|false { + $context = null +) { } diff --git a/stubs/stream_socket_server.stub b/stubs/stream_socket_server.stub index f0736ce2ad..2fab72c780 100644 --- a/stubs/stream_socket_server.stub +++ b/stubs/stream_socket_server.stub @@ -3,12 +3,14 @@ /** * @param-out int $error_code * @param-out string $error_message + * @param resource|null $context + * @return resource|false */ function stream_socket_server( string $address, int &$error_code = null, string &$error_message = null, int $flags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, - resource $context = null -): resource|false { + $context = null +) { } From 1038814b5975de8aa22d20e5b69be0f61b700e11 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 30 Sep 2025 00:14:20 +1000 Subject: [PATCH 5/6] fix(stubs): mark parameters as explicitly nullable --- stubs/stream_socket_client.stub | 11 ++++++----- stubs/stream_socket_server.stub | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/stubs/stream_socket_client.stub b/stubs/stream_socket_client.stub index 6145aa2908..e53569f19e 100644 --- a/stubs/stream_socket_client.stub +++ b/stubs/stream_socket_client.stub @@ -1,16 +1,17 @@ Date: Tue, 30 Sep 2025 00:39:00 +1000 Subject: [PATCH 6/6] fix(stubs): provide `@param` alongside `@param-out` --- stubs/stream_socket_client.stub | 2 ++ stubs/stream_socket_server.stub | 2 ++ 2 files changed, 4 insertions(+) diff --git a/stubs/stream_socket_client.stub b/stubs/stream_socket_client.stub index e53569f19e..d5e6a7f13b 100644 --- a/stubs/stream_socket_client.stub +++ b/stubs/stream_socket_client.stub @@ -1,7 +1,9 @@