-
Notifications
You must be signed in to change notification settings - Fork 671
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
InvalidReturnType due to void and null not treated the same #8178
Comments
I found these snippets: https://psalm.dev/r/f4bb991d20<?php
/**
* @return void|never
*/
function foo() {
if ( rand( 0, 10 ) > 5 ) {
return;
}
}
|
Hmmm, I don't think it actually makes sense to have a return type of |
It can make sense for assertions methods where you either throw or do nothing. but the snippet in example doesn't do that. So yeah, it's just a wrong phrasing |
Shouldn't that just combine to |
True. The case I had some times ago was something like |
I found these snippets: https://psalm.dev/r/8dad765588<?php
/**
* @return ($bar is true ? void : never)
*/
function foo(bool $bar) {
if ($bar) {
return;
}
exit;
}
https://psalm.dev/r/d162606c86<?php
/**
* @return void|never
*/
function foo(bool $bar) {
if ($bar) {
return;
}
exit;
}
|
…ts them equally already Fix: vimeo#8178
* require explicit "never" return type when function always exits * error if function does not exit, but return type explicitly contains "never" * Fix: vimeo#8175 * Fix: vimeo#8178
* require explicit "never" return type when function always exits * error if function does not exit, but return type explicitly contains "never" * Fix: vimeo#8175 * Fix: vimeo#8178
* require explicit "never" return type when function always exits * error if function does not exit, but return type explicitly contains "never" * Fix: vimeo#8175 * Fix: vimeo#8178
* require explicit "never" return type when function always exits, except if it only throws * error if function does not exit, but return type explicitly contains "never" * Fix: vimeo#8175 * Fix: vimeo#8178
* require explicit "never" return type when function always exits, except if it only throws * error if function does not exit, but return type explicitly contains "never" * Fix: vimeo#8175 * Fix: vimeo#8178
https://psalm.dev/r/f4bb991d20
void and null must be treated as the same thing.
The text was updated successfully, but these errors were encountered: