I have a switch statement that has over 300 case statements.
case 'hello':
{ $say = 'some text'; }
break;
case 'hi':
{ $say = 'some text'; }
break;
Why is it that the break is always on a separate line? Is this required? Is there anything syntactically incorrect about me doing this:
case 'hello': { $say = 'some text'; } break;
case 'hi': { $say = 'some text'; } break;
There is nothing wrong with having the break on the same line. You also don’t need the brackets.
However have you considerered rather than having a 300 case switch statment you use another method. A map of keys to values (using an array) would be faster and more maintainable.