fix:更新已知bug,优化代码
This commit is contained in:
62
vendor/symfony/console/Helper/ProgressBar.php
vendored
62
vendor/symfony/console/Helper/ProgressBar.php
vendored
@@ -36,32 +36,32 @@ final class ProgressBar
|
||||
private const FORMAT_DEBUG_NOMAX = 'debug_nomax';
|
||||
private const FORMAT_NORMAL_NOMAX = 'normal_nomax';
|
||||
|
||||
private $barWidth = 28;
|
||||
private $barChar;
|
||||
private $emptyBarChar = '-';
|
||||
private $progressChar = '>';
|
||||
private $format;
|
||||
private $internalFormat;
|
||||
private $redrawFreq = 1;
|
||||
private $writeCount;
|
||||
private $lastWriteTime;
|
||||
private $minSecondsBetweenRedraws = 0;
|
||||
private $maxSecondsBetweenRedraws = 1;
|
||||
private int $barWidth = 28;
|
||||
private string $barChar;
|
||||
private string $emptyBarChar = '-';
|
||||
private string $progressChar = '>';
|
||||
private ?string $format = null;
|
||||
private ?string $internalFormat = null;
|
||||
private ?int $redrawFreq = 1;
|
||||
private int $writeCount = 0;
|
||||
private float $lastWriteTime = 0;
|
||||
private float $minSecondsBetweenRedraws = 0;
|
||||
private float $maxSecondsBetweenRedraws = 1;
|
||||
private $output;
|
||||
private $step = 0;
|
||||
private $max;
|
||||
private $startTime;
|
||||
private $stepWidth;
|
||||
private $percent = 0.0;
|
||||
private $formatLineCount;
|
||||
private $messages = [];
|
||||
private $overwrite = true;
|
||||
private int $step = 0;
|
||||
private ?int $max = null;
|
||||
private int $startTime;
|
||||
private int $stepWidth;
|
||||
private float $percent = 0.0;
|
||||
private int $formatLineCount;
|
||||
private array $messages = [];
|
||||
private bool $overwrite = true;
|
||||
private $terminal;
|
||||
private $previousMessage;
|
||||
private ?string $previousMessage = null;
|
||||
private $cursor;
|
||||
|
||||
private static $formatters;
|
||||
private static $formats;
|
||||
private static array $formatters;
|
||||
private static array $formats;
|
||||
|
||||
/**
|
||||
* @param int $max Maximum steps (0 if unknown)
|
||||
@@ -103,9 +103,7 @@ final class ProgressBar
|
||||
*/
|
||||
public static function setPlaceholderFormatterDefinition(string $name, callable $callable): void
|
||||
{
|
||||
if (!self::$formatters) {
|
||||
self::$formatters = self::initPlaceholderFormatters();
|
||||
}
|
||||
self::$formatters ??= self::initPlaceholderFormatters();
|
||||
|
||||
self::$formatters[$name] = $callable;
|
||||
}
|
||||
@@ -117,9 +115,7 @@ final class ProgressBar
|
||||
*/
|
||||
public static function getPlaceholderFormatterDefinition(string $name): ?callable
|
||||
{
|
||||
if (!self::$formatters) {
|
||||
self::$formatters = self::initPlaceholderFormatters();
|
||||
}
|
||||
self::$formatters ??= self::initPlaceholderFormatters();
|
||||
|
||||
return self::$formatters[$name] ?? null;
|
||||
}
|
||||
@@ -134,9 +130,7 @@ final class ProgressBar
|
||||
*/
|
||||
public static function setFormatDefinition(string $name, string $format): void
|
||||
{
|
||||
if (!self::$formats) {
|
||||
self::$formats = self::initFormats();
|
||||
}
|
||||
self::$formats ??= self::initFormats();
|
||||
|
||||
self::$formats[$name] = $format;
|
||||
}
|
||||
@@ -148,9 +142,7 @@ final class ProgressBar
|
||||
*/
|
||||
public static function getFormatDefinition(string $name): ?string
|
||||
{
|
||||
if (!self::$formats) {
|
||||
self::$formats = self::initFormats();
|
||||
}
|
||||
self::$formats ??= self::initFormats();
|
||||
|
||||
return self::$formats[$name] ?? null;
|
||||
}
|
||||
@@ -574,6 +566,8 @@ final class ProgressBar
|
||||
|
||||
private function buildLine(): string
|
||||
{
|
||||
\assert(null !== $this->format);
|
||||
|
||||
$regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
|
||||
$callback = function ($matches) {
|
||||
if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
|
||||
|
||||
Reference in New Issue
Block a user