From fa3283824227e5535dbd57113edc0cfd9097b41f Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 8 Oct 2026 22:18:45 +0700 Subject: [PATCH 1/2] perf: Store only the content hash in per-file cache payload metadata --- src/Cache/AnalysisResultCache.php | 19 +++++-------------- tests/Cache/AnalysisResultCacheTest.php | 10 ++-------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/Cache/AnalysisResultCache.php b/src/Cache/AnalysisResultCache.php index 238960da..5eb27861 100644 --- a/src/Cache/AnalysisResultCache.php +++ b/src/Cache/AnalysisResultCache.php @@ -65,7 +65,7 @@ final class AnalysisResultCache * their shape or naming changes: it is recorded in the metadata marker, * so a cache written by an older format is cleared on its next use. */ - public const FORMAT_VERSION = 14; + public const FORMAT_VERSION = 15; private readonly string $cacheDirectory; @@ -297,7 +297,7 @@ private function analysisNodePayload(string $file, string $namespace): ?array { $payload = $this->read($this->analysisNodesKey($file, $namespace)); - if ($payload === null || ($payload['metadata'] ?? null) !== $this->fileMetadata($file, $namespace)) { + if ($payload === null || ($payload['metadata'] ?? null) !== $this->fileHashProvider->hash($file)) { return null; } @@ -409,8 +409,10 @@ public function storeAnalysisNodes( ): void { $this->ensureCacheInitialised(); + // The namespace is already part of the file name, so the payload + // only carries the content hash it was built from. $payload = [ - 'metadata' => $this->fileMetadata($file, $namespace), + 'metadata' => $this->fileHashProvider->hash($file), 'nodes' => array_map($this->classNodeToArray(...), $classNodes), ]; @@ -1482,15 +1484,4 @@ private function analysisNodesKey(string $file, string $namespace): string { return 'analysis-nodes-' . hash('xxh128', $namespace . "\0" . $file); } - - /** - * @return array - */ - private function fileMetadata(string $file, string $namespace): array - { - return [ - 'namespace' => $namespace, - 'hash' => $this->fileHashProvider->hash($file), - ]; - } } diff --git a/tests/Cache/AnalysisResultCacheTest.php b/tests/Cache/AnalysisResultCacheTest.php index 8b04594f..b8d381ce 100644 --- a/tests/Cache/AnalysisResultCacheTest.php +++ b/tests/Cache/AnalysisResultCacheTest.php @@ -1369,10 +1369,7 @@ public function testClassNodesLoadOldCachePayloadWithoutInterfaceExtends(): void try { $this->writeCachePayload($cacheDirectory, [ - 'metadata' => [ - 'namespace' => 'config', - 'hash' => hash('xxh128', (string) file_get_contents($sourceFile)), - ], + 'metadata' => hash('xxh128', (string) file_get_contents($sourceFile)), 'nodes' => [ [ 'className' => Foo::class, @@ -2672,10 +2669,7 @@ public function testClassNodesMissWhenPayloadIsMalformed(array $payloadOverride) $cacheFile = $this->firstJsonFile($cacheDirectory); $this->writeCachePayload($cacheDirectory, [ - 'metadata' => [ - 'namespace' => 'config', - 'hash' => hash('xxh128', (string) file_get_contents($sourceFile)), - ], + 'metadata' => hash('xxh128', (string) file_get_contents($sourceFile)), ...$payloadOverride, ], $cacheFile); From 9173998a132a67b1cd68dab4c328af5f8beca907 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 8 Oct 2026 22:21:33 +0700 Subject: [PATCH 2/2] try re-enable Github macOS with PHP 8.5 --- .github/workflows/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d61bb134..9e8e7b9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,11 +20,6 @@ jobs: - operating-system: ubuntu-latest php-versions: "8.2" coverage: pcov - exclude: - # Temporarily disabled: GitHub Actions macOS runners currently fail - # to set up PHP 8.5. Re-enable once the runner image is fixed. - - operating-system: macos-latest - php-versions: "8.5" steps: - name: Checkout