fix:更新已知bug,优化代码
This commit is contained in:
@@ -32,19 +32,19 @@ class ProgressIndicator
|
||||
];
|
||||
|
||||
private $output;
|
||||
private $startTime;
|
||||
private $format;
|
||||
private $message;
|
||||
private $indicatorValues;
|
||||
private $indicatorCurrent;
|
||||
private $indicatorChangeInterval;
|
||||
private $indicatorUpdateTime;
|
||||
private $started = false;
|
||||
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
|
||||
@@ -146,10 +146,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 +159,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;
|
||||
}
|
||||
@@ -229,6 +221,9 @@ class ProgressIndicator
|
||||
return round(microtime(true) * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, \Closure>
|
||||
*/
|
||||
private static function initPlaceholderFormatters(): array
|
||||
{
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user