Hello together, i often write switches, where i throw an Exception when something unknown come in, rather than using a default value.
switch($myVar){ case 1: doSomethingElse(); break; case 2: doSomething(); break; //... default: throw new Exception('Undefined input: ' . $myVar); break; } I would like to write something like this: switch($myVar){ //... default: throw new Exception('Undefined input: ' . get_the_used_switch_variable()); break; } The `get_the_used_switch_variable()` is just a placeholder, name can be changed to something natural...maybe a constant. It's really usefull, when dealing with nested objects like when you work with Doctrine. Best regards Martin