Skip to content

Issue/599 Allow psr/log 3 next to psr/log 2 - #604

Merged
armanist merged 2 commits into
quantum-php:masterfrom
armanist:issue/599-allow-psr-log-3
Oct 23, 2026
Merged

armanist merged 2 commits into
quantum-php:masterfrom
armanist:issue/599-allow-psr-log-3

Conversation

@armanist

Copy link
Copy Markdown
Collaborator

Closes #599. Part of #595. The changelog entry is written in a final pull request, after the sub-issues.

What changed

  • composer.json requires psr/log ^2.0 || ^3.0 instead of ^2.0.
  • The nine PSR-3 methods of Logger (emergency, alert, critical, error, warning, notice, info, debug and log) declare string|Stringable $message.

Why

Applications that already use psr/log 3, for example through Monolog 3, could not install Quantum. The constraint was one reason; symfony/console 5.4 was the other, because it declares a conflict with psr/log 3 or newer. The console is on 6.4 since #596, so Composer can now resolve psr/log 3.

psr/log 2 and 3 declare the same parameter type, string|\Stringable, and differ only in the : void return type, which Logger already has. The native type on our methods therefore fits both versions.

Breaking changes

  • None. The adapters' report() already accepted only string|Stringable, so the Logger methods only state what happened further down.

Testing

  • No new tests. The Logger, Tracer, Mailer, Debugger, Cron and Console tests pass with psr/log 3.0.2 and with 2.0.0, and so do PHPStan, PHP-CS-Fixer and Rector. All class files load without deprecations on both.
  • The full suite on PHP 8.1 with psr/log 3.0.2 gives the same results as before.
  • Known gap: CI resolves the newest version, so it exercises psr/log 3 only. Version 2 was checked by hand with composer update psr/log --with psr/log:^2.0.

Notes for reviewers

  • While checking this, I found that logger()->info([...]) with an array, which the Logger docs describe, throws a TypeError because the adapters' report() accepts only string|Stringable. That is independent of this change and tracked separately.

composer.json accepts psr/log ^2.0 || ^3.0. psr/log 3 could not be installed while symfony/console 5.4 conflicted with it; the console is on 6.4 now. Both versions declare string|\Stringable for the message, so the Logger methods declare it natively too.
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

emergency(), alert() and critical() were never called by a test, because the global helpers cover only the other five levels. The tests check that each level method reports its message with its level, and that a Stringable message is accepted.
@quantum-php quantum-php deleted a comment from coderabbitai Bot Oct 23, 2026
@armanist
armanist merged commit 84fb2ae into quantum-php:master Oct 23, 2026
7 checks passed
@armanist
armanist deleted the issue/599-allow-psr-log-3 branch October 23, 2026 15:06
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.

Allow psr/log 3 next to psr/log 2

1 participant