tboothman / imdbphp

PHP library for retrieving film and tv information from IMDb
247 stars 84 forks source link

Support for psr/log 2.0 and 3.0 #300

Closed DariusIII closed 1 year ago

DariusIII commented 1 year ago

Add support for psr/log 2.0 and 3.0 versions

tboothman commented 1 year ago

This works for psr-3 v2 but not 3. If you use 3 it errors:

$ php src/index.php
PHP Fatal error:  Declaration of Imdb\Logger::emergency($message, array $context = []) must be compatible with Psr\Log\LoggerInterface::emergency(Stringable|string $message, array $context = []): void in /imdbphp/src/Imdb/Logger.php on line 27

I'm going to add in the option of v2 since that's compatible and should hopefully help people out when using newer frameworks. Making v3 work would mean dropping support for < php 8

tboothman commented 1 year ago

Here's the change: https://github.com/tboothman/imdbphp/commit/1cfb8ff9c8569a4dd7c8e667c0eaa781a4d7e64c Thanks for kicking me into looking at this again. I was pretty sure there was nothing to be done as type hints in psr/log would cause it to not match .. but it turns out php's not that bothered about inconsistent params.