Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80095 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72681 invoked from network); 2 Jan 2015 14:06:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jan 2015 14:06:58 -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.216 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.216 imap10-3.ox.privateemail.com Received: from [192.64.116.216] ([192.64.116.216:46786] helo=imap10-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 90/02-61219-106A6A45 for ; Fri, 02 Jan 2015 09:06:58 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id B04212400AA; Fri, 2 Jan 2015 09:06:54 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap10.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap10.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id YT5rvqLRcEjk; Fri, 2 Jan 2015 09:06:54 -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 A14782400A9; Fri, 2 Jan 2015 09:06:53 -0500 (EST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: <54A6A4D3.9070808@seld.be> Date: Fri, 2 Jan 2015 14:06:20 +0000 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: <41D5BB0B-73AF-488E-968D-90B2878E3178@ajf.me> <54A5DF14.7000105@gmail.com> <54A678EA.4070706@fischer.name> <54A6A4D3.9070808@seld.be> To: Jordi Boggiano X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints From: ajf@ajf.me (Andrea Faulds) Hey Jordi, > On 2 Jan 2015, at 14:01, Jordi Boggiano wrote: >=20 > And I, on the other hand, disagree. >=20 > Looking at it from an OSS maintainer perspective, introducing strict = hints in code would be a huge BC break as I don't know how people use my = code, nor if they validate/coerce their user input early or not. If I = suddenly declare something as int and someone used to pass '5', they get = an error. That would make adoption quite hard in OSS IMO if you don't = want to bother people. >=20 > With weak typing on the other hand, I get to remove tons of @param = annotations which would be amazing, and I get additional safeties that = *new* mis-uses (like passing an object in an arg expecting a string, = which at the moment could not be type hinted) will be caught early in = the future. > Existing mis-uses probably don't exist much since they'd likely fail = further down in the code execution already, but in case they don't = they'd be caught too and that's a good thing since it makes people look = at their buggy code. > As for valid uses of the code, like the '5' above, it keeps working = just fine because it is fine. It's not my call as a library author to = decide whether the users of the lib should cast user inputs to ints or = validate them or do nothing at all. This is an excellent point which had never occurred to me before! Yes, = weakly-typed hints like these are far less likely to break existing = code. I should probably mention that in the RFC. Thanks! -- Andrea Faulds http://ajf.me/