package and depencies

This commit is contained in:
RafficMohammed
2023-01-08 02:57:24 +05:30
parent d5332eb421
commit 1d54b8bc7f
4309 changed files with 193331 additions and 172289 deletions

View File

@@ -31,20 +31,20 @@ class ProgressIndicator
'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
];
private $output;
private $startTime;
private $format;
private $message;
private $indicatorValues;
private $indicatorCurrent;
private $indicatorChangeInterval;
private $indicatorUpdateTime;
private $started = false;
private OutputInterface $output;
private int $startTime;
private ?string $format = null;
private ?string $message = null;
private array $indicatorValues;
private int $indicatorCurrent;
private int $indicatorChangeInterval;
private float $indicatorUpdateTime;
private bool $started = false;
/**
* @var array<string, callable>
*/
private static $formatters;
private static array $formatters;
/**
* @param int $indicatorChangeInterval Change interval in milliseconds
@@ -54,14 +54,8 @@ class ProgressIndicator
{
$this->output = $output;
if (null === $format) {
$format = $this->determineBestFormat();
}
if (null === $indicatorValues) {
$indicatorValues = ['-', '\\', '|', '/'];
}
$format ??= $this->determineBestFormat();
$indicatorValues ??= ['-', '\\', '|', '/'];
$indicatorValues = array_values($indicatorValues);
if (2 > \count($indicatorValues)) {
@@ -146,10 +140,8 @@ class ProgressIndicator
/**
* Gets the format for a given name.
*
* @return string|null
*/
public static function getFormatDefinition(string $name)
public static function getFormatDefinition(string $name): ?string
{
return self::FORMATS[$name] ?? null;
}
@@ -161,23 +153,17 @@ class ProgressIndicator
*/
public static function setPlaceholderFormatterDefinition(string $name, callable $callable)
{
if (!self::$formatters) {
self::$formatters = self::initPlaceholderFormatters();
}
self::$formatters ??= self::initPlaceholderFormatters();
self::$formatters[$name] = $callable;
}
/**
* Gets the placeholder formatter for a given name (including the delimiter char like %).
*
* @return callable|null
*/
public static function getPlaceholderFormatterDefinition(string $name)
public static function getPlaceholderFormatterDefinition(string $name): ?callable
{
if (!self::$formatters) {
self::$formatters = self::initPlaceholderFormatters();
}
self::$formatters ??= self::initPlaceholderFormatters();
return self::$formatters[$name] ?? null;
}
@@ -199,16 +185,13 @@ class ProgressIndicator
private function determineBestFormat(): string
{
switch ($this->output->getVerbosity()) {
return match ($this->output->getVerbosity()) {
// OutputInterface::VERBOSITY_QUIET: display is disabled anyway
case OutputInterface::VERBOSITY_VERBOSE:
return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi';
case OutputInterface::VERBOSITY_VERY_VERBOSE:
case OutputInterface::VERBOSITY_DEBUG:
return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi';
default:
return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi';
}
OutputInterface::VERBOSITY_VERBOSE => $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi',
OutputInterface::VERBOSITY_VERY_VERBOSE,
OutputInterface::VERBOSITY_DEBUG => $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi',
default => $this->output->isDecorated() ? 'normal' : 'normal_no_ansi',
};
}
/**
@@ -229,6 +212,9 @@ class ProgressIndicator
return round(microtime(true) * 1000);
}
/**
* @return array<string, \Closure>
*/
private static function initPlaceholderFormatters(): array
{
return [