Hi

On Tue, Mar 31, 2026 at 11:59 AM Tim Düsterhus <[email protected]> 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

Reply via email to