namespace Symfony\Component\Console\Style;
-use Symfony\Component\Console\Application;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Helper\Helper;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Question\Question;
+use Symfony\Component\Console\Terminal;
/**
* Output decorator helpers for the Symfony Style Guide.
$this->input = $input;
$this->bufferedOutput = new BufferedOutput($output->getVerbosity(), false, clone $output->getFormatter());
// Windows cmd wraps lines as soon as the terminal width is reached, whether there are following chars or not.
- $this->lineLength = min($this->getTerminalWidth() - (int) (DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
+ $width = (new Terminal())->getWidth() ?: self::MAX_LINE_LENGTH;
+ $this->lineLength = min($width - (int) (DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
parent::__construct($output);
}
return $this->progressBar;
}
- private function getTerminalWidth()
- {
- $application = new Application();
- $dimensions = $application->getTerminalDimensions();
-
- return $dimensions[0] ?: self::MAX_LINE_LENGTH;
- }
-
private function autoPrependBlock()
{
$chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);