From e0a8a8a4dc93a0256590bc9454ab7f5f6b68785d Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Fri, 31 Jul 2026 17:30:23 +0800 Subject: [PATCH] fix(parser): allow missing ignore paths in project YAML configuration - Modified parseProjectYaml to skip non-existent ignore paths instead of throwing errors - Added test case verifying optional ignore paths are silently ignored when missing - Maintained existing behavior for missing source files which still throw exceptions - Updated version number from 1096 to 1097 --- phpunit/src/CompilerBaseApiTest.php | 29 +++++++++++++++++++++++++++++ src/Translator.php | 5 ++++- version.txt | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/phpunit/src/CompilerBaseApiTest.php b/phpunit/src/CompilerBaseApiTest.php index 4939ec83..0cffa399 100644 --- a/phpunit/src/CompilerBaseApiTest.php +++ b/phpunit/src/CompilerBaseApiTest.php @@ -576,6 +576,35 @@ YAML); $this->assertNotContains(realpath($projectDir . '/skipped/nested.php'), $files); } + public function testParseProjectYamlAllowsMissingIgnorePaths(): void + { + $projectFile = $this->createProjectFile(<<<'YAML' +sources: + - main.php +ignore: + - optional-missing.php + - optional-missing-directory +YAML); + + $files = $this->invokeMethod('parseProjectYaml', $projectFile); + + $this->assertSame([realpath(dirname($projectFile) . '/main.php')], $files); + $this->assertSame([], $this->getPropertyValue('ignorePaths')); + } + + public function testParseProjectYamlStillRejectsMissingSources(): void + { + $projectFile = $this->createProjectFile(<<<'YAML' +sources: + - required-missing.php +YAML); + + $this->expectException(TestError::class); + $this->expectExceptionMessage('Source file not exists: `required-missing.php`'); + + $this->invokeMethod('parseProjectYaml', $projectFile); + } + public function testParseProjectYamlSupportsConditionalSourcesByPhpVersion(): void { $futureVersion = PHP_VERSION_ID + 10000; diff --git a/src/Translator.php b/src/Translator.php index db4cd0c9..861279a9 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -2230,7 +2230,10 @@ CODE; foreach ($ignore as $src) { $realPath = $this->getAbsolutePath($src, $projectDir); if (!$realPath) { - $this->error('Source file not exists: `' . $src . '`'); + // Ignore entries describe optional exclusions. Projects often + // share one configuration across dependency versions where an + // excluded file or directory may not exist. + continue; } $this->ignorePaths[] = $realPath; } diff --git a/version.txt b/version.txt index ba851d84..8b37c8cf 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1096 +1097 \ No newline at end of file