Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #151 make gelf php compatible with psr log 1.0 #152

Conversation

Ocramius
Copy link
Contributor

Fixes #151

This patch is targeting master, but is aimed at 2.0.1 (to be released as a patch).

Also very happy to send a follow-up after a 2.0.1 release, to drop psr/log:^1 support, and re-introduce the type declarations :-)

…ration

Fixes bzikarsky#151

This patch makes the component compatible with `psr/log:^1` again.

Ref: bzikarsky#151

> Heyo, just noticed this incompatibility while upgrading:
>
> ```
> PHP Fatal error:  Declaration of Gelf\Logger::log($level, Stringable|string $message, array $context = []): void must be compatible with Psr\Log\LoggerInterface::log($level, $message, array $context = [])
> ```
>
> Practically, the `Stringable|string` is incompatible with `Psrl\Log\LoggerInterface` in `psr/log:1.0.0`:
>
> https://github.com/php-fig/log/blob/fe0936ee26643249e916849d48e3a51d5f5e278b/Psr/Log/LoggerInterface.php#L113
>
> ```
>     /**
>      * Logs with an arbitrary level.
>      *
>      * @param mixed $level
>      * @param string $message
>      * @param array $context
>      * @return null
>      */
>     public function log($level, $message, array $context = array());
> ```
>
> https://github.com/bzikarsky/gelf-php/blob/a8f68846ff4db5f1942172bb428465be7ebb768c/src/Gelf/Logger.php#L42-L44

Ref: https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters
@bzikarsky bzikarsky merged commit 29ef48f into bzikarsky:master May 23, 2023
10 checks passed
@bzikarsky
Copy link
Owner

Thanks! 😊

@bzikarsky
Copy link
Owner

Tagged 2.0.1

@Ocramius
Copy link
Contributor Author

Awesome, thanks!

@Ocramius Ocramius deleted the fix/#151-make-gelf-php-compatible-with-psr-log-1.0 branch May 23, 2023 14:55
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.

gelf-php 2.0.0 incompatible with psr/log:^1 due to method signature being too strict
2 participants