This repository is aimed for used by these.
- https://github.com/struggle-for-php/sfp-psalm-psr-log-plugin
- https://github.com/struggle-for-php/sfp-phpstan-psr-log
But, You can use this for individual purpose. Add the following files to your stub settings.
stubs-for-throwable/LoggerInterface.phpstub
<?php
/** @var Psr\Log\LoggerInterface $logger */
$logger->error('error happen.', ['exception' => $exception->getMessage()]);
Your Static analysis would points like this message.
Parameter #2 $context of method Psr\Log\LoggerInterface::error() expects array()|array('exception' => Exception),
Implementors MUST still verify that the 'exception' key is actually an Exception before using it as such, as it MAY contain anything.
https://www.php-fig.org/psr/psr-3/#13-context
The PSR-3 specification states Exception
but we have confirmed with PHP-FIG that Throwable
is allowed for PHP 7 and later.
https://groups.google.com/g/php-fig/c/nnwDWSFmij8
/**
* @param LogLevel::* $level
*/
public function log($level, $message, array $context = array())
- Stub
LoggerAwareTrait