Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75419 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67606 invoked from network); 13 Jul 2014 15:36:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jul 2014 15:36:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.178 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.178 mail-wi0-f178.google.com Received: from [209.85.212.178] ([209.85.212.178:64753] helo=mail-wi0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9C/2A-16748-B67A2C35 for ; Sun, 13 Jul 2014 11:36:13 -0400 Received: by mail-wi0-f178.google.com with SMTP id hi2so1398427wib.11 for ; Sun, 13 Jul 2014 08:36:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=S8+QPi1aahFXhLcuQUwqryegI2zbnxoPc/MTdtunrSQ=; b=EKzT5Ds///jhJZ0Bzpb+O73fmxVZgfMXhMpXqAiQMEQc4M/hCaORWKALAai3CZPeXK xFlMIM5XRoD8ZLlHTEP2fXWExxqP68Da8kEAEc8r6D9Pny0HT4xUS1535uaTxaul/9Nk qNXdol0IxM4/kWZivp5m7TrIiFaIaX8Q2LEdQiK2OR1TpTwOwIy+aXzdtE79KU2C5T9/ 9K7hoEKUagBPqHLz4EkwPLXgQRveZc0ZpU5tDaQYsBsgT+qJmKdx+HRzIVLs47Cjtx6o G3NLPts4ifPukKfUrUmACenVprTkPEkQzanqoMQej2hrZKs97AtWAz+H3S7NCN0Oi7hy q4zA== X-Received: by 10.194.87.97 with SMTP id w1mr13116749wjz.42.1405265768651; Sun, 13 Jul 2014 08:36:08 -0700 (PDT) Received: from [192.168.0.2] (cpc19-brig17-2-0-cust25.3-3.cable.virginm.net. [81.101.201.26]) by mx.google.com with ESMTPSA id eo4sm20052255wid.4.2014.07.13.08.36.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 13 Jul 2014 08:36:08 -0700 (PDT) Message-ID: <53C2A765.8010707@gmail.com> Date: Sun, 13 Jul 2014 16:36:05 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: internals@lists.php.net References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> <53C2178E.7070705@sugarcrm.com> In-Reply-To: <53C2178E.7070705@sugarcrm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: rowan.collins@gmail.com (Rowan Collins) On 13/07/2014 06:22, Stas Malyshev wrote: > I have one request: could we please stop calling it "hinting"? I've always thought the current "type hinting" should be called "type assertion", since passing the wrong data type is detected only at runtime, and causes an error in much the same way as if you wrote assert($param instanceof HintedClass). What this RFC proposes is more like "type validation" - detecting that the given input can be safely coerced to the given type, and performing the coercion in the process. As Andrea points, out, it's similar to what Nikita called[1] "strict weak type hinting", but with the added step of performing the cast, which is really just a convenience, since if you've asked for a value to be validated as an int, you're presumably about to use it as one. [1] http://nikic.github.io/2012/03/06/Scalar-type-hinting-is-harder-than-you-think.html -- Rowan Collins [IMSoP]