Skip to content

Conversation

@hostep
Copy link
Collaborator

@hostep hostep commented Jan 28, 2026

I ran into a weird situation a couple of times where phpstan loaded a Magento extension attribute interface but not with the expected methods being included.

After some deep debugging, it turned out it was loading the generated extension attribute interface from a totally different project, but since it was using the exact same class name as the other project, it used the one generated from the other project instead of generating a new one.

This is unrelated to phpstan's result cache, but instead is coming from the file cache storage this phpstan extension is using.
So I've updated it to also include the magentoRoot variable (which is just the current working directory) in the hash it generates for the cache directory.

After some quick testing, I no longer get false positives/negatives anymore when phpstan runs across multiple projects now.

Let me know if this doesn't make sense, and we can further see how we can improve this.
I don't quite like that we only use the first 4 characters of this hash as the chances on collisions are still very high, not sure why that hash was truncated to only 4 characters? Possibly to avoid too long directory names?


Temporary workaround until this PR gets approved, for the people interested, if you overwrite the tmpDir to something else per project, in your phpstan.neon file, that also solves this issue, example:

parameters:
    tmpDir: %currentWorkingDirectory%/var/phpstan

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.

1 participant