Fix trait detection recursion for anonymous classes#946
Fix trait detection recursion for anonymous classes#946ondrejmirtes merged 6 commits intophpstan:masterfrom herndlm:fix-trait-detection-for-anonymous-classes
Conversation
|
Hi, I really need the test to be able to merge this. Can you push what you've tried to reproduce it? |
|
Oh I have a different behaviour now on my other machine. Sure, I'll check that out and push that then. Might take a bit. |
|
Also - please use the original source code (it has more classes): trait T
{
public function x(): void
{
\PHPStan\dumpType(parent::class);
}
}
class A {}
class B extends A
{
use T;
}
new class() extends B
{
use T;
}; |
|
Very odd, it started behaving the same strange way now too. Initially it was working (and showing another recursion problem), then I added and removed classes from the test file and now I always get reflection errors. It feels like some caching or so could be the culprit, but even after deleting all caches I can think of I have the same errors :/ when running via |
this was on purpose for now, as the PR here does not yet fix another recursion problem with |
|
So please fix all of the issues related to that bug report (otherwise it's not really a regression test for that bugreport and cannot be merged/closed). Thanks :) |
|
Your reflection error might be fixable by running "composer dump" whenever you move/add classes. |
that was really it! thx! I was not thinking that composer might be doing anything with those test files. |
|
well, looks like something is still/now broken on Windows |
|
Use |
|
maybe I should try to normalize it earlier / only once, give me a minute |
|
Thank you! |
|
Thank you too for the pointers 🎉 |
Closes phpstan/phpstan#6442, aftermath of 11176c7.
This was a missing edge case that lead to endless recursion in case the trait looking for and anonymous class using it were in the same file. By not skipping the node, it would start looking at the anonymous class, find the trait usage, start looking for the trait, find it, come to the anonymous class, find the trait usage, start looking for the trait, ..