switch
statements found PHP-W1091Nested switch
statements are difficult to understand and affect code readability. In addition, it is considered a code smell since they are harder to maintain and can easily be confused with the outer switch
statement. Therefore it is recommended to avoid using nested switch
statements or consider moving the inner switch
to another function/method.
switch ($i) {
case 0:
switch ($j) {
case 1:
// some implementation here..
break;
}
break;
case 1:
echo "i equals 1";
break;
default:
echo "default";
}
switch ($i) {
case 0:
check_val($j);
break;
case 1:
echo "i equals 1";
break;
default:
echo "default";
}
function check_val($j) {
switch ($j) {
case 1:
// some implementation here..
break;
}
}