*/ 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:----gdAHIX6jAYvi7CJQgHjauma/9qcttNjrNC8E9xBWcWA2A8uImmK9uH+YibEgkOquExBqhfbmkmMG4WU+KELoKSDMsNCNM42zj0zSFLaLFSdDSxRi4teDl3xD339rUKZe8bZyfBqG0/UnO5q4+3QnWozEEI3m9g1+s2easlG552n1eNI5LQA5A+5il+iK4EY98ZkJUJL6NHLTg0loOhqi3gLsHnzohRFdB2Of0SgpF1aDxFfJSMY5IiXxQ9PSwkOxxIrLCC7BF9wPVTg4dF0DZptS6EBi2NIBCBzVvkv+KjC9VfIJrjch5f3Qr5q3ObFfdHoATIw8K+EI6qVmmKWuLRihy8DSV+K17uXgH8CAaFeuyVIQMzPnQiHhCyjWfc9Oe8WkzaZVTPfOeMtP10O/5+jMf7siF33Pru0ohc2/oowc/c5Va7XcR1xvjH343JcF6ZYaDQiGmjAW0KgHdyvr2JcA4eoikX41nfyZkrwg3RRgb4/m0U1bqa7Ubzt3D9gjKvKqIpRbg04KVXsmmwSUZtMK9GoNUucb7NBpzh4RGf6tg1Leiwr7atvSp8JtwdiNkMnT8JLfZl42LNRqn7OmO/+/3YFmUxQmO47S6+xGi1i7Q8g7FN6SnqzimJui+uL2brqqTZlFiUGQEjl8WXaT41QhxOFDY572+rmlgpIKt3U=----ATTACHMENT:----NDkyOTU1NjgzNTAzNDQ0MCAxMDUzMzYxOTEyOTE3ODEzIDY5NTU2MTg3NzMxODU4NDI=