file_provider = new Provider\FakeFileProvider(); $config = new TestConfig(); $parser_cache_provider = new Provider\FakeParserCacheProvider(); $this->project_checker = new ProjectChecker( $config, $this->file_provider, $parser_cache_provider, new \Psalm\Provider\NoCache\NoFileStorageCacheProvider(), new \Psalm\Provider\NoCache\NoClassLikeStorageCacheProvider(), false, true, ProjectChecker::TYPE_CONSOLE, 1, false ); $this->project_checker->infer_types_from_usage = true; } /** * @param string $file_path * @param string $contents * * @return void */ public function addFile($file_path, $contents) { $this->file_provider->registerFile($file_path, $contents); $this->project_checker->getCodeBase()->scanner->addFileToShallowScan($file_path); } /** * @param string $file_path * @param \Psalm\Context $context * * @return void */ public function analyzeFile($file_path, \Psalm\Context $context) { $codebase = $this->project_checker->getCodebase(); $codebase->addFilesToAnalyze([$file_path => $file_path]); $codebase->scanFiles(); $file_checker = new FileChecker( $this->project_checker, $file_path, $codebase->config->shortenFileName($file_path) ); $file_checker->analyze($context); } }