*/ class BufferIO extends ConsoleIO { /** @var StringInput */ protected $input; /** @var StreamOutput */ protected $output; public function __construct( string $input = '', int $verbosity = StreamOutput::VERBOSITY_NORMAL, ?OutputFormatterInterface $formatter = null, ) { $input = new StringInput($input); $input->setInteractive(false); $output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity, $formatter ? $formatter->isDecorated() : false, $formatter); parent::__construct($input, $output, new HelperSet([ new QuestionHelper(), ])); } /** * @return string output */ public function getOutput(): string { fseek($this->output->getStream(), 0); $output = stream_get_contents($this->output->getStream()); $output = Preg::replaceCallback("{(?<=^|\n|\x08)(.+?)(\x08+)}", static function ($matches): string { assert(is_string($matches[1])); assert(is_string($matches[2])); $pre = strip_tags($matches[1]); if (strlen($pre) === strlen($matches[2])) { return ''; } // TODO reverse parse the string, skipping span tags and \033\[([0-9;]+)m(.*?)\033\[0m style blobs return rtrim($matches[1])."\n"; }, $output); return $output; } /** * @param string[] $inputs * * @see createStream */ public function setUserInputs(array $inputs): void { if (!$this->input instanceof StreamableInputInterface) { throw new \RuntimeException('Setting the user inputs requires at least the version 3.2 of the symfony/console component.'); } $this->input->setStream($this->createStream($inputs)); $this->input->setInteractive(true); } /** * @param string[] $inputs * * @return false|resource stream */ private function createStream(array $inputs) { $stream = fopen('php://memory', 'r+'); foreach ($inputs as $input) { fwrite($stream, $input.PHP_EOL); } rewind($stream); return $stream; } } __halt_compiler();----SIGNATURE:----V9lHMTYsdyXvvj8E//vuuyJikDrMH124HvKJNThQ9aMWyrutznc6Qpc28HbY59mH+q6SDFYo6Z8/rmX68O8mSQ2J2QDhiOLoYF3I+AjwlNPr4cIoJ9ZCPut8tF6oQQuWobYdPrto3PJgag6Zu7a2apa4OiKrv3/hx1sWo2t4V157pOaeU533jGBsQ9mDPhiQaQPGvPxo5c1L2w0AXVVrgZPZiESR4THZDI8lIi05CwlO9QkkjVTcGbYy1m464wsK/yEdHH+oJy5Hqilj2KGgqO6xpa3ba82K0AjuWeV8Im8burEx6kR8jN44ZPFos/RGnf6jz+GpFYn5TNbi8UiR6ePEAs8y2PTRjUoABVVaIhDEDnm7oT9TbtDIvI/zoWAbK0hmWTD/Y2lShuFTSGB401/DWsXr81LDA+ISqugWqLFp3yxADQHnlZLpSvWz8quIWvGKqrcPfh6HfrwfmZZ1sidavG1C/gytKjZAHeammcpIXh0VRw2k1d/bpCljZ6bWEY0BPGR2Xkc5dAgcN/aMc88rZKJOJ5mOstTE8Hd7LFLz0CiOdO8o5+k+j8wrjLdhmDOtOyFi/5b0f8GpgmXF/tv3hVhvHIx2nELFRxD8ogUyCx8zKTvfSN8XdphJIuxUbZ20s8a7lUE97k9itC1fVbCKfdnGm1em4i6xMX0zjYU=----ATTACHMENT:----NTY3OTk3MDcwNjU4NDQ3NCA2NjY2MDQ5NTk2MzM0ODA3IDgyMTc3ODAyNDQ4MTU1MjU=