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
get_class does not return false #7042
Conversation
Technically all functions could return false or null when a wrong parameter is provided, but that was undefined behavour in PHP <8 and should not be relied upon.
Ok, it did return false prior to PHP 8. I will change the PR to account for this tomorrow. |
Did it ever return false without also producing a warning? |
Not to my knowledge. See https://heap.space/xref/PHP-7.4/Zend/zend_builtin_functions.c?r=1e0bc6e3#955 |
not since PHP 5.3: Psalm is already emitting an error in all those cases. The only case where Psalm does not emit error is: https://psalm.dev/r/781da1e35e but it gives a warning even in PHP 5.2. I say we can get rid of the false return as we already did on such cases for other functions |
I found these snippets: https://psalm.dev/r/781da1e35e<?php
var_dump(get_class());
|
If we can reliably flag cases where it would return false then we don't need There's one I can think of: calling |
I found these snippets: https://psalm.dev/r/58287e0c4e<?php
echo get_class();
https://psalm.dev/r/dd677898db<?php
echo __CLASS__;
|
It's not flagged by Psalm but it never worked AND always emitted a warning or worse: https://3v4l.org/TkeS5 (weirdly, it started as a warning, then was an error, again a warning and it's now an error!) |
It's a good indication that we need to flag it. |
That should do it: #7043 |
What about this PR? Is it ok to just remove |
Just dropping |
Thanks! |
Technically all functions could return false or null when a wrong parameter is provided, but that was undefined behavour in PHP <8 and should not be relied upon.