2017-09-10 18:05 GMT+02:00 Theodore Brown <theodor...@outlook.com>: > On Saturday, September 9, 2017 6:21 AM, ilija.tov...@me.com wrote: > > > I find myself writing switch statements in PHP quite rarely. This has a > few reasons: > > 1. It doesn’t have a "strict_types” version > > ... > > I assume that some people will not be so happy about having to > switch-like constructs. IMO the implicit type conversion is the biggest > issue here. Maybe we could offer a solution for this one at least. > > I also rarely use switch, primarily because of the lack of strict > comparison. > Personally I would prefer having an option for strict comparison when > using switch, similar to how `in_array` has an optional `$strict` parameter. > > Would it be possible to add an optional `$strict` parameter to switch? E.g. > > ``` > switch ($i, true) { > case 1: > echo 'i is 1'; > break; > case: 1.0: > echo 'i is 1.0'; > break; > case '1': > echo 'i is "1"'; > break; > case true: > echo 'i is true'; > break; > }
I'd very much prefer a "strict switch ($i) { ... }" over a second parameter. Regards, Niklas