Open ygottschalk opened 4 years ago
I found these snippets:
After CI finished, I found this unit test in the validCode
section (which fails with my provided commit):
<?php
$a = rand(0, 1) ? "a" : "b";
switch ($a) {
case "a": break;
case "b": break;
default:
throw new \Exception("should never happen");
}
After finding that, I'm not sure what should be the correct behaviour.
I would argue, that the unit test given above should pass, while the code snippet I gave above should emitt an issue. This would require to differentiate between return
-ing and throw
-ing case statements in SwitchCaseAnalyzer
(and maybe SwitchAnalyzer
).
Any opinions?
Maybe the best would be, to have a config value allowParadoxicalDefaultWithExit = ['return', 'throw', 'exit_function']
https://psalm.dev/r/0fa3a37e03 https://psalm.dev/r/6aa20eea86