Skip to content

Commit d414539

Browse files
Merge branch '9.2'
2 parents 932092f + e82f3f7 commit d414539

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

ChangeLog-10.1.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
44

5+
## [10.1.3] - 2023-MM-DD
6+
7+
### Fixed
8+
9+
* Static analysis cache keys do not include configuration settings that affect source code parsing
10+
511
## [10.1.2] - 2023-05-22
612

713
### Fixed
@@ -24,6 +30,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
2430

2531
* The `SebastianBergmann\CodeCoverage\Filter::includeDirectory()`, `SebastianBergmann\CodeCoverage\Filter::excludeDirectory()`, and `SebastianBergmann\CodeCoverage\Filter::excludeFile()` methods are now deprecated
2632

33+
[10.1.3]: https://github.com/sebastianbergmann/php-code-coverage/compare/10.1.2...10.1
2734
[10.1.2]: https://github.com/sebastianbergmann/php-code-coverage/compare/10.1.1...10.1.2
2835
[10.1.1]: https://github.com/sebastianbergmann/php-code-coverage/compare/10.1.0...10.1.1
2936
[10.1.0]: https://github.com/sebastianbergmann/php-code-coverage/compare/10.0.2...10.1.0

src/CodeCoverage.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,9 @@ private function analyser(): FileAnalyser
599599
if ($this->cachesStaticAnalysis()) {
600600
$this->analyser = new CachingFileAnalyser(
601601
$this->cacheDirectory,
602-
$this->analyser
602+
$this->analyser,
603+
$this->useAnnotationsForIgnoringCode,
604+
$this->ignoreDeprecatedCode
603605
);
604606
}
605607

src/StaticAnalysis/CacheWarmer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ public function warmCache(string $cacheDirectory, bool $useAnnotationsForIgnorin
2020
new ParsingFileAnalyser(
2121
$useAnnotationsForIgnoringCode,
2222
$ignoreDeprecatedCode
23-
)
23+
),
24+
$useAnnotationsForIgnoringCode,
25+
$ignoreDeprecatedCode,
2426
);
2527

2628
foreach ($filter->files() as $file) {

src/StaticAnalysis/CachingFileAnalyser.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,20 @@
2727
final class CachingFileAnalyser implements FileAnalyser
2828
{
2929
private static ?string $cacheVersion = null;
30+
private readonly string $directory;
3031
private readonly FileAnalyser $analyser;
32+
private readonly bool $useAnnotationsForIgnoringCode;
33+
private readonly bool $ignoreDeprecatedCode;
3134
private array $cache = [];
32-
private readonly string $directory;
3335

34-
public function __construct(string $directory, FileAnalyser $analyser)
36+
public function __construct(string $directory, FileAnalyser $analyser, bool $useAnnotationsForIgnoringCode, bool $ignoreDeprecatedCode)
3537
{
3638
Filesystem::createDirectory($directory);
3739

38-
$this->analyser = $analyser;
39-
$this->directory = $directory;
40+
$this->analyser = $analyser;
41+
$this->directory = $directory;
42+
$this->useAnnotationsForIgnoringCode = $useAnnotationsForIgnoringCode;
43+
$this->ignoreDeprecatedCode = $ignoreDeprecatedCode;
4044
}
4145

4246
public function classesIn(string $filename): array
@@ -142,7 +146,20 @@ private function write(string $filename, array $data): void
142146

143147
private function cacheFile(string $filename): string
144148
{
145-
return $this->directory . DIRECTORY_SEPARATOR . md5($filename . "\0" . file_get_contents($filename) . "\0" . self::cacheVersion());
149+
$cacheKey = md5(
150+
implode(
151+
"\0",
152+
[
153+
$filename,
154+
file_get_contents($filename),
155+
self::cacheVersion(),
156+
$this->useAnnotationsForIgnoringCode,
157+
$this->ignoreDeprecatedCode,
158+
]
159+
)
160+
);
161+
162+
return $this->directory . DIRECTORY_SEPARATOR . $cacheKey;
146163
}
147164

148165
private static function cacheVersion(): string

0 commit comments

Comments
 (0)