I find the idea of making ‘==‘ which has always been a loose comparison, have a new optional way to be ‘more strict’ than ‘===‘ to be quite odd. I would however love a way to have strict comparisons in a switch statement.
Cheers Stephen > On 23 Sep 2016, at 20:51, Christian Schneider <cschn...@cschneid.com> wrote: > > Am 19.09.2016 um 15:04 schrieb Vesa Kaihlavirta <vpkai...@gmail.com>: >> <?php declare(strict_comparisons=1); >> >> $two = "2"; >> if ($two > 1) { >> echo "This sorta works without strict_comparisons=1" . PHP_EOL; >> } >> >> ...would throw a TypeError exception after this change. > > This sounds like a bad idea to me: Changing the language semantics of > something so basic as the comparison operators seems like asking for trouble. > One programmer will try to incorporate code from non-strict parts into strict > parts and possibly gets exceptions even though the code works. Another > programmer is puzzled about all the type casts (or even try/catch constructs) > when moving code the other way around. > > On top of that: Making it a runtime-setting or file-wide declaration seems > like the most troublesome option. > Reminds me way too much of magic quotes :-) > > Let's take a step back: If you want type-safety and your program is more or > less well-structured then type declarations on function parameters should > IMHO be more than sufficient. > > Regards, > - Chris > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php