Skip to content

Commit

Permalink
Fix errors reported by phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
z4kn4fein committed Aug 23, 2024
1 parent f7c46da commit afa7da6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
19 changes: 10 additions & 9 deletions src/Log/DefaultLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,48 @@

class DefaultLogger implements LoggerInterface
{
public function emergency($message, array $context = []): void
public function emergency(string|Stringable $message, array $context = []): void
{
self::logMsg(LogLevel::EMERGENCY, $message, $context);
}

public function alert($message, array $context = []): void
public function alert(string|Stringable $message, array $context = []): void
{
self::logMsg(LogLevel::ALERT, $message, $context);
}

public function critical($message, array $context = []): void
public function critical(string|Stringable $message, array $context = []): void
{
self::logMsg(LogLevel::CRITICAL, $message, $context);
}

public function error($message, array $context = []): void
public function error(string|Stringable $message, array $context = []): void
{
self::logMsg(LogLevel::ERROR, $message, $context);
}

public function warning($message, array $context = []): void
public function warning(string|Stringable $message, array $context = []): void
{
self::logMsg(LogLevel::WARNING, $message, $context);
}

public function notice($message, array $context = []): void
public function notice(string|Stringable $message, array $context = []): void
{
self::logMsg(LogLevel::NOTICE, $message, $context);
}

public function info($message, array $context = []): void
public function info(string|Stringable $message, array $context = []): void
{
self::logMsg(LogLevel::INFO, $message, $context);
}

public function debug($message, array $context = []): void
public function debug(string|Stringable $message, array $context = []): void
{
self::logMsg(LogLevel::DEBUG, $message, $context);
}

public function log($level, $message, array $context = []): void
/** @phpstan-ignore-next-line */
public function log($level, string|Stringable $message, array $context = []): void

Check failure on line 55 in src/Log/DefaultLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 55.

Check failure on line 55 in src/Log/DefaultLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 55.

Check failure on line 55 in src/Log/DefaultLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 55.

Check failure on line 55 in src/Log/DefaultLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 55.

Check failure on line 55 in src/Log/DefaultLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 55.

Check failure on line 55 in src/Log/DefaultLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 55.

Check failure on line 55 in src/Log/DefaultLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 55.

Check failure on line 55 in src/Log/DefaultLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 55.

Check failure on line 55 in src/Log/DefaultLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 55.

Check failure on line 55 in src/Log/DefaultLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 55.

Check failure on line 55 in src/Log/DefaultLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 55.

Check failure on line 55 in src/Log/DefaultLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 55.
{
// Do nothing, only the leveled methods should be used.
}
Expand Down
19 changes: 10 additions & 9 deletions src/Log/InternalLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
private readonly Hooks $hooks
) {}

public function emergency($message, array $context = []): void
public function emergency(string|Stringable $message, array $context = []): void
{
$this->hooks->fireOnError(self::format($message, $context), $context['exception'] ?? null);
if ($this->shouldLog(LogLevel::EMERGENCY, $context)) {
Expand All @@ -35,7 +35,7 @@ public function emergency($message, array $context = []): void
}
}

public function alert($message, array $context = []): void
public function alert(string|Stringable $message, array $context = []): void
{
$this->hooks->fireOnError(self::format($message, $context), $context['exception'] ?? null);
if ($this->shouldLog(LogLevel::ALERT, $context)) {
Expand All @@ -44,7 +44,7 @@ public function alert($message, array $context = []): void
}
}

public function critical($message, array $context = []): void
public function critical(string|Stringable $message, array $context = []): void
{
$this->hooks->fireOnError(self::format($message, $context), $context['exception'] ?? null);
if ($this->shouldLog(LogLevel::CRITICAL, $context)) {
Expand All @@ -53,7 +53,7 @@ public function critical($message, array $context = []): void
}
}

public function error($message, array $context = []): void
public function error(string|Stringable $message, array $context = []): void
{
$this->hooks->fireOnError(self::format($message, $context), $context['exception'] ?? null);
if ($this->shouldLog(LogLevel::ERROR, $context)) {
Expand All @@ -62,39 +62,40 @@ public function error($message, array $context = []): void
}
}

public function warning($message, array $context = []): void
public function warning(string|Stringable $message, array $context = []): void
{
if ($this->shouldLog(LogLevel::WARNING, $context)) {
$enriched = $this->enrichMessage($message, $context);
$this->logger->warning($enriched, $context);
}
}

public function notice($message, array $context = []): void
public function notice(string|Stringable $message, array $context = []): void
{
if ($this->shouldLog(LogLevel::NOTICE, $context)) {
$enriched = $this->enrichMessage($message, $context);
$this->logger->notice($enriched, $context);
}
}

public function info($message, array $context = []): void
public function info(string|Stringable $message, array $context = []): void
{
if ($this->shouldLog(LogLevel::INFO, $context)) {
$enriched = $this->enrichMessage($message, $context);
$this->logger->info($enriched, $context);
}
}

public function debug($message, array $context = []): void
public function debug(string|Stringable $message, array $context = []): void
{
if ($this->shouldLog(LogLevel::DEBUG, $context)) {
$enriched = $this->enrichMessage($message, $context);
$this->logger->debug($enriched, $context);
}
}

public function log($level, $message, array $context = []): void
/** @phpstan-ignore-next-line */
public function log($level, string|Stringable $message, array $context = []): void

Check failure on line 98 in src/Log/InternalLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 98.

Check failure on line 98 in src/Log/InternalLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 98.

Check failure on line 98 in src/Log/InternalLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 98.

Check failure on line 98 in src/Log/InternalLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 98.

Check failure on line 98 in src/Log/InternalLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 98.

Check failure on line 98 in src/Log/InternalLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 98.

Check failure on line 98 in src/Log/InternalLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 98.

Check failure on line 98 in src/Log/InternalLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 98.

Check failure on line 98 in src/Log/InternalLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 98.

Check failure on line 98 in src/Log/InternalLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 98.

Check failure on line 98 in src/Log/InternalLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 98.

Check failure on line 98 in src/Log/InternalLogger.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 98.
{
// Do nothing, only the leveled methods should be used.
}
Expand Down

0 comments on commit afa7da6

Please sign in to comment.