Skip to content

Commit 20b67e0

Browse files
committed
store on every change
1 parent c02b70e commit 20b67e0

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/Reflection/BetterReflection/SourceLocator/FileCachedSourceLocator.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function locateIdentifier(Reflector $reflector, Identifier $identifier):
5252

5353
if (!array_key_exists($className, $this->cachedSymbols['classes'])) {
5454
$this->cachedSymbols['classes'][$className] = $this->locator->locateIdentifier($reflector, $identifier);
55-
$this->storeOnShutdown();
55+
$this->storeCache();
5656
}
5757
return $this->cachedSymbols['classes'][$className];
5858
}
@@ -61,7 +61,7 @@ public function locateIdentifier(Reflector $reflector, Identifier $identifier):
6161

6262
if (!array_key_exists($className, $this->cachedSymbols['functions'])) {
6363
$this->cachedSymbols['functions'][$className] = $this->locator->locateIdentifier($reflector, $identifier);
64-
$this->storeOnShutdown();
64+
$this->storeCache();
6565
}
6666
return $this->cachedSymbols['functions'][$className];
6767
}
@@ -70,7 +70,7 @@ public function locateIdentifier(Reflector $reflector, Identifier $identifier):
7070

7171
if (!array_key_exists($constantName, $this->cachedSymbols['constants'])) {
7272
$this->cachedSymbols['constants'][$constantName] = $this->locator->locateIdentifier($reflector, $identifier);
73-
$this->storeOnShutdown();
73+
$this->storeCache();
7474
}
7575
return $this->cachedSymbols['constants'][$constantName];
7676
}
@@ -90,16 +90,6 @@ private function getVariableCacheKey(): string
9090
return sprintf('v2-%s-%s', ComposerHelper::getBetterReflectionVersion(), $this->phpVersion->getVersionString());
9191
}
9292

93-
private function storeOnShutdown(): void
94-
{
95-
if ($this->storeOnShutdown) {
96-
return;
97-
}
98-
99-
$this->storeOnShutdown = true;
100-
register_shutdown_function([$this, 'storeCache']);
101-
}
102-
10393
/** @return array{classes: array<string, ReflectionClass|null>, functions: array<string, ReflectionFunction|null>, constants: array<string, ReflectionConstant|null>} */
10494
private function loadCache(Reflector $reflector): array
10595
{

0 commit comments

Comments
 (0)