Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75475 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9341 invoked from network); 14 Jul 2014 15:30:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2014 15:30:15 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.171 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.171 mail-wi0-f171.google.com Received: from [209.85.212.171] ([209.85.212.171:59385] helo=mail-wi0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 62/C3-25444-687F3C35 for ; Mon, 14 Jul 2014 11:30:14 -0400 Received: by mail-wi0-f171.google.com with SMTP id hi2so2791200wib.16 for ; Mon, 14 Jul 2014 08:30: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=M/qO8pySkZPHLf8FZtnMlxoShUSrlWOO739ko9so+8o=; b=RgYKJvoFocm2wrnXf4YIrCvA9IDNye4GjEWSH7iClGIgkwbPtoh9FL0cPaWmdHgd93 fUxOKSCCBXZxEFwumaUiq1gvb2DrItq6F0yj0GM/qXtsFzOzqVMtQIbZSMIb0BONYfGd d1HWIoibLza9cI4YIMgZu7K/QEhoubTXffv0xNhIyieexScAmbs9kZkaKobQFe271ooI +0X3PBgpZNFtVBc1lY9FdKdOJwIiCtzfohYnOZlU2S/Gv4RumnOGva90mh/xZlNuxDxd HAUCj5wugOb70lvz4KoxmOJPTCtI7UuJQfEjMYNQxzt+huLazS2MC15YrJEmsnWjj5/Q QpRw== X-Received: by 10.194.71.12 with SMTP id q12mr20334412wju.5.1405351807406; Mon, 14 Jul 2014 08:30:07 -0700 (PDT) Received: from [192.168.0.139] ([62.189.198.114]) by mx.google.com with ESMTPSA id ed15sm32330231wic.9.2014.07.14.08.30.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Jul 2014 08:30:06 -0700 (PDT) Message-ID: <53C3F70A.7010706@gmail.com> Date: Mon, 14 Jul 2014 16:28:10 +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> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; 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) Derick Rethans wrote (on 14/07/2014): > A compromise by adding more inconsistencies. The only way of not introducing some inconsistencies (or, to put it another way, new features) is to use strict type hints, which perform no casting, and error on invalid input, since that's what the existing type hints do, in particular "array". There's broad consensus that that wouldn't be very "PHP-ish", and it has been rejected in previous discussions. Here are the main variants discussed in this thread: 1) add type hints using existing syntax, but which are actually silent casts, rather than the strict validation performed for existing types 2) add type hints using existing syntax, which are casts, but also act differently from existing casts by emitting some kind of notice 3) add cast hints using a new syntax 4) add type hints using existing syntax, which use a new "lossless cast", i.e. perform validation for completely wrong input ('abc' as an int param) but allow juggling for "reasonable" input ('123' as an int param). Option 2 (or 3) could also be implemented by making *all* lossy casts emit some kind of notice. This RFC currently proposes option 4.