Skip to content

Commit fc3d96b

Browse files
committed
Add README
1 parent d32248f commit fc3d96b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
sfp-psalm-psr-log-plugin
2+
========================
3+
4+
PSR-3 (psr/log) plugin for [Psalm](https://github.com/vimeo/psalm)
5+
6+
Installation:
7+
8+
```console
9+
$ composer require --dev struggle-for-php/sfp-psalm-psr-log-plugin
10+
$ vendor/bin/psalm-plugin enable struggle-for-php/sfp-psalm-psr-log-plugin
11+
```
12+
13+
## Example
14+
15+
```php
16+
<?php
17+
18+
use Psr\Log\LoggerInterface;
19+
20+
class Foo
21+
{
22+
/** @var LoggerInterface */
23+
private $logger;
24+
25+
public function anyAction()
26+
{
27+
try {
28+
} catch (\Exception $e) {
29+
$this->logger->error('error happend.', ['exception' => $e->getMessage()]);
30+
}
31+
}
32+
}
33+
```
34+
35+
would be ERROR output:
36+
```php
37+
ERROR: InvalidArgument - src/Foo.php:14:45 - Argument 2 of Psr\Log\LoggerInterface::error expects array{exception?: Exception}, array{exception: string} provided
38+
$this->logger->error('error happend.', ['exception' => $e->getMessage()]);
39+
```

0 commit comments

Comments
 (0)