Lines
66.66%
4 / 6
Functions and Methods
50.00%
2 / 4
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ManifestResultCacheValue | 66.66% | 4 / 6 | 50.00% | 2 / 4 | 5.93 | 0.00% | 0 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| getValue | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 2 | |||||
| keyToResultCache | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| keyFromResultCache | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\PHPStan\Cache; | |
| 6 | ||
| 7 | use PHPStan\Analyser\ResultCache\ResultCacheValueExtension; | |
| 8 | use Stewart\PHPStan\Manifest\ManifestCatalogLoader; | |
| 9 | ||
| 10 | // The findings depend on the generated Manifest, which the files that use entity IDs do not import. | |
| 11 | final readonly class ManifestResultCacheValue implements ResultCacheValueExtension | |
| 12 | { | |
| 13 | public const string MANIFEST_KEY = 'manifest'; | |
| 14 | ||
| 15 | private const string WITHOUT_MANIFEST = 'none'; | |
| 16 | ||
| 17 | private const string FROM_OLDER_MAJOR = 'older-major'; | |
| 18 | ||
| 19 | public function __construct(private ManifestCatalogLoader $manifests) {} | |
| 20 | ||
| 21 | public function getValue(string $key): string | |
| 22 | { | |
| 23 | if ($this->manifests->findOlderMajorNamespace() !== null) { | |
| 24 | return self::FROM_OLDER_MAJOR; | |
| 25 | } | |
| 26 | ||
| 27 | return $this->manifests->findCatalog()?->computeHash() ?? self::WITHOUT_MANIFEST; | |
| 28 | } | |
| 29 | ||
| 30 | public function keyToResultCache(string $key): string | |
| 31 | { | |
| 32 | return $key; | |
| 33 | } | |
| 34 | ||
| 35 | public function keyFromResultCache(string $storedKey): string | |
| 36 | { | |
| 37 | return $storedKey; | |
| 38 | } | |
| 39 | } |