Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services
https://seldaek.github.io/monolog/
MIT License
21.05k stars 1.9k forks source link

Fix return type `JsonFormatter::normalizeException()` #1924

Closed ro0NL closed 2 weeks ago

ro0NL commented 2 weeks ago

I dont see how normalizeException can return a string.

Seldaek commented 2 weeks ago

See the build failure. It is done like that to allow the child class (LineFormatter) to override this. It's very difficult to have strict types for NormalizerFormatter as it is extended for various different use cases.

ro0NL commented 2 weeks ago

@Seldaek got ya. updated.

Seldaek commented 2 weeks ago

Sorry not sure what you updated? :) Still failing

ro0NL commented 2 weeks ago

yeah ok. i dont feel like doing the phpstan bookkeeping. sorry.

we've casted JsonFormatter::normalize on our side.

Seldaek commented 2 weeks ago

Yeah that's fine by me.. I don't know which is best here tbh, we gotta ignore some errors somewhere, but maybe for lib consumers it would be better if we did it like you had and ignore the JsonFormatter extension error. But I guess your array-key change should be applied still right? Is array-key equivalent to string|int? I can look at doing the change and updating the baseline.

ro0NL commented 2 weeks ago

psalm describes it as

array-key is the supertype (but not a union) of int and string.

so yes just a union in practice

Seldaek commented 1 week ago

OK I think this works https://github.com/Seldaek/monolog/commit/e94000419394ff1bec801dad310432228f9fc19c