Skip to content

Commit

Permalink
FileTypeMapper - removed one of the in-memory caches
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Dec 7, 2019
1 parent 646ea1d commit 2ec754f
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/Type/FileTypeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ class FileTypeMapper
/** @var array<string, ResolvedPhpDocBlock> */
private $resolvedPhpDocBlockCache = [];

/** @var array<string, PhpDocNode> */
private $phpDocStringCache = [];

public function __construct(
Parser $phpParser,
PhpDocStringResolver $phpDocStringResolver,
Expand Down Expand Up @@ -149,10 +146,6 @@ private function createResolvedPhpDocBlock(string $phpDocKey, NameScopedPhpDocSt

private function resolvePhpDocStringToDocNode(string $phpDocString): PhpDocNode
{
if (isset($this->phpDocStringCache[$phpDocString])) {
return $this->phpDocStringCache[$phpDocString];
}

$phpDocParserVersion = 'Version unknown';
try {
$phpDocParserVersion = \Jean85\PrettyVersions::getVersion('phpstan/phpdoc-parser')->getPrettyVersion();
Expand All @@ -162,16 +155,13 @@ private function resolvePhpDocStringToDocNode(string $phpDocString): PhpDocNode
$cacheKey = sprintf('phpdocstring-%s-%s', $phpDocString, $phpDocParserVersion);
$phpDocNodeSerializedString = $this->cache->load($cacheKey);
if ($phpDocNodeSerializedString !== null) {
$phpDocNode = unserialize($phpDocNodeSerializedString);
$this->phpDocStringCache[$phpDocString] = $phpDocNode;
return $phpDocNode;
return unserialize($phpDocNodeSerializedString);
}

$phpDocNode = $this->phpDocStringResolver->resolve($phpDocString);
if ($this->shouldPhpDocNodeBeCachedToDisk($phpDocNode)) {
$this->cache->save($cacheKey, serialize($phpDocNode));
}
$this->phpDocStringCache[$cacheKey] = $phpDocNode;

return $phpDocNode;
}
Expand Down

0 comments on commit 2ec754f

Please sign in to comment.