I'm currently working on a php frontend. Specifically, the authentication process.
I'll spare everyone the exact details of the decision tree, but it includes a lot of checks and about half of them branch to a call to do_logon() which generates the login page and then calls exit to stop processing further.
Currently, I follow up each of those calls with another exit statement in the branch itself:
if($db->authenticate($user,$password)) {
... continue processing checks...
} else {
$message='Invalid password';
do_logon($message,true);
exit;
}
Despite knowing that that final exit will never actually be called because do_logon ends on an exit.
My reasoning is that while I know that do_logon will always exit, other people who may wind up working on this codebase may not, or if I'm asked to maintain this code half a decade from now I might not remember, so adding the superfluous exit statement doesn't alter the code flow but does make it clear that processing will stop there, but am I overlooking something?
do_logondo one thing only, instead of generating the login page and sending it to the browser and exiting. I'd structure this asecho render_template("logon", [$message, true]); exitdo_logoncallsexit. It implies that your code has bad structure.