facile-it / psalm-psr-log-plugin
Psalm plugin for psr/log (PSR-3)
Installs: 200
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
pkg:composer/facile-it/psalm-psr-log-plugin
Requires
- php: ^7.4 || ^8.0
- ext-simplexml: *
- psr/log: ^1.1 || ^2.0 || ^3.0
- vimeo/psalm: ^4.7 || ^5.0 || ^6.0
Requires (Dev)
- codeception/codeception: ^4.1 || ^5.0
- facile-it/facile-coding-standard: ^1.3.0
- weirdan/codeception-psalm-module: ^0.14.0
This package is auto-updated.
Last update: 2025-10-21 15:24:57 UTC
README
A Psalm plugin to check psr/log (PSR-3) usage.
Features
- Suppress
ImplicitToStringCastpsalm errors when objects with a__toString()method are used as message - Checks that all placeholders used in a message string are in the context array
Example
This plugin checks for missing context keys for placeholders:
/** @var Psr\Log\LoggerInterface $logger */ $logger->info('User {username} logged in at {datetime}', [ 'username' => 'user-username', ]);
Usage
Include the plugin in your psalm.xml config file.
<psalm> <plugins> <pluginClass class="Facile\Psalm\PsrLogPlugin\Plugin"/> </plugins> </psalm>
Required keys
if you want to always require keys in context, you can configure the plugin with the requiredKey:
<psalm> <plugins> <pluginClass class="Facile\Psalm\PsrLogPlugin\Plugin"> <requiredKey>requestId</requiredKey> <requiredKey>environment</requiredKey> </pluginClass> </plugins> </psalm>
Ignored keys
if you want to ignore requirement for some key in context, you can configure the plugin with the ignoredKey.
This is useful when you have your logger that automatically injects it.
<psalm> <plugins> <pluginClass class="Facile\Psalm\PsrLogPlugin\Plugin"> <ignoredKey>requestId</ignoredKey> </pluginClass> </plugins> </psalm>
