fix:更新已知bug,优化代码

This commit is contained in:
Ying
2022-11-28 19:11:12 +08:00
parent f6aee95cfc
commit 9445b206a2
1378 changed files with 53759 additions and 20789 deletions

View File

@@ -30,7 +30,7 @@ class ConsoleLogger extends AbstractLogger
public const ERROR = 'error';
private $output;
private $verbosityLevelMap = [
private array $verbosityLevelMap = [
LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
@@ -40,7 +40,7 @@ class ConsoleLogger extends AbstractLogger
LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
];
private $formatLevelMap = [
private array $formatLevelMap = [
LogLevel::EMERGENCY => self::ERROR,
LogLevel::ALERT => self::ERROR,
LogLevel::CRITICAL => self::ERROR,
@@ -50,7 +50,7 @@ class ConsoleLogger extends AbstractLogger
LogLevel::INFO => self::INFO,
LogLevel::DEBUG => self::INFO,
];
private $errored = false;
private bool $errored = false;
public function __construct(OutputInterface $output, array $verbosityLevelMap = [], array $formatLevelMap = [])
{
@@ -61,10 +61,8 @@ class ConsoleLogger extends AbstractLogger
/**
* {@inheritdoc}
*
* @return void
*/
public function log($level, $message, array $context = [])
public function log($level, $message, array $context = []): void
{
if (!isset($this->verbosityLevelMap[$level])) {
throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
@@ -89,10 +87,8 @@ class ConsoleLogger extends AbstractLogger
/**
* Returns true when any messages have been logged at error levels.
*
* @return bool
*/
public function hasErrored()
public function hasErrored(): bool
{
return $this->errored;
}
@@ -110,7 +106,7 @@ class ConsoleLogger extends AbstractLogger
$replacements = [];
foreach ($context as $key => $val) {
if (null === $val || \is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) {
if (null === $val || \is_scalar($val) || $val instanceof \Stringable) {
$replacements["{{$key}}"] = $val;
} elseif ($val instanceof \DateTimeInterface) {
$replacements["{{$key}}"] = $val->format(\DateTime::RFC3339);