-
Notifications
You must be signed in to change notification settings - Fork 669
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
check "never" return type more strictly #8624
check "never" return type more strictly #8624
Conversation
kkmuffme
commented
Oct 27, 2022
- require explicit "never" return type when function always exits
- error if function does not exit, but return type explicitly contains "never"
- Fix: Missing InvalidReturnType check when exit; #8175
- Fix: InvalidReturnType due to void and null not treated the same #8178
This snippet should still be working: |
I found these snippets: https://psalm.dev/r/3ec4cb4877<?php
abstract class Car{
abstract public function getFuel(): string{}
}
class ThermalCar{
public function getFuel(): string { return 'Gas';}
}
class ElectricCar{
public function getFuel(): never { throw new DomainException('EV need no fuel'); }
}
|
ab37a7a
to
b2acba2
Compare
The failing test is unrelated to the changes of this PR. As discussed it won't give an error for #8175 (comment) / #8624 Ready for review |
@orklah if I resolve the conflicts which popped up in the meantime, could this get reviewed & merged now? |
Yeah probably, did you check the snippet I posted above? |
Afair yes, this is still working without errors. (I even added a test for a similar case) |
* 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
b2acba2
to
694b7d8
Compare
Thanks! |
Fix never return union type wrong condition Related vimeo#8624