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