Skip to content

Store PhpStorm stub paths relative to the stubs package in the reflection cache - #6153

Open
SvenHerrmann wants to merge 1 commit into
phpstan:2.2.xfrom
SvenHerrmann:bugfix/relative-instead-of-absolute-paths-for-phpstorm-stub-cache
Open

Store PhpStorm stub paths relative to the stubs package in the reflection cache#6153
SvenHerrmann wants to merge 1 commit into
phpstan:2.2.xfrom
SvenHerrmann:bugfix/relative-instead-of-absolute-paths-for-phpstorm-stub-cache

Conversation

@SvenHerrmann

Copy link
Copy Markdown

fixes #15023

@ondrejmirtes

Copy link
Copy Markdown
Member

I'm skeptical here because this isn't the only thing that's stored with absolute filename in the cache. Why it's a problem here but not in other cases?

@SvenHerrmann

SvenHerrmann commented Jul 30, 2026

Copy link
Copy Markdown
Author

In the other cases, the absolute path (or a hash of it) is part of the cache key.
So in fact you have two cache items in that cases - one for each absolute project path

e.g.

$variableCacheKey = $this->getVariableCacheKey($this->fileName);
$presentSymbolsCacheKey = sprintf('osfsl-%s-presentSymbols', $this->fileName);
$cached = $this->cache->load($presentSymbolsCacheKey, $variableCacheKey);
(cache key depends on fileName)

vs.

$cacheKey = sprintf('phpinternal-%s-%s', $identifier->getType()->getName(), $name);
$variableCacheKey = $this->getVariableCacheKey();
$cached = $this->cache->load($cacheKey, $variableCacheKey);

private function getVariableCacheKey(): string
{
return $this->variableCacheKey ??= sprintf(
'v1-%s-%s-%s',
ComposerHelper::getBetterReflectionVersion(),
ComposerHelper::getPhpStormStubsVersion(),
$this->phpVersion->getVersionString(),
);
}

(cache key only depends on versions)

I assume, the path was omitted as part of the cache key, as normally you wouldn't have a real file for an internal function.

@ondrejmirtes ondrejmirtes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like an E2E test that shows the problem in e2e-tests.yml and e2e/ directory instead.

It's possible I'll just solve it by reverting the cache, the wins were small anyway, or maybe with a different solution than this PR presents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal error: Incorrect path for vendor files inside phpstan.phar

2 participants