-
Notifications
You must be signed in to change notification settings - Fork 1
/
Plugin.php
37 lines (32 loc) · 1.24 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace Bocmah\PsalmReactPhpPromisePlugin;
use SimpleXMLElement;
use Psalm\Plugin\PluginEntryPointInterface;
use Psalm\Plugin\RegistrationInterface;
class Plugin implements PluginEntryPointInterface
{
public function __invoke(RegistrationInterface $psalm, ?SimpleXMLElement $config = null): void
{
// This is plugin entry point. You can initialize things you need here,
// and hook them into psalm using RegistrationInterface
//
// Here's some examples:
// 1. Add a stub file
// ```php
// $psalm->addStubFile(__DIR__ . '/stubs/YourStub.php');
// ```
foreach ($this->getStubFiles() as $file) {
$psalm->addStubFile($file);
}
// Psalm allows arbitrary content to be stored under you plugin entry in
// its config file, psalm.xml, so you plugin users can put some configuration
// values there. They will be provided to your plugin entry point in $config
// parameter, as a SimpleXmlElement object. If there's no configuration present,
// null will be passed instead.
}
/** @return list<string> */
private function getStubFiles(): array
{
return glob(__DIR__ . '/stubs/*.phpstub') ?: [];
}
}