Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84158 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70428 invoked from network); 2 Mar 2015 09:47:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Mar 2015 09:47:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 74.125.82.180 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 74.125.82.180 mail-we0-f180.google.com Received: from [74.125.82.180] ([74.125.82.180:42104] helo=mail-we0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D8/C3-48321-9B134F45 for ; Mon, 02 Mar 2015 04:47:38 -0500 Received: by wesw62 with SMTP id w62so32084636wes.9 for ; Mon, 02 Mar 2015 01:47:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:cc:content-type; bh=TYxZeCmclBmeWr2dJofG0vnahUIot99WejPce6RxdRY=; b=IBJfHrCnHf/3n5dJypVdjFb83hp9ryzqs4RykikbpNR7+ppCpMmrNm0WbMheWiXqQX WlRcZ9jqMUphUVLakgRHssbEkiZILSu+6ShC8OnNusZLLU277r+UBlYkHaVvjAOODNma G+PrPqLrVdjUYqTtVR+S59UDx5Op2g3CjiyfLtfAeok+wQRBMJR7yyX9BsNVxRG4yfnP I6D7sMZhSNpeKn7C0hzDUQLIzfWui5BF7aJQXWETErJ3IbNe5oLG2k0P0BcjHLcIS2XJ OSZK3g8JDeA7M4VOJX1pcCwtr05lOYUCclMOacxXJwMVRz+gvNcwIYxUDja2437KUll5 V4sA== X-Gm-Message-State: ALoCoQnyLoGeqox+a/DRNDx9TtIMpfQb2SDljJw3ldFywz66xWckDuycAkKXIK3KyX32E3xVuDLtAZ5vUHRkSsQ5ZNbxXK2/6/cZJhzcpiyNihzDwWiBGS3UokFlJkFW6Paci5lIAkTH3+o3JRJpYeX+hK+glb/adw== X-Received: by 10.180.211.235 with SMTP id nf11mr34708203wic.52.1425289654454; Mon, 02 Mar 2015 01:47:34 -0800 (PST) References: <54F42DDF.2070505@lsces.co.uk> In-Reply-To: <54F42DDF.2070505@lsces.co.uk> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQHbEgvqZ08kgCvmYfG4mXODzCFejgD7DxroAZSg+X8CNOWwVZzNUHPw Date: Mon, 2 Mar 2015 11:47:33 +0200 Message-ID: To: Lester Caine Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: RE: [PHP-DEV] Coercive STH - some real world tests and updated RFC From: zeev@zend.com (Zeev Suraski) > -----Original Message----- > From: Lester Caine [mailto:lester@lsces.co.uk] > Sent: Monday, March 02, 2015 11:31 AM > To: internals@lists.php.net > Subject: Re: [PHP-DEV] Coercive STH - some real world tests and updated > RFC > > Andrea's post highlights the fact that we did try a fix when PHP5 came > out. > What it fails to add is perhaps why the change was reverted? Still today > there > are people pressuring to have it restored? As this thread has shown. At > the > end of the day, this fine tuning of casting action has very little to do > with the > type hinting debate? Now IS the time to discuss the rules but not as part > of > some other RFC? It deserves it's own independent discussion as it SHOULD > apply what ever happens over type hinting. The whole discussion is presently limited to the area of type hints, and this is unlikely to change for 7.0. I think it's good to think about post 7.0 changes - perhaps bringing the rule-set to other areas of PHP (namely implicit casting), but no, it's not the time to seriously discuss this IMHO. > Thomas's example in my book is where a number of things come into play? > My first thought would be just where is this actually processed and so > where > is it trimmed? Additionally how about '001'? However it does highlight > that a > single 'int' hint is not going to satisfy everybody anyway? The thing > perhaps > to point out here is that we are looking in this case at a source that may > well > be using unicode and wonder if THAT may not be more of a problem here? Whether we have weak, strict, coercive or yellow-red type hints added to PHP, they're absolutely not supposed to satisfy everyone. They're supposed to satisfy most use cases, but not all - for the remaining X percent, you'd have to write a bit of custom code, which is fine (either do away with the hint and do custom validation, or use the hint - but do a bit of preprocessing in the calling code). It's not as if everything we deal with in scalars is going to fit into the various scalar type hint buckets anyway. Functions that accept URLs, or emails, or other types of scalar-but-specifically-formatted data have to be validated with custom code anyway. It's fine for other cases to require a bit of custom validation - as long as the key use cases are covered. I'm obviously biased but I believe that the coercive rules actually cover a lot more ground than the weak+strict sets. In other words, with weak+strict, overall, you're going to have to add custom code in a lot more cases than with the coercive rule set (either because weak is too weak and strict will very frequently be too strict, while coercive provides a rule-set that accepts sensible values and reject non-sensible ones, making it work out of the box in most cases). But even with coercive, it's definitely not a one size fits all solution, and it's not supposed to be either. You still have custom code available to you. Zeev