-
-
Notifications
You must be signed in to change notification settings - Fork 913
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
Property is suddenly undefined #10477
Comments
Opening the Try link it's dumping
I presume because the |
Interesting behaviour! Passing But passing a different variable changes it: https://3v4l.org/XMTjK PHPStan should reflect this. |
What's more interesting is that it's any other variable , even a renamed The reasoning is most likely backwards compatibility with PHP 4. As in PHP 4 class instances were value types (instead of reference types) so had to be passed by reference so the callee could/would actually modify the state of the object (also in the call site and not just in the called functions scope). |
Seems like PHP just ignores the by reference directive when the "source" is |
Well, if you try and assign something to |
It looks like the reference is broken if you try and change the |
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
I have class A which I can change, and class B which I don't have control over.
The output is this:
I don't understand 2 things:
$this->foo
is changed tomixed
$this->foo
is suddenly undefined?Code snippet that reproduces the problem
https://phpstan.org/r/40d3135d-7d52-4ebe-bb1c-7f23b4ecb4f4
Expected output
Did PHPStan help you today? Did it make you happy in any way?
Still love the tool!!
The text was updated successfully, but these errors were encountered: