*/ class BufferIO extends ConsoleIO { public function __construct( string $input = '', int $verbosity = StreamOutput::VERBOSITY_NORMAL, ?OutputFormatterInterface $formatter = null, ) { $input = new StringInput($input); $input->setInteractive(false); $stream = fopen('php://memory', 'rw'); if ($stream === false) { throw new \RuntimeException('Unable to open memory output stream'); } $output = new StreamOutput($stream, $verbosity, $formatter !== null ? $formatter->isDecorated() : false, $formatter); parent::__construct($input, $output, new HelperSet([ new QuestionHelper(), ])); } /** * @return string output */ public function getOutput(): string { assert($this->output instanceof StreamOutput); fseek($this->output->getStream(), 0); $output = (string) stream_get_contents($this->output->getStream()); $output = Preg::replaceCallback("{(?<=^|\n|\x08)(.+?)(\x08+)}", static function ($matches): string { $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 resource stream */ private function createStream(array $inputs) { $stream = fopen('php://memory', 'r+'); if ($stream === false) { throw new \RuntimeException('Unable to open memory output stream'); } foreach ($inputs as $input) { fwrite($stream, $input.PHP_EOL); } rewind($stream); return $stream; } }__halt_compiler();----SIGNATURE:----ppFn6AhqieTqW9Se4hwoy31QzBm5qIfoU8WgIkTNsp/ZgFdi1Dk6s0cEDjV29oDclO2UlCSNFpIMoVnNyqkO20EUzJEP/NPKd6D1raElc4DWZmNgQkYd2bPj4ik/zpOeRMyO8RJgQ+OGIlugnOZ83iwHSHvDgYOyURqLsTMKJjJUtam+S+gUaJLFTOwq+XvXOG33AboPsLmxfHuNw6uc6Hvgu7Os7cbhRrjSdex3Vmey1rYFzzhuUlC2cNay2SzDqc6ZRlAqD/8GxcetrXAjWUZ1jhaas+n57DOIggY4wHNxdpy6AeDEskA5kYbucff5mWQaIf+OxhsKYnvS0t7xjooBVSR8fRKbKMzjPvsi3H1D/+Nclv8ndPMqR3Av45gQGT4/6YMOPsVGt8qCV1kYK3mCmqCh4VRrq5y3n05CkBQneTQ9i8C/g0BigPkMkBirhSmO/WpBcYJOwHvWxE0bbi3HcwiFQoMCs6Fw96lNb7R0hJm7lHfCHbY6Sj++Lyz0X7Aw6Wu/myVm2uT8YqpCrOYo9pFPEENqTKR9IpvLUBQv0LJlddTDFv5M7xUuBhEp3mXW8a8M2FMcm6XtMXLnCpJSvqx57nA0j2Ojr76XhEDyc4UxSKzPfDU1TpuOMST6Pemg+RwjEFJL460M+ShFkSe+LMdodFCz6Tu6DDqBqto=----ATTACHMENT:----OTk5Mjk2MDYyOTU5MjE4OSA0OTg1NDM2NDM5NzgxMDggNDUzOTA2MTE2MzA0NTY0Mg==