-
-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
currently, ByteStream\getStderr has a weird behaviour in my opnion when the standard error output is not available. which is that ByteStream\getStderr() returns a stream, but, it is not the expected STDERR stream, instead, its a php://memory stream that has been closed.
I would expect either:
- return
nullindicating that the stream is not available - throw an exception informing me that the stream is not available
It would be good if this behaviour could be clarified maybe via documentation. and maybe introducing a new function that has a ( IMO ) saner behaviour?
For context, i was trying to replicate this:
/**
* Returns the default terminal output.
*
* @internal
*/
public static function getOutput(): OutputInterface
{
$standardOutputHandle = IO\output_handle();
$standardErrorOutputHandle = IO\error_handle();
if (null === $standardErrorOutputHandle) {
return new HandleOutput($standardOutputHandle);
}
return new HandleConsoleOutput($standardOutputHandle, $standardErrorOutputHandle);
}which is possible to replicate with the current behaviour:
/**
* Returns the default terminal output.
*
* @internal
*/
public static function getOutput(): OutputInterface
{
$standardOutputStream = ByteStream\getStdout();
$standardErrorOutputStream = ByteStream\getStderr();
if ($standardErrorOutputStream->isClosed()) {
return new ByteStreamOutput($standardOutputStream);
}
return new ByteStreamConsoleOutput($standardOutputStream, $standardErrorOutputStream);
}however, this implementation took me a bit of time to figure out as Amp does not mention anything about returning a closed stream from getStderr.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels