Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83131 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66198 invoked from network); 18 Feb 2015 22:36:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2015 22:36:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=patrick.allaert@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=patrickallaert@php.net; sender-id=unknown Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: patrick.allaert@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:53530] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4B/4E-25021-4E315E45 for ; Wed, 18 Feb 2015 17:36:20 -0500 Received: by mail-wi0-f170.google.com with SMTP id hi2so42014947wib.1 for ; Wed, 18 Feb 2015 14:36:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:references:from:date:message-id:subject:to:cc :content-type; bh=WMMT/TkMf7S4EKNvMnXr4cgpV4ygL1s7tmHctgrLJTA=; b=Bh4tN96NXh9vQVwsXrvAqfWu2WMjK1XDPFVOAXxZbnPwJLl18zaFMLEoEHRX8XlYvO ygmnOLd2V6wYG+DNkYy7wsT+hkrw48Uz1NG2MWT2++mRO7+AyqcIroOvC5shG7IoIEmS 2aW7fQxl0eu+tWLiJiXAKfiFzoPDG4WRLKIg+wsnuiyEFRKJ27mKZ1S1aSINWsfrFzRB YN4IT/0OiGXv7dTr2Avd3rIYLkM2ICyjjXm9qWgDAcImOjKjcdXv+nPyIU7Ienm+iVCe F+pnUW4SdytyTJ6Iy7yOFK2pTohiM4rdPADGl2oOR3QCxoacsgJFWCjTyNM5sdJgfSe3 dwFA== X-Received: by 10.194.157.68 with SMTP id wk4mr2842689wjb.123.1424298977127; Wed, 18 Feb 2015 14:36:17 -0800 (PST) MIME-Version: 1.0 References: Date: Wed, 18 Feb 2015 22:36:16 +0000 Message-ID: To: Sara Golemon Cc: PHP internals Content-Type: multipart/alternative; boundary=089e0112cbfc95f72b050f6472c0 Subject: Re: [PHP-DEV] Scalar Type Hints v0.4 From: patrickallaert@php.net (Patrick ALLAERT) --089e0112cbfc95f72b050f6472c0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Le Wed Feb 18 2015 at 19:10:54, Sara Golemon a =C3=A9crit= : > On Wed, Feb 18, 2015 at 7:34 AM, Patrick ALLAERT > 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). > That precisely my intention. > 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) > So, by turning it on, I would realise there is something wrong in my "LibraryA"? > My point is that it potentially imposes new warnings on foreign code. > Eureka :) That's what happened when I introduced the "Array to string conversion": lot of people complained about it and many frameworks had to fix various issues where it happened under the hood (e.g.: with array_diff() on multidimensional arrays). My point is that the same is true when adding E_NOTICE, E_WARNING, E_DEPRECATED,... to the error_reporting: it might prevent libraries to work correctly (read: without extra PHP errors). Why can't strictness follow that path? PS: your feedback makes me feel it would be; even more; a viable option :) Cheers, Patrick --089e0112cbfc95f72b050f6472c0--