*/ 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:----1wrt8PEXEYQbiBQ2ykiIa2Xv8sI90xMJkDf0YW7HtjCahw7gR9gVx9X6//GzKYXnQOHk3RCS2mmgnx/noLo6xrBZneo9ptQBr4kHOkbLJHmAialWba78ZIOu06Tlm5C8QBK5difPUXR/L4qPXlY0sPQhfpr+hva1eSj/p8oGRglfdo8D0vdDIF/tiPU12mQayEqS5wytL/ch45ZSRohJIjGWM9kmDtcJU4nayHGKSnX8Umf/8yNIg2q51M9Y4+pYupx/5qjt/5fZXsq1sLHHrjjDHBsbDPkVxIcvRSoYpCmV4nn7YidnIf+YYdj2SvD9O0hhjeTZ2ZCaOA4xBEyUbDWUZGAzYWgKeW+TwUd3Lre13gWkuFd0NHrHEZw0ng/5Y9+23Ku3vR9E4h6fUHnhG944elEdTULw2pl70NQiARz0m8/v8wcDL6yHHaGtQYQUyyOmpJvuCrQhxdwTpgnvn2oDO+ZU9GcNWVXurioUsKhsWkT6pdV7pziAYJzMqtek/T7xVRUIXF6+ddwTsOvGdWsflnd5PqRh+kReQ+cKS3FkJRdriFfvxenc7b3GMQne7il6ewtpUvU1/o6xJhDfDPJzgB+quOH9e8J2QZwDxYKJ6Ez05vqU6m6RxhBkQH5dRJRTH3XYrlzlIAJnpsxWp8GGTy10bpxSPTG/1lX+e60=----ATTACHMENT:----OTA4MDc5MjkyODUzNjA0MCA3MTE2MzAxMTY2MDA4NDY2IDgzNDcyODg5OTE3MTY1Mjk=