fix!: handle php errors with custom error handling
This commit changes the api of the stream classes, since indication of success or failure is no longer necessary.
This commit is contained in:
@@ -100,22 +100,12 @@ abstract class Stdio
|
||||
*
|
||||
* @param resource $stream
|
||||
*
|
||||
* @throws InvalidArgumentException When stream is not a live stream resource
|
||||
* @throws InvalidArgumentException When stream is not a stream resource
|
||||
*/
|
||||
public static function stream($stream): StdioInterface
|
||||
{
|
||||
$isResource = is_resource($stream)
|
||||
|| ($stream !== null
|
||||
&& !is_scalar($stream)
|
||||
&& !is_array($stream)
|
||||
&& !is_object($stream));
|
||||
|
||||
if (!$isResource) {
|
||||
throw new InvalidArgumentException('not a resource');
|
||||
}
|
||||
|
||||
if (get_resource_type($stream) !== 'stream') {
|
||||
throw new InvalidArgumentException('resource is not a stream or was closed');
|
||||
throw new InvalidArgumentException('resource is not a stream');
|
||||
}
|
||||
|
||||
return new class($stream) implements StdioInterface {
|
||||
|
||||
Reference in New Issue
Block a user