Re: Re: [RFC] Stream Error Handling Improvements

From: Date: Thu, 02 Apr 2026 17:25:11 +0000
Subject: Re: Re: [RFC] Stream Error Handling Improvements
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-130534@lists.php.net to get a copy of this message
Hi On Tue, Mar 31, 2026 at 11:59 AM Tim Düsterhus <tim@bastelstu.be> wrote: > > 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. > > Fixed > 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 :-) > > Fixed > 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. > > After doing a review of the categories, I decided to drop all the helpers and not expose categories in any way. More on the reasoning in my other replay to Pierre. Kind regards, Jakub

« previous php.internals (#130534) next »