Upgrade framework

This commit is contained in:
2023-11-14 16:54:35 +01:00
parent 1648a5cd42
commit 4fcf6fffcc
10548 changed files with 693138 additions and 466698 deletions

View File

@@ -14,29 +14,23 @@ namespace Symfony\Component\Console\Logger;
use Psr\Log\AbstractLogger;
use Psr\Log\InvalidArgumentException;
use Psr\Log\LogLevel;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* PSR-3 compliant console logger.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @see http://www.php-fig.org/psr/psr-3/
* @see https://www.php-fig.org/psr/psr-3/
*/
class ConsoleLogger extends AbstractLogger
{
const INFO = 'info';
const ERROR = 'error';
public const INFO = 'info';
public const ERROR = 'error';
/**
* @var OutputInterface
*/
private $output;
/**
* @var array
*/
private $verbosityLevelMap = array(
private array $verbosityLevelMap = [
LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
@@ -45,11 +39,8 @@ class ConsoleLogger extends AbstractLogger
LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
);
/**
* @var array
*/
private $formatLevelMap = array(
];
private array $formatLevelMap = [
LogLevel::EMERGENCY => self::ERROR,
LogLevel::ALERT => self::ERROR,
LogLevel::CRITICAL => self::ERROR,
@@ -58,15 +49,10 @@ class ConsoleLogger extends AbstractLogger
LogLevel::NOTICE => self::INFO,
LogLevel::INFO => self::INFO,
LogLevel::DEBUG => self::INFO,
);
private $errored = false;
];
private bool $errored = false;
/**
* @param OutputInterface $output
* @param array $verbosityLevelMap
* @param array $formatLevelMap
*/
public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array())
public function __construct(OutputInterface $output, array $verbosityLevelMap = [], array $formatLevelMap = [])
{
$this->output = $output;
$this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
@@ -76,7 +62,7 @@ class ConsoleLogger extends AbstractLogger
/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = array())
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));
@@ -85,7 +71,7 @@ class ConsoleLogger extends AbstractLogger
$output = $this->output;
// Write to the error output if necessary and available
if ($this->formatLevelMap[$level] === self::ERROR) {
if (self::ERROR === $this->formatLevelMap[$level]) {
if ($this->output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput();
}
@@ -102,7 +88,7 @@ class ConsoleLogger extends AbstractLogger
/**
* Returns true when any messages have been logged at error levels.
*/
public function hasErrored()
public function hasErrored(): bool
{
return $this->errored;
}
@@ -111,23 +97,26 @@ class ConsoleLogger extends AbstractLogger
* Interpolates context values into the message placeholders.
*
* @author PHP Framework Interoperability Group
*
* @param string $message
* @param array $context
*
* @return string
*/
private function interpolate($message, array $context)
private function interpolate(string $message, array $context): string
{
// build a replacement array with braces around the context keys
$replace = array();
if (!str_contains($message, '{')) {
return $message;
}
$replacements = [];
foreach ($context as $key => $val) {
if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) {
$replace[sprintf('{%s}', $key)] = $val;
if (null === $val || \is_scalar($val) || $val instanceof \Stringable) {
$replacements["{{$key}}"] = $val;
} elseif ($val instanceof \DateTimeInterface) {
$replacements["{{$key}}"] = $val->format(\DateTime::RFC3339);
} elseif (\is_object($val)) {
$replacements["{{$key}}"] = '[object '.\get_class($val).']';
} else {
$replacements["{{$key}}"] = '['.\gettype($val).']';
}
}
// interpolate replacement values into the message and return
return strtr($message, $replace);
return strtr($message, $replacements);
}
}