Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85034 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85611 invoked from network); 16 Mar 2015 11:54:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2015 11:54:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=davidkmuir@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=davidkmuir@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.182 as permitted sender) X-PHP-List-Original-Sender: davidkmuir@gmail.com X-Host-Fingerprint: 209.85.192.182 mail-pd0-f182.google.com Received: from [209.85.192.182] ([209.85.192.182:35392] helo=mail-pd0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 59/63-03331-784C6055 for ; Mon, 16 Mar 2015 06:54:48 -0500 Received: by pdbop1 with SMTP id op1so56451687pdb.2 for ; Mon, 16 Mar 2015 04:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:in-reply-to:mime-version:content-transfer-encoding :content-type:message-id:cc:from:subject:date:to; bh=JDzgcymIkAwuAJDielJekPrePoz+4ziMM5kTITOLwzg=; b=nZedmX+WitMgUjhdhPR7Em+fGfxIQjK6/9UGfLp4BNL8Gl/9eQu2vWdTjxmbtVTLjV iSgKFALvQUGmiCY3lW8ZGihj0pMYr2sr7jcgCqycOntIfpsrww+w4YxTASO6EVUdShdR YyNAJvluOtxQDkwfOy6rZ4eaC+KJTegnFwz2LzHOZerUI6zCJ+0yn8GJBENEGTMtEb6w x9pvP2ReJVLHpgLBqywIYBqmitdvyc/BGaoe+irH2CuRFm5iW3gpFw/3NkH87zqj58+M 6ExQhZq9EkFg2X3UIoNXAihdVoV9ERGMbuYi856pFDpeGFVG3LOUkFQGlLaR2Lf9WAyC SsaA== X-Received: by 10.66.66.196 with SMTP id h4mr135178610pat.127.1426506884252; Mon, 16 Mar 2015 04:54:44 -0700 (PDT) Received: from [192.168.0.2] (115-64-165-88.static.tpgi.com.au. [115.64.165.88]) by mx.google.com with ESMTPSA id j5sm16994040pdo.60.2015.03.16.04.54.43 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Mar 2015 04:54:43 -0700 (PDT) References: <55033D61.8050405@lsces.co.uk> In-Reply-To: <55033D61.8050405@lsces.co.uk> Mime-Version: 1.0 (1.0) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-ID: Cc: "internals@lists.php.net" X-Mailer: iPhone Mail (11D257) Date: Mon, 16 Mar 2015 22:54:37 +1100 To: Lester Caine Subject: Re: [PHP-DEV] STH and the 3 RFCs From: davidkmuir@gmail.com (David Muir) >> On 14 Mar 2015, at 6:41 am, Lester Caine wrote: >>=20 >> On 13/03/15 18:53, guilhermeblanco@gmail.com wrote: >> By considering PHP's nature, having a dual mode is a WTF. I can see mysel= f >> asking multiple times a day "is this file strict or not?" to trace >> potential bugs or type juggling. I do want strict, but I don't think it's= >> the right time for PHP to make this move. Userland would have strictness,= >> but all internal functions are a weird WTF type juggling mode. I original= ly >> switched my vote many times in the v3 of the RFC, mainly because PHP >> developers are the ones that would suffer by these configurability on a >> daily basis. I ended up with a YES vote because when considering STH or >> nothing at all, I prefer to have some. >=20 > The bigger WTF is perhaps that moving forward one has no idea just what > a third party library is using internally. A case has been made that > this does not matter since calling that library from a non-strict site > will simply work as now, but in that case the library is not designed to > handle non-strict input. It assumes that the strict check happens, where > a well designed 'weak' library will be handling the edge cases properly. > It not simply a matter of "is this file strict or not?" but rather "what > happens when I pass the wrong data?". If I've understood the RFC's correctly, your point is moot. With any scalar t= ype hints, a library will not be able to tell how it is being called. All it= knows is that it has received an int, string, float, or boolean where it ha= s asked for one. A library written in weak or strict mode will have no beari= ng on its public API. This is the case with all of the STH RFCs.=20 So no, a weak mode library is not better off. It is actually worse off becau= se it has more edge cases where things could go wrong (internally), while a s= trict library will not function at all until the edge cases are actually tak= en care of. As far as being a user of the library itself, the strictness or weakness of t= he library code is irrelevant. You can use a weak library in strict mode, an= d the library would never know or care. if you decide to make all your own code strict, you're not changing the beha= vior of the library. If you make all your own code weak, you're not changing= the behavior of the library. Even if you strips out all the declare strict s= tatements, it will not change the behavior of the library (except in the cas= e where the code was broken and wasn't even working previously!). I think the best way to explain the dual mode RFC is to think of it like thi= s: Imagine PHP threw a COERCIBLE_TYPE_MISMATCH notice whenever you pass the wro= ng type to a function. In weak mode, the type gets coerced, the notice is ig= nored, and we truck along as if nothing happened. Strict mode is basically w= here you've set up a custom, per-file error handler where COERCIBLE_TYPE_MIS= MATCH notices are turned into fatal errors. It is your code that decides whi= ch error handler to use. Cheers, David