Skip to content

Conversation

@sangemaru
Copy link

Summary

Fixes fatal error when running SatisPress with PHP 8.x and psr/log ^3.0.

The log() method signature in SatisPress\Logger must match Psr\Log\AbstractLogger::log() which in psr/log 3.x requires:

  • \Stringable|string type hint for $message parameter
  • void return type

The Error

Fatal error: Declaration of SatisPress\Logger::log($level, $message, array $context = [])
must be compatible with Psr\Log\AbstractLogger::log($level, Stringable|string $message,
array $context = []): void in /path/to/satispress/src/Logger.php on line 73

Changes

  • Updated log() method signature to match PSR-3 v3 interface
  • Cast $message to string before passing to format() method (handles Stringable objects)
  • Updated docblock to reflect new parameter types

Backwards Compatibility

This change maintains backwards compatibility:

  • Still works with psr/log ^1.0 and ^2.0 (union types are valid, just not enforced)
  • The (string) cast handles both string and Stringable inputs correctly

Test Plan

  • Verified fix resolves fatal error on PHP 8.2 with psr/log 3.0
  • Logging functionality works as expected with string messages
  • Logging functionality works with Stringable objects

The log() method signature must match Psr\Log\AbstractLogger::log()
which in psr/log 3.x requires:
- \Stringable|string type hint for $message parameter
- void return type

This fixes fatal errors when running with PHP 8.x and psr/log ^3.0:

Fatal error: Declaration of SatisPress\Logger::log($level, $message,
array $context = []) must be compatible with
Psr\Log\AbstractLogger::log($level, Stringable|string $message,
array $context = []): void
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant