file_provider = new Provider\FakeFileProvider(); $this->project_checker = new \Psalm\Checker\ProjectChecker( $this->file_provider, new Provider\FakeParserCacheProvider() ); if (!self::$config) { self::$config = new TestConfig(); self::$config->addPluginPath('examples/ClassUnqualifier.php'); } $this->project_checker->setConfig(self::$config); } /** * @dataProvider providerFileCheckerValidCodeParse * * @param string $input_code * @param string $output_code * @param string $php_version * @param string[] $issues_to_fix * * @return void */ public function testValidCode($input_code, $output_code, $php_version, array $issues_to_fix) { $test_name = $this->getName(); if (strpos($test_name, 'PHP7-') !== false) { if (version_compare(PHP_VERSION, '7.0.0dev', '<')) { $this->markTestSkipped('Test case requires PHP 7.'); return; } } elseif (strpos($test_name, 'SKIPPED-') !== false) { $this->markTestSkipped('Skipped due to a bug.'); } $context = new Context(); $file_path = self::$src_dir_path . 'somefile.php'; $this->addFile( $file_path, $input_code ); list($php_major_version, $php_minor_version) = explode('.', $php_version); $keyed_issues_to_fix = []; foreach ($issues_to_fix as $issue) { $keyed_issues_to_fix[$issue] = true; } $file_checker = new FileChecker($file_path, $this->project_checker); $this->project_checker->setIssuesToFix($keyed_issues_to_fix); $this->project_checker->alterCodeAfterCompletion((int) $php_major_version, (int) $php_minor_version); $file_checker->visitAndAnalyzeMethods($context); $this->project_checker->updateFile($file_path, false); $this->assertSame($output_code, $this->project_checker->getFileContents($file_path)); } /** * @return array */ public function providerFileCheckerValidCodeParse() { return [ 'addMissingVoidReturnType56' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ '