*/ 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:----oSwOOvqN98ug4xJG4cxFKRuM5c3hzLpE7WFbLv1EwH2DBa5GePUSrD2yEqaP4/nhHjNjJDWEWP6vuy626HA7E7ff8MElibpG3u3bxpoMDWRHcp1GesCwULIhtd44b2Fz3+BAkWEiuj2Zza14Ep//tqp6pmCTkTqtQvs+NGzodnG8L+G+1r9B3R/kAqnLXFM5RyL5oM97H8DxRv3QNGB0PY1z99m4URqvAz6vI9ApWfIBuhRFpY9pT2nOGtUdmGRSdvmJ7l89NbiAk/xTmp747/wn5sSky/UT42BpPTtoXzNX5UKnjnlaipzHghYADDMIUfLW/wgsLPlTeDRJx2MSD82E0JQQyNjbDaz88VJr5bHx81FZJ7UB8+u59H2M+lOj/xU66AQe92TienPDrbYD+qp9xteHU5il4cbR4NkgGYAOV2AKNOYdiXslMomjKAwTxX78BpOJgoGXEg1HTYgh65yzjCpgln0qRoETPQT/bSbXCqw4/fNgOt6HaYOKV18KK5yC34LMbftbPPdvNM5LwQLnoJuqGYwXY8RJZKIH3wMB7YCjshH/lQBh52moIQ0lQI1IsVGGRe04aYh3bJ2saDDzXq7WfYcylNk9Nffs7wp4o1Ob7zWeKmTr+P9LOkfil02RtxcGmh1o8YXekOGsD05lbKIJEzyNgXq6Eurpwqc=----ATTACHMENT:----ODQzMTg5NDYyNzE1MzEzMyA0NjE4ODEyNTUyNjIzNzU2IDkzMjMwOTMxNDQ5MjQzMDk=