Re: Scalar Type Hints v0.4

From: Date: Wed, 18 Feb 2015 18:10:47 +0000
Subject: Re: Scalar Type Hints v0.4
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-83102@lists.php.net to get a copy of this message
On Wed, Feb 18, 2015 at 7:34 AM, Patrick ALLAERT <patrickallaert@php.net> wrote: > Regarding 2) and 3): > An option might be to implement "weak mode" only and configure the coercion > rules "reporting" in a similar way than with the error_reporting > configuration entry. > > ini_set("coercion_reporting", 0); // current PHP 5.x behaviour > The significant problem with this is that it effects not only the current script, but also all callees (until the next time someone flips the bit). So imagine LibraryA.php was written for PHP5, no scalar type hints, and all that comes with it. Your application turns on COERSION_WARNING and calling LibraryA::doStuff(1,2,3); That call is valid because you're a good programmer who reads the manual and knows how to pass the right args. The author of LibraryA, however, wrote it while drunk at a ruby meetup and is depending on weak conversions all over the place. They even need md5(array()) to output 4410ec34d9e6c1a68100ca0ce033fb17 (yes, I know we don't allow that anymore, enjoy the metaphor) My point is that it potentially imposes new warnings on foreign code. -Sara

« previous php.internals (#83102) next »