Skip to content

Commit

Permalink
[NodeTypeResolver] No need json_decode/json_encode for cache class na…
Browse files Browse the repository at this point in the history
…me collection (#5881)
  • Loading branch information
samsonasik authored May 15, 2024
1 parent 3cf5b1a commit 6bd2b87
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions src/FamilyTree/Reflection/FamilyRelationsAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,11 @@ private function loadClasses(): void
$key = $this->dynamicSourceLocatorProvider->getCacheClassNameKey();
$classNamesCache = $this->cache->load($key, CacheKey::CLASSNAMES_HASH_KEY);

if (is_string($classNamesCache)) {
$classNamesCache = json_decode($classNamesCache);
if (is_array($classNamesCache)) {
foreach ($classNamesCache as $classNameCache) {
try {
$this->reflectionProvider->getClass($classNameCache);
} catch (ClassNotFoundException) {
}
if (is_array($classNamesCache)) {
foreach ($classNamesCache as $classNameCache) {
try {
$this->reflectionProvider->getClass($classNameCache);
} catch (ClassNotFoundException) {
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private function collectClasses(AggregateSourceLocator $aggregateSourceLocator,
$key = $this->getCacheClassNameKey();
$classNamesCache = $this->cache->load($key, CacheKey::CLASSNAMES_HASH_KEY);

if (is_string($classNamesCache)) {
if (is_array($classNamesCache)) {
return;
}

Expand All @@ -162,6 +162,6 @@ private function collectClasses(AggregateSourceLocator $aggregateSourceLocator,
} catch (CouldNotReadFileException) {
}

$this->cache->save($key, CacheKey::CLASSNAMES_HASH_KEY, json_encode($classNames));
$this->cache->save($key, CacheKey::CLASSNAMES_HASH_KEY, $classNames);
}
}

0 comments on commit 6bd2b87

Please sign in to comment.