Make cache key unique per project (so per current working directory). #347
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
magentoRootvariable (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
tmpDirto something else per project, in yourphpstan.neonfile, that also solves this issue, example: