Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129407 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 7F2581A00BC for ; Sun, 23 Nov 2025 15:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1763910336; bh=E4VGDT14T9yKE6zw6gNWdggvrC5la+yeHigs1Wmm/Dg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=WH+yAGrI2ovIjG9IeGxCSu4FahzOR9zQD2o/E2Jdo2yCNd+xnN+gyyWf7kA1lwLR1 ALxNXFPlVx9OU3raPJHk1p4VG8hK2Tlzf9SRen53JQlNGOVVF7xdMJ3zeb58OQgi+a 1kh+ZiIMOE8DpdGZPsZ3vR/TPDq9s22ThNiJ6jgZvqoKre2LVAdilFwf1hcLylqXv6 1VQq5roI3pdepcdGTbmPUf+1GVv4JIQHF7z2kGz1TBtVQp/sS3jjTgmWwdGnUIy9LU Izq6oOg0kJMJg+EbSnuGLNCdTWpc6wMLuGzDeNTrZHUfD3FqytggrXkaMhf4OXFcyi 1XYof8F/IgLCw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7E90A180040 for ; Sun, 23 Nov 2025 15:05:35 +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.6 required=5.0 tests=BAYES_50,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 ; Sun, 23 Nov 2025 15:05:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1763910314; bh=+HucL6oWzfVOxX17oVyr2VMiqvq9xEDSopLAkf81zis=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=K/wwk7+wWA44zh+37Q7CSTQppVMS0ZAPTgJA1PmCT5qXuqq0PH7CuOXf4LlMJ2EWk 7P0OXtg88gxJI47yLq6aFlWVlAW/hmQVfOsIPkaulypJFCfiWz0hogxdS/tW+dAXAF TJXNQ2Ogo11r1+5R69tfidYCoW1hyRuWAlwllIN5b7faxTK+1XuRTMHvLKiM1ZebVB NfZlSpBwPpxoL+pO23SN58bx6lwKHgbCwxfjixJIkUJPpxTuBDWWkn9OgmuUEZuYtO PvDnV3f6WqpCuVPHvaRlKmjSLNs5ljjfTSz+SHFFnrTiAhzU0F4AqHln67C4xsnMvm A2PwSfyLRNdTA== Message-ID: <7351fc32-93fa-4a22-a311-20c5ec34e01c@bastelstu.be> Date: Sun, 23 Nov 2025 16:05:12 +0100 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] Polling API To: Jakub Zelenka Cc: PHP internals list References: Content-Language: en-US In-Reply-To: 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 Apologies for the late reply. It was a few busy weeks leading up to the PHP 8.5 Release. When searching for the RFC text I just noticed that it does not appear to be listed in https://wiki.php.net/rfc#under_discussion yet. On 10/31/25 13:06, Jakub Zelenka wrote: >> 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. >> >> > I missed that they should not be backed. I just saw `enum AdjacentPosition > : string` in Dom so thought that it's fine to use it... Will change it. I missed that one indeed. That one is a little special, because ext/dom implements an existing API standard, where the API is defined based on string parameters. So there already was a “well-defined” string for each enum case that is needed for better interoperability with the external standard. >> >> 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.”). >> >> > This makes sense and I will introduce more exceptions. I will not use > exception per errno but some middle ground is a good idea. Maybe per op > exception with codes representing specific errors would be make sense? Yes, that makes sense to me. I don't exactly know which types of error can appear, but as a developer I am generally not interested in super-granular handling of the errors but rather broad categories. If the details are only available as the code, then that's totally fine and within policy. > >> 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”. > > > It fails if the same fd is added. This is also limitation of backends (e.g. > epoll does not allow the same fd to be added twice). I got error code for > the specific errors so this should be probably exposed as well. It would > still make sense to differentiate that it's an exception for addition. I see. I was wondering if it would make sense to simply ignore the error, thus making the operation idempotent (more convenient for a high-level language like PHP). But I suppose that doesn't work, because the `$data` could be different? Exception-wise this should probably be a DuplicateHandleError (i.e. within the Error hierarchy, since it's a programming error to add duplicate handles). > It's compile time but not sure if I like exposing enum only if compiled in > as it makes the checks harder. This part is not really something that > users should use but it's really more for testing purpose. In reality > everyone should just use default Auto... But getAvailableBackends() might > make sense even for testing. Maybe it could also have per enum method > isAvailable() so user can check that but not sure if it's needed. I'll think about this more when you made a decision and updated the RFC text :-) Best regards Tim Düsterhus