stream === null) { $this->stream = fopen('php://temp', 'w+'); } return new ConsoleSectionOutput( $this->stream, $this->consoleSectionOutputs, $this->getVerbosity(), $this->isDecorated(), $this->getFormatter() ); } public function fetch(): string { // Get the main buffer $content = parent::fetch(); // If there's a stream from sections, read that too if ($this->stream !== null) { rewind($this->stream); $streamContent = stream_get_contents($this->stream); if ($streamContent !== false) { $content .= $streamContent; } // Clear the stream for the next call ftruncate($this->stream, 0); rewind($this->stream); } return $content; } }