New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infinite loop into out of memory error for class wrongfully extending itself #7787
Comments
This bug report is missing a link to reproduction at phpstan.org/try. It will most likely be closed after manual review. |
This seems to be coming from On the other hand Also, the same thing is happening with interfaces as well, e.g. traceback
|
So I haven't tested it, but something maybe worth looking into is circular extends between multiple classes, as that might lead to the same issue? |
Yes, that's basically the core problem. Circular extends between one or more classes |
There are many similar problems that are not prevented in PHPStan:
And the same problems will cause infinite recursions in different places in the codebase for generics - where If the problem can be prevented by throwing an exception in BetterReflection, I'm all for it. I'll then rebase my own fork on top of the latest branch. |
And while we're at it, there are also constants and class constants whose values can reference themselves in a circular fashion. In BetterReflection that should be detected and prevented in CompileNodeToValue. But PHPStan doesn't use that. Here it should be prevented in InitializerExprTypeResolver. |
This is fixed now thanks to update to BetterReflection 6.0. It will produce this message: "Reflection error: Circular reference to class "Bug7787\TestClass"" |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
When creating a class that extends itself, phpstan will infinitely loop on trying to get the parent class until it is out of memory. I understand this is not valid php code, but I wonder if this might be catch-able and if this could be a normal error with an error message.
Code snippet that reproduces the problem
The share link on phpstan.org does not work because this breaks phpstan pretty badly.
Expected output
This code snippet produces an out of memory error, ideally it should probably create an error message that a class cannot extend itself.
Did PHPStan help you today? Did it make you happy in any way?
phpstan helps me all the time telling me when I made stupid typos, this tool is amazing :)
The text was updated successfully, but these errors were encountered: