fix: nested trait @use, use original class file name to get trait data#4813
Merged
ondrejmirtes merged 3 commits intophpstan:2.1.xfrom Jan 23, 2026
Merged
fix: nested trait @use, use original class file name to get trait data#4813ondrejmirtes merged 3 commits intophpstan:2.1.xfrom
@use, use original class file name to get trait data#4813ondrejmirtes merged 3 commits intophpstan:2.1.xfrom
Conversation
9c90049 to
9f8e0a9
Compare
Member
That's what variable cache key (2nd parameter of the load() method is for. When the cache becomes stale, you need to bump the number in the source code. |
9f8e0a9 to
93ea1f2
Compare
Contributor
Author
|
I suppose it needs to be bumped then as part of this fix to clear out all the bad caches? |
ondrejmirtes
requested changes
Jan 23, 2026
Member
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hello!
Git bisect shows that commit d8ec11f introduced a regression in nested trait
@useresolution, e.g., the following no longer passes the template to the base trait:This bug only seems to show up when the classes are in different files and namespaces, so it was impossible to replicate on the playground (see https://phpstan.org/r/985be0cb-f0ba-47e9-8f3c-3f7f63dccdfa). In the e2e test, I also tried to just have a
data/directory withframework.phpand asrc.phpfiles that had the respective namespace and classes in them but that passed and did not replicate the failure. So sorry for the 6 individual classes / files but this was the only way that I could replicate.Note
I'm not sure if this is the best fix, this was just suggested by the AI agent that was helping me diagnose the cause of this regression. This does however, fix the issue I was having...
Warning
There seems to be some additional caching going on that's not being cleared by
phpstan clear-result-cache. Running the following command before and after the commit that fixes the issue does not result in a different output unless thetmp/directory is completely cleared in between runs (i.e., if ran before the fix and then ran after the fix the command still results in an error when it should be passing; and the same backwards, running after the fix and then before the fix results in a passing command which should be failing):Thanks!