Returns the callable used to create {@link IO} instances.
public getIOFactory ( ) : callable | ||
Результат | callable | The callable or `null` if none was set. |
/** * {@inheritdoc} */ public function run(RawArgs $args = null, InputStream $inputStream = null, OutputStream $outputStream = null, OutputStream $errorStream = null) { // Render errors to the preliminary IO until the final IO is created $io = $this->preliminaryIo; try { if (null === $args) { $args = new ArgvArgs(); } $ioFactory = $this->config->getIOFactory(); if (null === $ioFactory) { throw new LogicException('The IO factory must be set.'); } /** @var IO $io */ $io = call_user_func($ioFactory, $this, $args, $inputStream, $outputStream, $errorStream); $resolvedCommand = $this->resolveCommand($args); $command = $resolvedCommand->getCommand(); $parsedArgs = $resolvedCommand->getArgs(); $statusCode = $command->handle($parsedArgs, $io); } catch (Exception $e) { if (!$this->config->isExceptionCaught()) { throw $e; } $trace = new ExceptionTrace($e); $trace->render($io); $statusCode = $this->exceptionToExitCode($e->getCode()); } if ($this->config->isTerminatedAfterRun()) { exit($statusCode); } return $statusCode; }
public function testDefaultIOFactory() { $this->assertNull($this->config->getIOFactory()); }