struggle-for-php/sfp-stubs-psr-log
最新稳定版本:3.0.2
Composer 安装命令:
composer require --dev struggle-for-php/sfp-stubs-psr-log
包简介
Stubs to let Static Analysis understand psr/log (PSR-3)
README 文档
README
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
Features
Typed context array, in order to force exception key is only Throwable object.
Example
<?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),
Refs.
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
level parameter of log method is a constant enum of LogLevels::*.
/** * @param LogLevel::* $level */ public function log($level, $message, array $context = array())
Not Support (Not planned)
- Stub
LoggerAwareTrait
统计信息
- 总下载量: 200.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-21