I've seen a lot of heavy nesting caused by the belief that functions should only have one return statement. Ex:
// Original
function render() {
$return = null;
if($condition1) {
if($condition2) {
$return = 2;
} else {
$return = 1;
}
} elseif($condition3) {
$return = 3;
} else {
$return = 4;
}
return $return;
}
But I'd rather read: // Refactored
function render() {
if($condition1 && $condition2) return 2;
if($condition1) return 1;
if($condition3) return 3;
return = 4;
}