Skip to content

Commit 67ea244

Browse files
committed
Update FileFilter logic to prevent exclusion of cached files from contract docblock extraction; adjust related test case for clarity
1 parent 012980d commit 67ea244

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/Contract/FileFilter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ public static function isFileExcluded(string|false|null $fileName): bool
4949
return self::$pathFilterCache[$normalizedPath] = true;
5050
}
5151

52+
// Transformed files in the cache directory represent valid application code and must NOT be excluded from reflection!
5253
if (PathMatcher::isCachePath($normalizedPath)) {
53-
return self::$pathFilterCache[$normalizedPath] = true;
54+
return self::$pathFilterCache[$normalizedPath] = false;
5455
}
5556

5657
$config = Config::get();
@@ -63,4 +64,4 @@ public static function isFileExcluded(string|false|null $fileName): bool
6364

6465
return self::$pathFilterCache[$normalizedPath] = ! $isIncluded;
6566
}
66-
}
67+
}

tests/Contract/FileFilterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
Config::reset();
139139
});
140140

141-
test('unconditionally excludes the configured cache directory even if include pattern is **', function () {
141+
test('does not exclude cached files from contract docblock extraction', function () {
142142
$customCacheDir = getcwd() . '/storage/typephp-cache';
143143

144144
Config::set([
@@ -152,7 +152,7 @@
152152
$cachedFilePath = str_replace('\\', '/', $customCacheDir . '/v0.1_hash123.php');
153153
$normalFilePath = str_replace('\\', '/', getcwd() . '/app/Models/User.php');
154154

155-
expect(FileFilter::isFileExcluded($cachedFilePath))->toBeTrue()
155+
expect(FileFilter::isFileExcluded($cachedFilePath))->toBeFalse()
156156
->and(FileFilter::isFileExcluded($normalFilePath))->toBeFalse()
157157
;
158158

0 commit comments

Comments
 (0)