Update vendored libs

This commit is contained in:
Frédéric Guillot
2020-06-08 22:46:20 -07:00
parent dfb0a2d915
commit f60e4a0c59
292 changed files with 9402 additions and 9487 deletions

View File

@@ -46,7 +46,7 @@ class SymfonyStyle extends OutputStyle
$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.
$width = (new Terminal())->getWidth() ?: self::MAX_LINE_LENGTH;
$this->lineLength = min($width - (int) (DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
$this->lineLength = min($width - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
parent::__construct($output);
}
@@ -63,7 +63,7 @@ class SymfonyStyle extends OutputStyle
*/
public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = true)
{
$messages = is_array($messages) ? array_values($messages) : array($messages);
$messages = \is_array($messages) ? array_values($messages) : [$messages];
$this->autoPrependBlock();
$this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, $escape));
@@ -76,10 +76,10 @@ class SymfonyStyle extends OutputStyle
public function title($message)
{
$this->autoPrependBlock();
$this->writeln(array(
$this->writeln([
sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
sprintf('<comment>%s</>', str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
));
]);
$this->newLine();
}
@@ -89,10 +89,10 @@ class SymfonyStyle extends OutputStyle
public function section($message)
{
$this->autoPrependBlock();
$this->writeln(array(
$this->writeln([
sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
sprintf('<comment>%s</>', str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
));
]);
$this->newLine();
}
@@ -117,7 +117,7 @@ class SymfonyStyle extends OutputStyle
{
$this->autoPrependText();
$messages = is_array($message) ? array_values($message) : array($message);
$messages = \is_array($message) ? array_values($message) : [$message];
foreach ($messages as $message) {
$this->writeln(sprintf(' %s', $message));
}
@@ -269,7 +269,7 @@ class SymfonyStyle extends OutputStyle
{
$progressBar = parent::createProgressBar($max);
if ('\\' !== DIRECTORY_SEPARATOR) {
if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
$progressBar->setEmptyBarCharacter('░'); // light shade character \u2591
$progressBar->setProgressCharacter('');
$progressBar->setBarCharacter('▓'); // dark shade character \u2593
@@ -279,7 +279,7 @@ class SymfonyStyle extends OutputStyle
}
/**
* @return string
* @return mixed
*/
public function askQuestion(Question $question)
{
@@ -306,8 +306,14 @@ class SymfonyStyle extends OutputStyle
*/
public function writeln($messages, $type = self::OUTPUT_NORMAL)
{
parent::writeln($messages, $type);
$this->bufferedOutput->writeln($this->reduceBuffer($messages), $type);
if (!is_iterable($messages)) {
$messages = [$messages];
}
foreach ($messages as $message) {
parent::writeln($message, $type);
$this->writeBuffer($message, true, $type);
}
}
/**
@@ -315,8 +321,14 @@ class SymfonyStyle extends OutputStyle
*/
public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
{
parent::write($messages, $newline, $type);
$this->bufferedOutput->write($this->reduceBuffer($messages), $newline, $type);
if (!is_iterable($messages)) {
$messages = [$messages];
}
foreach ($messages as $message) {
parent::write($message, $newline, $type);
$this->writeBuffer($message, $newline, $type);
}
}
/**
@@ -338,10 +350,7 @@ class SymfonyStyle extends OutputStyle
return new self($this->input, $this->getErrorOutput());
}
/**
* @return ProgressBar
*/
private function getProgressBar()
private function getProgressBar(): ProgressBar
{
if (!$this->progressBar) {
throw new RuntimeException('The ProgressBar is not started.');
@@ -350,18 +359,20 @@ class SymfonyStyle extends OutputStyle
return $this->progressBar;
}
private function autoPrependBlock()
private function autoPrependBlock(): void
{
$chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
if (!isset($chars[0])) {
return $this->newLine(); //empty history, so we should start with a new line.
$this->newLine(); //empty history, so we should start with a new line.
return;
}
//Prepend new line for each non LF chars (This means no blank line was output before)
$this->newLine(2 - substr_count($chars, "\n"));
}
private function autoPrependText()
private function autoPrependText(): void
{
$fetched = $this->bufferedOutput->fetch();
//Prepend new line if last char isn't EOL:
@@ -370,24 +381,22 @@ class SymfonyStyle extends OutputStyle
}
}
private function reduceBuffer($messages)
private function writeBuffer(string $message, bool $newLine, int $type): void
{
// We need to know if the two last chars are PHP_EOL
// Preserve the last 4 chars inserted (PHP_EOL on windows is two chars) in the history buffer
return array_map(function ($value) {
return substr($value, -4);
}, array_merge(array($this->bufferedOutput->fetch()), (array) $messages));
$this->bufferedOutput->write(substr($message, -4), $newLine, $type);
}
private function createBlock($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = false)
private function createBlock(iterable $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = false)
{
$indentLength = 0;
$prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix);
$lines = array();
$lines = [];
if (null !== $type) {
$type = sprintf('[%s] ', $type);
$indentLength = strlen($type);
$indentLength = \strlen($type);
$lineIndentation = str_repeat(' ', $indentLength);
}
@@ -399,7 +408,7 @@ class SymfonyStyle extends OutputStyle
$lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true)));
if (count($messages) > 1 && $key < count($messages) - 1) {
if (\count($messages) > 1 && $key < \count($messages) - 1) {
$lines[] = '';
}
}