diff --git a/config.xsd b/config.xsd index 44914705e..4e06bf9d8 100644 --- a/config.xsd +++ b/config.xsd @@ -52,14 +52,7 @@ - - - - - - - - + @@ -67,6 +60,15 @@ + + + + + + + + + diff --git a/src/Psalm/Config/FileFilter.php b/src/Psalm/Config/FileFilter.php index 341c4f9f5..5aa5c030a 100644 --- a/src/Psalm/Config/FileFilter.php +++ b/src/Psalm/Config/FileFilter.php @@ -81,6 +81,8 @@ class FileFilter $base_dir, $inclusive ) { + $allow_missing_files = ((string) $e['allowMissingFiles']) === 'true'; + $filter = new static($inclusive); if ($e->directory) { @@ -110,6 +112,10 @@ class FileFilter ); if (empty($globs)) { + if ($allow_missing_files) { + continue; + } + echo 'Could not resolve config path to ' . $base_dir . DIRECTORY_SEPARATOR . (string)$directory['name'] . PHP_EOL; exit(1); @@ -117,11 +123,19 @@ class FileFilter foreach ($globs as $glob_index => $directory_path) { if (!$directory_path) { + if ($allow_missing_files) { + continue; + } + echo 'Could not resolve config path to ' . $base_dir . DIRECTORY_SEPARATOR . (string)$directory['name'] . ':' . $glob_index . PHP_EOL; exit(1); } + if (!$directory_path) { + continue; + } + if ($ignore_type_stats && $filter instanceof ProjectFileFilter) { $filter->ignore_type_stats[$directory_path] = true; } @@ -138,6 +152,10 @@ class FileFilter $directory_path = realpath($prospective_directory_path); if (!$directory_path) { + if ($allow_missing_files) { + continue; + } + echo 'Could not resolve config path to ' . $base_dir . DIRECTORY_SEPARATOR . (string)$directory['name'] . PHP_EOL; exit(1); diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index b53cb5f61..ddad0edd2 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -139,6 +139,33 @@ class ConfigTest extends TestCase $this->assertFalse($config->isInProjectDirs(realpath('examples/StringAnalyzer.php'))); } + /** + * @return void + */ + public function testIgnoreMissingProjectDirectory() + { + $this->project_analyzer = $this->getProjectAnalyzerWithConfig( + Config::loadFromXML( + dirname(__DIR__), + ' + + + + + + + + ' + ) + ); + + $config = $this->project_analyzer->getConfig(); + + $this->assertTrue($config->isInProjectDirs(realpath('src/Psalm/Type.php'))); + $this->assertFalse($config->isInProjectDirs(realpath('does/not/exist/FileAnalyzer.php'))); + $this->assertFalse($config->isInProjectDirs(realpath('examples/StringAnalyzer.php'))); + } + /** * @return void */