On Sun, Jul 4, 2021, at 3:35 AM, Sasezaki wrote:
> Hi.
> 
> I have suggestion for psr-3 context's key 'exception'.
> Could be change allow `\Throwable` to accept ?
> 
> current psr-3
> https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
> > 'exception' key is actually an Exception.
> 
> I think this was designed for PHP 5 age. 
> 
> But, recent Monolog 's code is
> > if (isset($context['exception']) && $context['exception'] instanceof 
> Throwable) {
> https://github.com/Seldaek/monolog/blob/2.2.0/src/Monolog/Handler/RollbarHandler.php#L92
> 
> Other LoggerInterface implementer would be confused.
> "should it be strictly `\Exception` ? or `\Throwable`  ?".
> 
> --
> 
> And  from strict analysis tool usage (array-shapes stubs), it also 
> needs to be clear  \Exception or  \Throwable.
> 
> I have several implmentaion as example,
> 
> array{exception?: \Exception}  $context
> https://github.com/struggle-for-php/sfp-psalm-psr-log-plugin/blob/0.2.0/stubs/LoggerInterface.php
> 
> array{exception?: \Throwable}  $context
> https://github.com/struggle-for-php/sfp-psalm-psr-log-plugin/blob/0.2.0/throwable-stubs/LoggerInterface.php

You are correct, PSR-3 was developed around the PHP 5.4 era.  I would be fine 
with adding an Errata to the metadoc that says "Throwables generally".  That 
would require a PR and a Core Committee vote.

Note that PSR-3 doesn't have a metadoc yet. :-)  It's that old.  There's 
another vote in progress to add types to the interface packages that includes 
adding a metadoc file.  I'd say wait until that finishes (it looks like it's 
going to easily pass), and then it will be possible to add another errata to it 
in a second step.

--Larry Garfield

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to php-fig+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/b8705a16-67f5-49b7-99a5-e323fa102e08%40www.fastmail.com.

Reply via email to