Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130462 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 6EFF41A00BC for ; Thu, 26 Mar 2026 16:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1774544240; bh=EBnymmbng2n7r7i5JoXWoXb/iy30lQIJl8nroPHNcQw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=EiG1yAttekswzVHr/aidtKFf8HcBm4N77ONFNnZvoWVtboPdvzWwqilJ3MCS3lRh0 vvAzkF2eSeo3Waem1l4mfK+swC6gmWh34Z7QSJ5aCp+UXVWSaP6vLlDF/aR4vOTW7p F5pPrX28wa1HPRyL02i2kUeg3hnqkGYsdzZZfE1dBZCqmlhGDB4eXvZMvzJ9IDaYuv OmnIP8cPbRuTUNsBc/sBSLxibkAfkg1YMvvioEyTuBAjZIH16OISbebVkxORI0kKo/ MBR0gBS1JR2WeKX8wxkMMBlAJkeXeC0OpZCcAgxlhovgXYbAI1JGXU4lCXeig+fwUq 5kgbbSIAlmmTg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A5264180386 for ; Thu, 26 Mar 2026 16:57:17 +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 ; Thu, 26 Mar 2026 16:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1774544228; bh=e3QYb1nhiY/SIwui3uJ42jvy/aRxrefaXGjdRwF4svQ=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=X0aF4P4ONwWUjSncPJhVWquwDvlxnk1RHtvrWW6Z353VC6hLJI/UyMev3ze0O3fOM Xsvgny8FxbHA1DiigEp3UnGU2y2FS3990R5dOb6y6xYSAYJ8iV7ApzWWfRuYKXMV+1 zvDPJGp4dZfIVSwLsphWxleQKjWwMxihDGoktbRodO1hYXUofnEwI76slIsjwR0b0J ZjDyCSAmEL+iRj+zu8HSupghcZM29uMVgUQvTSh5K8cjqRZf5zBtFJlnFV9LTnPoLb 5jgUI//oCiS9dPBL9qLIRb4PrQSkAtmF/g5rNNmYgDkTsDSf/dBd/fW+ESqooduOtf OJZmxzqtLt0RA== Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 26 Mar 2026 17:57:07 +0100 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: 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 thank you for your RFC. I'm regretfully late to the party, but my primary comment about the RFC relates to the latest changes. Specifically: Am 2026-02-27 23:21, schrieb Jakub Zelenka: > I changed it to the StreamError class constants and also move the > is*Error > functions there. The RFC specifically defines “ranges” for the numeric value of the error constants, some of which are quite small with only 10 values available. I believe this is dangerous, because it is possible to run out of values within a specific range and users might make assumptions based on the ranges when they really should rely on the `is*()` methods to check what type of error there is. This is not a problem that would exist if the error code was an unbacked enum. Contrary to Nicolas, I also don't think it is a problem for the error code enum to be extended in future PHP versions. In other programming languages, Rust specifically, it is also common for errors to be defined as an enum that is explicitly defined to not be exhaustive. Here's an example in the standard library: https://doc.rust-lang.org/std/io/enum.ErrorKind.html. Note how the documentation says: > In application code, use match for the ErrorKind values you are > expecting; use _ to match “all other errors”. And the same would be possible in PHP by using a `default` branch in a `match()` expression. We could also add a “NonExhaustiveEnum” interface (or attribute) to PHP as a helper indicator for static analysis tools to warn if a `default` match is missing. -------- As for the `StreamError` class being a linked list: I agree with the folks that mentioned that the returned errors should be an array instead. `count()` would naturally be available, `hasCode()` can be implemented with `array_any($errors, fn ($error) => $error->code === CODE_DECODING_FAILED)` and the “primary error” can be obtained with `array_first()` (which we added in PHP 8.5). 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. Best regards Tim Düsterhus