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
pull/43/head
韩天峰 4 weeks ago
parent 6ecc447735
commit e0a8a8a4dc
  1. 29
      phpunit/src/CompilerBaseApiTest.php
  2. 5
      src/Translator.php
  3. 2
      version.txt

@ -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;

@ -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;
}

@ -1 +1 @@
1096
1097
Loading…
Cancel
Save