mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-27 00:25:50 +03:00
[GH-ISSUE #1957] Invalid composer require for psr/log #843
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#843
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hpsam on GitHub (Mar 19, 2025).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1957
Monolog version 3 / PHP 8.3 / psr/log 2.x
In composer.json there is this require : "psr/log": "^2.0 || ^3.0".
But Monolog\Logger class (since v3.0.0) is not compatible with Psr\Log\LoggerInterface (2.x). This result in a PHP Fatal error.
PHP Fatal error: Declaration of Monolog\Logger::emergency(Stringable|string $message, array $context = []): void must be compatible with Psr\Log\LoggerInterface::emergency($message, array $context = []) in /home/ard/www/typo3conf/ext-ard/ard_composerm/vendor/monolog/monolog/src/Monolog/Logger.php on line 683PHP Stop on first incompatible method, but all similar methods have the same problem. They declare a type on $message but interface don't do it.
Monolog\Logger class can't be more restrictive than the interface. Class could be less restrictive than interface.
2 solutions :
@Seldaek commented on GitHub (Mar 20, 2025):
I think you have psr/log 1.x there. psr/log 2.x does have the same signature as monolog (except for the void return type which was added in 3.x) https://github.com/php-fig/log/blob/2.0.0/src/LoggerInterface.php#L30
@hpsam commented on GitHub (Mar 21, 2025):
You are right, an other dependency downgrade psr/log in our project from 1.x to 2.x and I have not seen it.
Thanks