Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80102 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89881 invoked from network); 2 Jan 2015 16:40:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jan 2015 16:40:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:55332] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 98/50-22504-ED9C6A45 for ; Fri, 02 Jan 2015 11:39:58 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 5BB62B00093; Fri, 2 Jan 2015 11:39:55 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id aQUJ0MhHRolP; Fri, 2 Jan 2015 11:39:55 -0500 (EST) Received: from [192.168.0.13] (unknown [94.13.96.117]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 4D2BDB00058; Fri, 2 Jan 2015 11:39:54 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: Date: Fri, 2 Jan 2015 16:39:21 +0000 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <41D5BB0B-73AF-488E-968D-90B2878E3178@ajf.me> To: Matthew Leverton X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints From: ajf@ajf.me (Andrea Faulds) Hey Matthew, > On 2 Jan 2015, at 16:35, Matthew Leverton wrote: >=20 > I'd much prefer if they were strict types. I have a bias toward this > because I prefer to be as strict as possible. It's not hard to type > my_func((int) $_GET['foo']) if I want easy conversion. This explicit > cast serves as a reminder that I'm being sloppy. I can quickly scan > and see if there are parts of my code that are more prone to bugs. One problem with explicit casts like (int) is they never throw errors, = unlike implicit casts. takes_int([]) is an error, (int)[] isn=E2=80=99t. = There was a safe casting functions RFC, but that was rejected. Still, = yes, you have a point in that the sloppiness is more obvious. > But I'm not opposed to the RFC. I think it's *way* better than > nothing, and I understand the arguments in its favor. My one > complaint: I don't like that it emits a notice. I treat notices as > broken code, and if it's proper to say (int) "7 things", then it ought > to be proper to send that into a function. With notices being a > possibility, I'll need to manually add (int) in front of everything > ... at which point, we might as well have strict types. (Off-topic and > different RFC, but I think having return types that auto-cast is > weird, which is another reason I'd prefer strict types all around.) I=E2=80=99m not a fan of this behaviour either, but it is the behaviour = we already have. Another RFC could fix it. I should probably write one. > Finally, I'm not sure that implementing both (strict / type juggling) > with different syntax is a good idea. I think I'd prefer one or the > other. I don't really want to keep track as a user of many composer > libs (etc) which authors decided I need to use strict types. Because I > wouldn't want to have two different styles of code depending on the > library I'm using, I'd end up again going back to assuming everything > was a strict type. This is how I feel. Thanks. -- Andrea Faulds http://ajf.me/