disableExtension('grpc'); // If Xdebug is enabled, restart without it $ini_handler->check(); setlocale(LC_CTYPE, 'C'); $path_to_config = get_path_to_config($options); if (isset($options['tcp'])) { if (!is_string($options['tcp'])) { fwrite(STDERR, 'tcp url should be a string' . PHP_EOL); exit(1); } } $find_dead_code = isset($options['find-dead-code']); $config = initialiseConfig($path_to_config, $current_dir, \Psalm\Report::TYPE_CONSOLE, $first_autoloader); if ($config->resolve_from_config_file) { $current_dir = $config->base_dir; chdir($current_dir); } $config->setServerMode(); if (isset($options['clear-cache'])) { $cache_directory = $config->getCacheDirectory(); Config::removeCacheDirectory($cache_directory); echo 'Cache directory deleted' . PHP_EOL; exit; } $providers = new Psalm\Internal\Provider\Providers( new Psalm\Internal\Provider\FileProvider, new Psalm\Internal\Provider\ParserCacheProvider($config), new Psalm\Internal\Provider\FileStorageCacheProvider($config), new Psalm\Internal\Provider\ClassLikeStorageCacheProvider($config), new Psalm\Internal\Provider\FileReferenceCacheProvider($config) ); $project_analyzer = new ProjectAnalyzer( $config, $providers ); if (isset($options['disable-on-change'])) { $project_analyzer->onchange_line_limit = (int) $options['disable-on-change']; } $project_analyzer->provide_completion = !isset($options['enable-autocomplete']) || !is_string($options['enable-autocomplete']) || strtolower($options['enable-autocomplete']) !== 'false'; $config->visitComposerAutoloadFiles($project_analyzer); if ($find_dead_code) { $project_analyzer->getCodebase()->reportUnusedCode(); } $project_analyzer->server($options['tcp'] ?? null, isset($options['tcp-server']) ? true : false);