El estilo de
Patriarka es parecido al "Cortador" pero indentado, supongo que llamaré a este estilo "Patriarka".
Entonces
jc_moj prefiere la indentación de php.net
No me quedo claro como lo hace
pateketrueke :(
He estado buscando más información por ahí y he encontrado que originalmente los case: eran etiquetas y por lo tanto nunca deberían tabularse, o sea como el "económico".
Cita: When a label in a switch follows a "break" statement, the two are separated by a blank line. If the preceding statement is not a break, there is no blank line.
Blank lines separate each of the main sections in a file, including prologue comment (with copyright or version information, etc.), package declaration, imports and interface or class. Within a class, at least all constructors, methods and inner classes should be separated from each other and from any other fields by blank lines (always before the prologue comment, of course).
A blank line may optionally be inserted anywhere to improve readability but the use of two or more contiguous blank lines is unnecessary and should be avoided.
Sin embargo otras fuentes dicen que todo lo que está entre {llaves} debería indentarse.
Sin embargo en otro foro un usuario publicó este código:
Código PHP:
Ver originalswitch (1) {
case 1:
break;
case 2:
break;
case 3:
break;
default:
break;
}
y un corrector de scripts lanzó esta salida:
Cita: line 3, col 5, Expected 'case' to have an indentation at 1 instead at 5.
line 4, col 9, Expected 'break' to have an indentation at 5 instead at 9.
line 5, col 5, Expected 'case' to have an indentation at 1 instead at 5.
line 6, col 9, Expected 'break' to have an indentation at 5 instead at 9.
line 7, col 5, Expected 'case' to have an indentation at 1 instead at 5.
line 8, col 9, Expected 'break' to have an indentation at 5 instead at 9.
line 9, col 5, Expected 'default' to have an indentation at 1 instead at 5.
line 10, col 9, Expected 'break' to have an indentation at 5 instead at 9.
Por lo tanto también apoya a estilo "económico".
Al parecer, no hay una forma "correcta" o "incorrecta", pero esta encuesta me sirve para elegir un estandar :)
Y ustedes como hacen el switch?