|
4 | 4 | [](https://packagist.org/packages/struggle-for-php/sfp-phpstan-psr-log)
|
5 | 5 | [](https://shepherd.dev/github/struggle-for-php/sfp-phpstan-psr-log)
|
6 | 6 |
|
| 7 | +> [!IMPORTANT] |
| 8 | +> The next version `0.25.0` will have a BC break. Please refer `Stubs` section. |
| 9 | +
|
7 | 10 | `struggle-for-php/sfp-phpstan-psr-log` is extra strict and opinionated psr/log (psr-3) rules for PHPStan.
|
8 | 11 |
|
9 | 12 | * [PHPStan](https://phpstan.org/)
|
10 | 13 | * [PSR-3: Logger Interface - PHP-FIG](https://www.php-fig.org/psr/psr-3/)
|
11 | 14 | * [PSR-3 Meta Document](https://www.php-fig.org/psr/psr-3/meta/)
|
12 | 15 |
|
13 |
| -> [!IMPORTANT] |
14 |
| -> Since `0.20.0`, changed default rule settings. |
| 16 | +## Recommendation Settings |
15 | 17 |
|
16 |
| -* MessageStaticStringRule is enabled by default. |
17 |
| -* ContextRequireExceptionKeyRule is disabled by default. |
18 |
| -* [Recommendation] write these parameters to your project's `phpstan.neon`. |
| 18 | +Write these parameters to your project's `phpstan.neon`. |
19 | 19 |
|
20 | 20 | ```neon
|
21 | 21 | parameters:
|
22 | 22 | sfpPsrLog:
|
23 |
| - enableMessageStaticStringRule: true |
| 23 | + enableMessageStaticStringRule: false # default:true |
24 | 24 | enableContextRequireExceptionKeyRule: true
|
25 | 25 | reportContextExceptionLogLevel: 'info'
|
26 | 26 | contextKeyOriginalPattern: '#\A[A-Za-z0-9-_]+\z#'
|
27 | 27 | ```
|
28 | 28 |
|
29 | 29 | ## Stubs
|
30 | 30 |
|
31 |
| -This extension depends on our psr/log stub to serve strictness. |
| 31 | +> [!IMPORTANT] |
| 32 | +> include psr/log stub be planned to dropped in next release. |
| 33 | +
|
| 34 | +To try out the changes in the next version, |
| 35 | + |
| 36 | +DELETE `vendor/struggle-for-php/sfp-phpstan-psr-log/extension.neon` line from your `phpstan.neon` |
| 37 | + |
| 38 | +```neon |
| 39 | +includes: |
| 40 | + - vendor/struggle-for-php/sfp-phpstan-psr-log/extension.neon |
| 41 | +``` |
| 42 | + |
| 43 | +and, set parameters `enableLogLevelMethodRule` and `enableContextTypeRule` |
| 44 | + |
| 45 | +```neon |
| 46 | +parameters: |
| 47 | + sfpPsrLog: |
| 48 | + enableLogLevelMethodRule: true # default:false |
| 49 | + enableContextTypeRule: true # default:false |
| 50 | +``` |
| 51 | + |
| 52 | +### About stub |
| 53 | + |
| 54 | +Currently, this extension depends on our psr/log stub to serve strictness. |
32 | 55 |
|
33 | 56 | * eg.
|
34 | 57 | * `@param LogLevel::* $level` at `log()` method
|
@@ -221,11 +244,9 @@ To use this extension, require it in [Composer](https://getcomposer.org/):
|
221 | 244 | composer require --dev struggle-for-php/sfp-phpstan-psr-log
|
222 | 245 | ```
|
223 | 246 |
|
224 |
| -If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set. |
225 |
| - |
226 | 247 | ### Manual installation
|
227 | 248 |
|
228 |
| -If you don't want to use `phpstan/extension-installer`, include extension.neon & rules.neon in your project's PHPStan config: |
| 249 | +include extension.neon & rules.neon in your project's PHPStan config: |
229 | 250 |
|
230 | 251 | ```neon
|
231 | 252 | includes:
|
|
0 commit comments