diff --git a/src/Internal/Stream/LogStream.php b/src/Internal/Stream/LogStream.php index 144dd27..2537757 100644 --- a/src/Internal/Stream/LogStream.php +++ b/src/Internal/Stream/LogStream.php @@ -16,7 +16,13 @@ private function __construct(mixed $resource) public static function from(mixed $resource = null): LogStream { - return new LogStream(resource: $resource ?? STDERR); + if ($resource !== null) { + return new LogStream(resource: $resource); + } + + $fallback = fopen('php://stderr', 'wb'); + + return new LogStream(resource: $fallback); } public function write(string $content): void diff --git a/tests/Internal/Stream/LogStreamTest.php b/tests/Internal/Stream/LogStreamTest.php new file mode 100644 index 0000000..f6d8e05 --- /dev/null +++ b/tests/Internal/Stream/LogStreamTest.php @@ -0,0 +1,22 @@ +