fix:更新已知bug,优化代码
This commit is contained in:
34
vendor/symfony/console/Helper/Helper.php
vendored
34
vendor/symfony/console/Helper/Helper.php
vendored
@@ -34,25 +34,11 @@ abstract class Helper implements HelperInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getHelperSet()
|
||||
public function getHelperSet(): ?HelperSet
|
||||
{
|
||||
return $this->helperSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length of a string, using mb_strwidth if it is available.
|
||||
*
|
||||
* @deprecated since Symfony 5.3
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function strlen(?string $string)
|
||||
{
|
||||
trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::width() or Helper::length() instead.', __METHOD__);
|
||||
|
||||
return self::width($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of a string, using mb_strwidth if it is available.
|
||||
* The width is how many characters positions the string will use.
|
||||
@@ -93,10 +79,8 @@ abstract class Helper implements HelperInterface
|
||||
|
||||
/**
|
||||
* Returns the subset of a string, using mb_substr if it is available.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function substr(?string $string, int $from, int $length = null)
|
||||
public static function substr(?string $string, int $from, int $length = null): string
|
||||
{
|
||||
$string ?? $string = '';
|
||||
|
||||
@@ -107,7 +91,7 @@ abstract class Helper implements HelperInterface
|
||||
return mb_substr($string, $from, $length, $encoding);
|
||||
}
|
||||
|
||||
public static function formatTime($secs)
|
||||
public static function formatTime(int|float $secs)
|
||||
{
|
||||
static $timeFormats = [
|
||||
[0, '< 1 sec'],
|
||||
@@ -153,16 +137,6 @@ abstract class Helper implements HelperInterface
|
||||
return sprintf('%d B', $memory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 5.3
|
||||
*/
|
||||
public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
|
||||
{
|
||||
trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::removeDecoration() instead.', __METHOD__);
|
||||
|
||||
return self::width(self::removeDecoration($formatter, $string));
|
||||
}
|
||||
|
||||
public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
|
||||
{
|
||||
$isDecorated = $formatter->isDecorated();
|
||||
@@ -171,6 +145,8 @@ abstract class Helper implements HelperInterface
|
||||
$string = $formatter->format($string ?? '');
|
||||
// remove already formatted characters
|
||||
$string = preg_replace("/\033\[[^m]*m/", '', $string ?? '');
|
||||
// remove terminal hyperlinks
|
||||
$string = preg_replace('/\\033]8;[^;]*;[^\\033]*\\033\\\\/', '', $string ?? '');
|
||||
$formatter->setDecorated($isDecorated);
|
||||
|
||||
return $string;
|
||||
|
||||
Reference in New Issue
Block a user