Updates to vendors etc

This commit is contained in:
Chris Hunt
2025-07-11 15:57:48 +01:00
parent d972cbcd0a
commit 8fb6438254
8043 changed files with 248005 additions and 189479 deletions

View File

@@ -21,6 +21,9 @@ use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableCell;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Helper\TreeHelper;
use Symfony\Component\Console\Helper\TreeNode;
use Symfony\Component\Console\Helper\TreeStyle;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\ConsoleSectionOutput;
@@ -40,30 +43,27 @@ class SymfonyStyle extends OutputStyle
{
public const MAX_LINE_LENGTH = 120;
private InputInterface $input;
private OutputInterface $output;
private SymfonyQuestionHelper $questionHelper;
private ProgressBar $progressBar;
private int $lineLength;
private TrimmedBufferOutput $bufferedOutput;
public function __construct(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
public function __construct(
private InputInterface $input,
private OutputInterface $output,
) {
$this->bufferedOutput = new TrimmedBufferOutput(\DIRECTORY_SEPARATOR === '\\' ? 4 : 2, $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);
parent::__construct($this->output = $output);
parent::__construct($output);
}
/**
* Formats a message as a block of text.
*
* @return void
*/
public function block(string|array $messages, ?string $type = null, ?string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = true)
public function block(string|array $messages, ?string $type = null, ?string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = true): void
{
$messages = \is_array($messages) ? array_values($messages) : [$messages];
@@ -72,121 +72,87 @@ class SymfonyStyle extends OutputStyle
$this->newLine();
}
/**
* @return void
*/
public function title(string $message)
public function title(string $message): void
{
$this->autoPrependBlock();
$this->writeln([
sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
sprintf('<comment>%s</>', str_repeat('=', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
\sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
\sprintf('<comment>%s</>', str_repeat('=', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
]);
$this->newLine();
}
/**
* @return void
*/
public function section(string $message)
public function section(string $message): void
{
$this->autoPrependBlock();
$this->writeln([
sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
sprintf('<comment>%s</>', str_repeat('-', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
\sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
\sprintf('<comment>%s</>', str_repeat('-', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
]);
$this->newLine();
}
/**
* @return void
*/
public function listing(array $elements)
public function listing(array $elements): void
{
$this->autoPrependText();
$elements = array_map(fn ($element) => sprintf(' * %s', $element), $elements);
$elements = array_map(fn ($element) => \sprintf(' * %s', $element), $elements);
$this->writeln($elements);
$this->newLine();
}
/**
* @return void
*/
public function text(string|array $message)
public function text(string|array $message): void
{
$this->autoPrependText();
$messages = \is_array($message) ? array_values($message) : [$message];
foreach ($messages as $message) {
$this->writeln(sprintf(' %s', $message));
$this->writeln(\sprintf(' %s', $message));
}
}
/**
* Formats a command comment.
*
* @return void
*/
public function comment(string|array $message)
public function comment(string|array $message): void
{
$this->block($message, null, null, '<fg=default;bg=default> // </>', false, false);
}
/**
* @return void
*/
public function success(string|array $message)
public function success(string|array $message): void
{
$this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
}
/**
* @return void
*/
public function error(string|array $message)
public function error(string|array $message): void
{
$this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true);
}
/**
* @return void
*/
public function warning(string|array $message)
public function warning(string|array $message): void
{
$this->block($message, 'WARNING', 'fg=black;bg=yellow', ' ', true);
}
/**
* @return void
*/
public function note(string|array $message)
public function note(string|array $message): void
{
$this->block($message, 'NOTE', 'fg=yellow', ' ! ');
}
/**
* Formats an info message.
*
* @return void
*/
public function info(string|array $message)
public function info(string|array $message): void
{
$this->block($message, 'INFO', 'fg=green', ' ', true);
}
/**
* @return void
*/
public function caution(string|array $message)
public function caution(string|array $message): void
{
$this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
}
/**
* @return void
*/
public function table(array $headers, array $rows)
public function table(array $headers, array $rows): void
{
$this->createTable()
->setHeaders($headers)
@@ -199,10 +165,8 @@ class SymfonyStyle extends OutputStyle
/**
* Formats a horizontal table.
*
* @return void
*/
public function horizontalTable(array $headers, array $rows)
public function horizontalTable(array $headers, array $rows): void
{
$this->createTable()
->setHorizontal(true)
@@ -221,10 +185,8 @@ class SymfonyStyle extends OutputStyle
* * 'A title'
* * ['key' => 'value']
* * new TableSeparator()
*
* @return void
*/
public function definitionList(string|array|TableSeparator ...$list)
public function definitionList(string|array|TableSeparator ...$list): void
{
$headers = [];
$row = [];
@@ -285,27 +247,18 @@ class SymfonyStyle extends OutputStyle
return $this->askQuestion($questionChoice);
}
/**
* @return void
*/
public function progressStart(int $max = 0)
public function progressStart(int $max = 0): void
{
$this->progressBar = $this->createProgressBar($max);
$this->progressBar->start();
}
/**
* @return void
*/
public function progressAdvance(int $step = 1)
public function progressAdvance(int $step = 1): void
{
$this->getProgressBar()->advance($step);
}
/**
* @return void
*/
public function progressFinish()
public function progressFinish(): void
{
$this->getProgressBar()->finish();
$this->newLine(2);
@@ -366,10 +319,7 @@ class SymfonyStyle extends OutputStyle
return $answer;
}
/**
* @return void
*/
public function writeln(string|iterable $messages, int $type = self::OUTPUT_NORMAL)
public function writeln(string|iterable $messages, int $type = self::OUTPUT_NORMAL): void
{
if (!is_iterable($messages)) {
$messages = [$messages];
@@ -381,10 +331,7 @@ class SymfonyStyle extends OutputStyle
}
}
/**
* @return void
*/
public function write(string|iterable $messages, bool $newline = false, int $type = self::OUTPUT_NORMAL)
public function write(string|iterable $messages, bool $newline = false, int $type = self::OUTPUT_NORMAL): void
{
if (!is_iterable($messages)) {
$messages = [$messages];
@@ -396,10 +343,7 @@ class SymfonyStyle extends OutputStyle
}
}
/**
* @return void
*/
public function newLine(int $count = 1)
public function newLine(int $count = 1): void
{
parent::newLine($count);
$this->bufferedOutput->write(str_repeat("\n", $count));
@@ -428,6 +372,24 @@ class SymfonyStyle extends OutputStyle
?? throw new RuntimeException('The ProgressBar is not started.');
}
/**
* @param iterable<string, iterable|string|TreeNode> $nodes
*/
public function tree(iterable $nodes, string $root = ''): void
{
$this->createTree($nodes, $root)->render();
}
/**
* @param iterable<string, iterable|string|TreeNode> $nodes
*/
public function createTree(iterable $nodes, string $root = ''): TreeHelper
{
$output = $this->output instanceof ConsoleOutputInterface ? $this->output->section() : $this->output;
return TreeHelper::createTree($output, $root, $nodes, TreeStyle::default());
}
private function autoPrependBlock(): void
{
$chars = substr(str_replace(\PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
@@ -463,7 +425,7 @@ class SymfonyStyle extends OutputStyle
$lines = [];
if (null !== $type) {
$type = sprintf('[%s] ', $type);
$type = \sprintf('[%s] ', $type);
$indentLength = Helper::width($type);
$lineIndentation = str_repeat(' ', $indentLength);
}
@@ -505,7 +467,7 @@ class SymfonyStyle extends OutputStyle
$line .= str_repeat(' ', max($this->lineLength - Helper::width(Helper::removeDecoration($this->getFormatter(), $line)), 0));
if ($style) {
$line = sprintf('<%s>%s</>', $style, $line);
$line = \sprintf('<%s>%s</>', $style, $line);
}
}