Ich habe diesen Code in einer Funktion:Warum sauberen Code verbieten sonst Ausdruck
if ($route !== null) { // a route was found
$route->dispatch();
} else {
// show 404 page
$this->showErrorPage(404);
}
Jetzt PHPmd einen Fehler gibt:
The method run uses an else expression. Else is never necessary and you can simplify the code to work without else.
Jetzt frage ich mich, ob es wirklich besser Code wäre um das else zu vermeiden und einfach eine return-Anweisung zum if-Teil hinzuzufügen?
Gibt es also etwas besseres als phpMD? – Pascal
Lernen von http://www.phptherightway.com/ wird oft von vielen Programmierern vorgeschlagen –