1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00
psalm/docs/plugins.md

27 lines
782 B
Markdown
Raw Normal View History

2018-02-22 02:11:34 +01:00
# Plugins
Psalm can be extended through plugins to find domain-specific issues.
All plugins must extend `Psalm\Plugin` and return an instance of themselves e.g.
```php
<?php
class SomePlugin extends \Psalm\Plugin
{
}
return new SomePlugin;
```
`Psalm\Plugin` offers two methods that you can override:
- `afterStatementsCheck` - called after Psalm evaluates each statement
- `afterExpressionCheck` - called after Psalm evaluates each expression
An example plugin that checks class references in strings is provided [here](https://github.com/vimeo/psalm/blob/master/examples/StringChecker.php).
To ensure your plugin runs when Psalm does, add it to your [config](Configuration):
```php
<plugins>
<plugin filename="src/plugins/SomePlugin.php" />
</plugins>
```