Re: RFC: Strict comparisons

From: Date: Fri, 23 Sep 2016 13:51:38 +0000
Subject: Re: RFC: Strict comparisons
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-96110@lists.php.net to get a copy of this message
Am 19.09.2016 um 15:04 schrieb Vesa Kaihlavirta <vpkaihla@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

« previous php.internals (#96110) next »