mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
N°8834 - Add compatibility with PHP 8.4 (#819)
* N°8834 - Add compatibility with PHP 8.4 * Rollback of scssphp/scssphp version upgrade due to compilation error
This commit is contained in:
@@ -20,7 +20,7 @@ class DebugLoggerConfigurator
|
||||
{
|
||||
private ?object $processor = null;
|
||||
|
||||
public function __construct(callable $processor, bool $enable = null)
|
||||
public function __construct(callable $processor, ?bool $enable = null)
|
||||
{
|
||||
if ($enable ?? !\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
|
||||
$this->processor = \is_object($processor) ? $processor : $processor(...);
|
||||
|
||||
@@ -33,14 +33,14 @@ interface DebugLoggerInterface
|
||||
* timestamp_rfc3339: string,
|
||||
* }>
|
||||
*/
|
||||
public function getLogs(Request $request = null);
|
||||
public function getLogs(?Request $request = null);
|
||||
|
||||
/**
|
||||
* Returns the number of errors.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countErrors(Request $request = null);
|
||||
public function countErrors(?Request $request = null);
|
||||
|
||||
/**
|
||||
* Removes all log records.
|
||||
|
||||
@@ -57,7 +57,7 @@ class Logger extends AbstractLogger implements DebugLoggerInterface
|
||||
/**
|
||||
* @param string|resource|null $output
|
||||
*/
|
||||
public function __construct(string $minLevel = null, $output = null, callable $formatter = null, private readonly ?RequestStack $requestStack = null, bool $debug = false)
|
||||
public function __construct(?string $minLevel = null, $output = null, ?callable $formatter = null, private readonly ?RequestStack $requestStack = null, bool $debug = false)
|
||||
{
|
||||
if (null === $minLevel) {
|
||||
$minLevel = null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING;
|
||||
@@ -74,13 +74,13 @@ class Logger extends AbstractLogger implements DebugLoggerInterface
|
||||
}
|
||||
|
||||
if (!isset(self::LEVELS[$minLevel])) {
|
||||
throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $minLevel));
|
||||
throw new InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $minLevel));
|
||||
}
|
||||
|
||||
$this->minLevelIndex = self::LEVELS[$minLevel];
|
||||
$this->formatter = null !== $formatter ? $formatter(...) : $this->format(...);
|
||||
if ($output && false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) {
|
||||
throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output));
|
||||
if ($output && false === $this->handle = \is_string($output) ? @fopen($output, 'a') : $output) {
|
||||
throw new InvalidArgumentException(\sprintf('Unable to open "%s".', $output));
|
||||
}
|
||||
$this->debug = $debug;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ class Logger extends AbstractLogger implements DebugLoggerInterface
|
||||
public function log($level, $message, array $context = []): void
|
||||
{
|
||||
if (!isset(self::LEVELS[$level])) {
|
||||
throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
|
||||
throw new InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $level));
|
||||
}
|
||||
|
||||
if (self::LEVELS[$level] < $this->minLevelIndex) {
|
||||
@@ -112,7 +112,7 @@ class Logger extends AbstractLogger implements DebugLoggerInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function getLogs(Request $request = null): array
|
||||
public function getLogs(?Request $request = null): array
|
||||
{
|
||||
if ($request) {
|
||||
return $this->logs[spl_object_id($request)] ?? [];
|
||||
@@ -121,7 +121,7 @@ class Logger extends AbstractLogger implements DebugLoggerInterface
|
||||
return array_merge(...array_values($this->logs));
|
||||
}
|
||||
|
||||
public function countErrors(Request $request = null): int
|
||||
public function countErrors(?Request $request = null): int
|
||||
{
|
||||
if ($request) {
|
||||
return $this->errorCount[spl_object_id($request)] ?? 0;
|
||||
@@ -155,7 +155,7 @@ class Logger extends AbstractLogger implements DebugLoggerInterface
|
||||
$message = strtr($message, $replacements);
|
||||
}
|
||||
|
||||
$log = sprintf('[%s] %s', $level, $message);
|
||||
$log = \sprintf('[%s] %s', $level, $message);
|
||||
if ($prefixDate) {
|
||||
$log = date(\DateTimeInterface::RFC3339).' '.$log;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user