Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130513 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 E010F1A00BC for ; Tue, 31 Mar 2026 09:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1774951177; bh=a8Du09f5RW7ixO7wThtcZZhDcDLXlJxG0Asty2q6f/w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=O3mwHr/hj37GnYkK1XQJYJe3vqvV9gFvl5vdqdPJ54b6rNJNN3Gz1S2P+zFtf5j8s jPdxiTei8wZivebeFdjKwGPYAxYjghDmMfyhw2B7OiafH1hDsgmbgjA+QMteKOZP4f Evo0n6fpaqnCS5vpPBhGKqxrMx23ywQPO3rZzvD4IZyjddTaCUwfdF7sH+VAEAN4Lg ZNsNXBX7d5kZkDqdPQXg0cPptHkKMyQbB0t3zdpPXwHV37EeKFoSy9rw4FUOQvN/h9 s5pgxLPiKlF7ouf43X7L/YiR0z71AoD0FsILzTf6QRf4KMmO+CxUhjM/m7UiJ+taqL 7z8MWq8Cu3dfQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CA1E41801EE for ; Tue, 31 Mar 2026 09:59: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 ; Tue, 31 Mar 2026 09:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1774951159; bh=FvVNLFSiqS0d9uvjx28Huy7YOotw1Deb9ZF+mMBQG1g=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=ZRbL07+cGdjpOip1N2BpGB2pACmjP4DwvHDi0T8heUC619LYzTm6ku38Gcosbfw7a vwye62CtGagxyGX25jLDaLRPSt9CtAyJGQKYXF0SvXoY+O4lO0yxX+f2RhXJ1PIqD6 lj/EnSWHp8jgmOyHV+ovQmnxfpc27v5NcGOimPwzkAiL4jyBVSfRSqeI37yFDh6Zi0 h4sYBW7qn3Rn4XrTRmXUWrhTnmti+owu4ii5zFuRD5JV0nrZNiCsspKMNscXzvtJcu ft1kFgtzrkjYl37VSY8iPMmb8praTK8+7IMjFIeBNnX505qttHwQjsXuMn+NowBx1Y h5NzvxevJPsag== Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Tue, 31 Mar 2026 11:59:18 +0200 To: Jakub Zelenka Cc: Nicolas Grekas , PHP internals list Subject: Re: [PHP-DEV] Re: [RFC] Stream Error Handling Improvements In-Reply-To: References: Message-ID: <1597c99a0ad7dc1e55a40f952d7536c5@bastelstu.be> 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 2026-03-29 20:25, schrieb Jakub Zelenka: >> For the naming of `stream_get_last_error()`: Within PHP we have both >> `X_get_last_error()` and `X_last_error()`. The latter seems to be more >> common and also what I would prefer here, because the `stream_get_` >> prefix sounds to me like we would get something from a stream, but the >> returned value is not related to a specific stream, but rather a >> global. >> >> > Good point, I changed it but because it now returns array (no linked > list), > it's called stream_last_errors(). I also added stream_clear_errors for > explicit clearing which might be useful in some situations. That both makes sense to me. > The RFC and the implementation is updated so please take a look! Thank you. The updated RFC looks really good now. I have some (final?) minor remarks: 1. "// Search for specific codes using array_any (PHP 8.5+)" array_any is already available in PHP 8.4. The same is true for "array_find (PHP 8.5+)" in the same example. But given it's an RFC for PHP 8.6 anyways, we already know that these functions exist, so the hint could just be removed entirely. 2. In the example example "$primary = $errors[0] ?? null;" This can just be `$primary = array_first($errors);` (PHP 8.5+). Same for the other examples. The examples should ideally show the cleanest possible code :-) 3. For "StreamErrorCode::is*()" Can error codes fall into multiple categories or is it always a single one? If it's guaranteed to be a single category, then perhaps a `->getErrorCategory()` method returning a StreamErrorCodeCategory enum makes more sense and allow for simpler / more efficient code when folks are interested in checking for multiple different categories. Instead of `$code->isNetworkError() || $code->isFileSystemError()` they can do `\in_array($code->getErrorCategory(), [StreamErrorCodeCategory::NetworkError, StreamErrorCodeCategory::FileSystemError], true)` or use a `match()` expression instead. Best regards Tim Düsterhus