1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-14 02:07:37 +01:00
psalm/src/psalm_plugin.php
Bruce Weirdan 205fdd197e
Wrap entrypoints into IIFE to protect their variables (#5366)
* Wrap entrypoints into IIFE to protect their variables

Fixes vimeo/psalm#5359

* Add tests for Psalm variable isolation

* Capture environment before registering autoloader
2021-03-11 00:14:22 -05:00

47 lines
1.4 KiB
PHP

<?php
namespace Psalm;
use PackageVersions\Versions;
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 Symfony\Component\Console\Input\InputOption;
use function dirname;
use function getcwd;
use const DIRECTORY_SEPARATOR;
require_once __DIR__ . '/command_functions.php';
require_once __DIR__ . '/Psalm/Internal/Composer.php';
(
function (): void {
$current_dir = (string)getcwd() . DIRECTORY_SEPARATOR;
$vendor_dir = \Psalm\getVendorDir($current_dir);
requireAutoloaders($current_dir, false, $vendor_dir);
$app = new Application('psalm-plugin', Versions::getVersion('vimeo/psalm'));
$psalm_root = dirname(__DIR__) . 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->getDefinition()->addOption(
new InputOption('config', 'c', InputOption::VALUE_REQUIRED, 'Path to Psalm config file')
);
$app->setDefaultCommand('show');
$app->run();
}
)();