Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129019 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 9BBA11A00BC for ; Fri, 31 Oct 2025 09:40:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761903632; bh=j4E2c/5+Rn7HbcCzilNBH2C25kU0cDVC0UkFQ80v9dU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AASynnpaRe/qy9T2dlw56pyGdRCCNTFabSgWSZyGLcEBM5JttVLESe/li4EPFbN4s eOad+gxF64T9iJ1EbyjaVgRgOE5KtV8WLNa+/sCqb6wj6G/O/lyhD4kop2rv8ixyv9 tnE3sjW4WDTW3p9bgrSVmbvkcPJHBfp3nJTLfz+YIAA5MGyPBBJxpFsKOdwXGv5wwY X1jlTtUho/RvIalxLb4LGm6yq07vmkVLB4h4o5AKi+V69RAaJ6ghpcuTKQY9s8GQrC hz6JoLbpQEsKealvX+1XQtMAfgMyas+yiMQ8GE/hG3yfhjcd01xdoiy/shzpK5Dqwp Yoz+s7vezC6Xg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7C686180039 for ; Fri, 31 Oct 2025 09:40:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 31 Oct 2025 09:40:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1761903625; bh=NtOrEW7YVWNVN7qvBuRzcu4Qi8V0F6cI6qg/yNKnVZQ=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=YLtlp4YIGMApU0QnrVQjMCznlCL3dfNcPxgbcCW0EZGDTAPjR/Zqa+wkFR/2bRaK4 tsNHx809OW1yBBRneievLDTb89Z6NDu5lN2deAA+guHQKQrBLqGPu1J0SlCb0IjWVn WGo8X9Hc/f2IeO/h1RmyOwo+sKCjLzoFn+24gpwwb54bKjfEJUrRVfC/bhH45kkFJU IcSjaiFrlYpZ9I0fwMDL8mrwWKX9dMxDQvW/xG8L/JAslkDqIVR42CHSiVTECh1RwC vkjiMEZ6KOT/4uvpq9JVqvWzkZcgUgBJOB36njoBMm+5a/Gyq07Y1io4XJrmmzDe5S 2O7cP7okJM1BA== Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 31 Oct 2025 10:40:24 +0100 To: Jakub Zelenka Cc: PHP internals list Subject: Re: [PHP-DEV] [RFC] Polling API In-Reply-To: References: Message-ID: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-10-30 22:06, schrieb Jakub Zelenka: > I would like to introduce a new polling API RFC that is part of my > stream > evolution work: > > https://wiki.php.net/rfc/poll_api 1. Thank you for the RFC. I've taken a first skim of the proposal and it immediately raised the question of naming and namespacing in particular. Our naming policy at https://github.com/php/policies/blob/main/coding-standards-and-naming.rst#bundled-extensions says that “namespaces SHOULD be used” and given that this is a completely new API, I think we should namespace them. My understanding is that the proposed API relies on a file descriptor and not something like a timeout. It therefore makes sense to me to put it into a `namespace Io\Poll;` or similar. We would then also have: namespace Io; class IoException extends \Exception {} namespace Io\Poll; class PollException extends \Io\IoException {} The StreamPollHandle method should possibly be placed in the global namespace still, since the stream functions are sitting there - and a SocketPollHandle would of course be sitting in the namespace of the Sockets extension. 2. As for the PollBackend enum. Is there a reason why this is a backed enum? Generally speaking enums should not be backed, unless there is a good reason for this. I don't think there is in this case - and none of the native enums are backed so far. 3. Exception-wise. StreamPollHandle::__construct(): This should probably be a ValueError, not a PollException, since passing an invalid stream is a programmer error. In the other cases it probably makes sense to further split the PollException into purpose-built exceptions according to the Throwable policy at https://github.com/php/policies/blob/main/coding-standards-and-naming.rst#throwables (“The exception message MUST NOT be the only means of distinguishing exception causes that the user might want to handle differently.”). As an example PollContext::__construct() should probably throw a BackendUnavailableException or something like this. For PollContext::add() I'm wondering in which cases a handle “cannot be added”. Is this an error situation that users will encounter in the real world? Similarly, when can PollContext::wait() fail? 4. PollBackend Is the availability of the backends known at compile time of PHP or at runtime only? Depending on that it might make sense to only conditionally define the enum cases, allowing users to check availability with `defined()` or checking the output of `::cases()`. Alternatively, a `public static function getAvailableBackends(): array` could be added. -------- I'll give the proposal a more in-depth read at a later point, but this email should already provide for some discussion points. Best regards Tim Düsterhus