Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75405 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46286 invoked from network); 13 Jul 2014 14:41:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jul 2014 14:41:45 -0000 Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.177 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 209.85.220.177 mail-vc0-f177.google.com Received: from [209.85.220.177] ([209.85.220.177:49403] helo=mail-vc0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C6/95-16748-8AA92C35 for ; Sun, 13 Jul 2014 10:41:45 -0400 Received: by mail-vc0-f177.google.com with SMTP id ij19so5337191vcb.8 for ; Sun, 13 Jul 2014 07:41:42 -0700 (PDT) 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=LNtVLVe2iHKF0LLq1pdvI6k0PHJXn9Ttx20EshLlCME=; b=ZPj3rN4ZIgzm35lbhBhakXErwV7JRGp1OXTjviBk8ZwYMF732SQ8TmvtOXJkd8MtiE huemYTiMX43pMXv2buX2UpzBXFsnxXm+VGy45sfOoFAV9RG8KjtgRUb1WPJ0HZRrV5M6 HSXqSrlltaO3CFR7lMdbZdYMqe2Dd7mSbb8ho27t+p/SWPdINVyfEraUsc1LwLi6BC6c +MGidGSMJQSK1N4qpr2fS1mRKORUbXzhxvDw6yGXTwFbXQEjbxGI/vx9wu40QdC/qAkc 6gfwIEJ53N94pEHPbSn2S8/31apwZLu66PhIiD7Ycqmm/LrEt6wHcGisdaM0vafcW+Ix 9eow== X-Gm-Message-State: ALoCoQkxjYeQJX0dHFqf5L4TfF4tGZL6b11LfQykrIkvLJdtTOy4UVxcg1HHY04A2D6r7rBx5a6cLs0nkeaVvLvI0FB7hThywufRVUW8dSQwFx3ZWiPRTMvz03mIosoKcmHPPmouFMnt X-Received: by 10.58.150.1 with SMTP id ue1mr10780265veb.11.1405262501955; Sun, 13 Jul 2014 07:41:41 -0700 (PDT) References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> <027E65EF-C4FC-474C-92BB-D99EFADDEEED@ajf.me> In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJuUFVOlGiX172RfpkkW7aXwqSXwwOWY2SKAql1dl4CVdDzGgKRSJF6mgd3VPA= Date: Sun, 13 Jul 2014 17:41:41 +0300 Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: RE: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: zeev@zend.com (Zeev Suraski) > -----Original Message----- > From: Andrea Faulds [mailto:ajf@ajf.me] > Sent: Sunday, July 13, 2014 5:34 PM > To: Zeev Suraski > Cc: Nikita Popov; PHP internals > Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) > > > On 13 Jul 2014, at 15:31, Zeev Suraski wrote: > > > I think this is a big step in the wrong direction to one of the most > > common auto-conversion use cases out there (HTTP input variables). > > See my note to Nikita... > > > > This RFC is a huge deal, I suggest we let more people voice their > > opinion in before changing it in each direction :) > > > > Zeev > > Yes, I might have acted a little too quickly. However, I'm not sure "12a" is such > a common case. With the strict behaviour, foobar(" 12") and foobar("12") still > work, however foobar("12 ") unfortunately would not. I don't think it's a common intentional case, but when writing code defensively - you need to be prepared for whatever someone might through at you... Say I have a form that accepts 'age', and I expect users to type in their age. As one that develops the backend, it's great if I can simply stick an 'int' in the function signature that deals with this $_GET['age'], and know that whatever the user typed in - it would turn it to the most sane integer value. In other words, if someone types in '12a' (by mistake or intentionally), I think it's a very sane behavior to just treat it as 12, as opposed to forcing me (the developer) to write error handling code with a try/catch block, and a fairly hairy try/catch block too. Your example of "12 " (that I didn't even think about before) is an even a more likely scenario, but I think there's no strong reason not to allow both. Zeev