forked from vimeo/psalm
/
Plugin.php
49 lines (37 loc) · 1.31 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
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace Psalm\Internal\Cli;
use Psalm\Internal\CliUtils;
use Psalm\Internal\PluginManager\Command\DisableCommand;
use Psalm\Internal\PluginManager\Command\EnableCommand;
use Psalm\Internal\PluginManager\Command\ShowCommand;
use Psalm\Internal\PluginManager\PluginListFactory;
use Symfony\Component\Console\Application;
use function dirname;
use function getcwd;
use const DIRECTORY_SEPARATOR;
// phpcs:disable PSR1.Files.SideEffects
require_once __DIR__ . '/../CliUtils.php';
require_once __DIR__ . '/../Composer.php';
/**
* @internal
*/
final class Plugin
{
public static function run(): void
{
CliUtils::checkRuntimeRequirements();
$current_dir = (string)getcwd() . DIRECTORY_SEPARATOR;
$vendor_dir = CliUtils::getVendorDir($current_dir);
CliUtils::requireAutoloaders($current_dir, false, $vendor_dir);
$app = new Application('psalm-plugin', PSALM_VERSION);
$psalm_root = dirname(__DIR__, 4) . DIRECTORY_SEPARATOR;
$plugin_list_factory = new PluginListFactory($current_dir, $psalm_root);
$app->addCommands([
new ShowCommand($plugin_list_factory),
new EnableCommand($plugin_list_factory),
new DisableCommand($plugin_list_factory),
]);
$app->setDefaultCommand('show');
$app->run();
}
}