file_provider = new \Psalm\Tests\Internal\Provider\FakeFileProvider(); $config = new TestConfig(); $providers = new Providers( $this->file_provider, new Provider\FakeParserCacheProvider() ); $this->project_analyzer = new ProjectAnalyzer( $config, $providers, false, true, ProjectAnalyzer::TYPE_CONSOLE, 1, false ); $this->project_analyzer->setPhpVersion('7.3'); } /** * @param string $file_path * @param string $contents * * @return void */ public function addFile($file_path, $contents) { $this->file_provider->registerFile($file_path, $contents); $this->project_analyzer->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_analyzer->getCodebase(); $codebase->addFilesToAnalyze([$file_path => $file_path]); $codebase->scanFiles(); $codebase->config->visitStubFiles($codebase); $file_analyzer = new FileAnalyzer( $this->project_analyzer, $file_path, $codebase->config->shortenFileName($file_path) ); $file_analyzer->analyze($context); } /** * @param bool $withDataSet * @return string */ protected function getTestName($withDataSet = true) { $name = parent::getName($withDataSet); /** @psalm-suppress DocblockTypeContradiction PHPUnit 7 introduced nullable name */ if (null === $name) { throw new RuntimeException('anonymous test - shouldn\'t happen'); } return $name; } }