Creates an I/O based on the given input and outputs.
public __construct ( |
||
$input | The standard input. | |
$output | The standard output. | |
$errorOutput | The error output. |
/** * Creates the I/O. * * @param string $inputData The data to return from the input. * @param Formatter $formatter The formatter to use. */ public function __construct($inputData = '', Formatter $formatter = null) { $formatter = $formatter ?: new PlainFormatter(); $input = new Input(new StringInputStream($inputData)); $output = new Output(new BufferedOutputStream(), $formatter); $errorOutput = new Output(new BufferedOutputStream(), $formatter); parent::__construct($input, $output, $errorOutput); }
/** * Creates the I/O. * * @param Input $input The standard input. * @param Output $output The standard output. * @param Output $errorOutput The error output. */ public function __construct(Input $input = null, Output $output = null, Output $errorOutput = null) { if (null === $input) { $inputStream = new StandardInputStream(); $input = new Input($inputStream); } if (null === $output) { $outputStream = new StandardOutputStream(); $formatter = $outputStream->supportsAnsi() ? new AnsiFormatter() : new PlainFormatter(); $output = new Output($outputStream, $formatter); } if (null === $errorOutput) { $errorStream = new ErrorOutputStream(); $formatter = $errorStream->supportsAnsi() ? new AnsiFormatter() : new PlainFormatter(); $errorOutput = new Output($errorStream, $formatter); } parent::__construct($input, $output, $errorOutput); }