Skip to content

Commit 6628bcd

Browse files
committed
Update cache deletion logic
1 parent 12a19b2 commit 6628bcd

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/Cache/FileCacheStorage.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use function rmdir;
2626
use function sha1;
2727
use function sprintf;
28-
use function str_contains;
2928
use function str_starts_with;
3029
use function strlen;
3130
use function substr;
@@ -37,7 +36,7 @@
3736
final class FileCacheStorage implements CacheStorage
3837
{
3938

40-
private const CACHED_CLEARED_VERSION = 'v2-old-two';
39+
private const CACHED_CLEARED_VERSION = 'v2-new';
4140

4241
public function __construct(private string $directory)
4342
{
@@ -147,27 +146,16 @@ public function clearUnusedFiles(): void
147146
"<?php declare(strict_types = 1);\n\n%s",
148147
sprintf('// %s', 'variadic-method-'),
149148
);
150-
$beginOld = sprintf(
151-
"<?php declare(strict_types = 1);\n\n%s",
152-
'return PHPStan\\Cache\\CacheItem::',
153-
);
154-
$beginOld2 = sprintf(
155-
"<?php declare(strict_types = 1);\n\n%s",
156-
'return \\PHPStan\\Cache\\CacheItem::',
157-
);
149+
$beginNew = "<?php declare(strict_types = 1);\n\n//";
158150
$emptyDirectoriesToCheck = [];
159151
foreach ($files as $file) {
160152
try {
161153
$path = $file->getPathname();
162154
$contents = FileReader::read($path);
163-
if (str_contains($contents, 'odsl-')) {
164-
continue;
165-
}
166155
if (
167156
!str_starts_with($contents, $beginFunction)
168157
&& !str_starts_with($contents, $beginMethod)
169-
&& !str_starts_with($contents, $beginOld)
170-
&& !str_starts_with($contents, $beginOld2)
158+
&& str_starts_with($contents, $beginNew)
171159
) {
172160
continue;
173161
}

0 commit comments

Comments
 (0)