Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59025 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71811 invoked from network); 19 Mar 2012 04:17:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Mar 2012 04:17:41 -0000 Authentication-Results: pb1.pair.com header.from=adamjonr@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=adamjonr@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: adamjonr@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:35071] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0E/79-41178-463B66F4 for ; Sun, 18 Mar 2012 23:17:40 -0500 Received: by obbup19 with SMTP id up19so843584obb.29 for ; Sun, 18 Mar 2012 21:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ewr3gUEBudKgAfJLWSAztqVFeithBClIeLw25cqhVBA=; b=D1ngasg/EvMQMjZOvRbQasEUUOhZDoI25/FHk1ZUWu7ye8+5LRbmTDvxmzIoqFG1c0 hUF7lvaAmIQL27ONVUN9kGvMSxxyZpFSeLM2vXvVyxqjOckXnRDp1W61f/LHkM72C25V /slwLlq6u4wWa7UDcLI3ayd3qBUbOChafBNUM5bq6N2tlkDAf7GLzqhe2Ytx3hOcpdGs cezxP0dkm2uwD511/x5aLm0MLA0kkJrkYQefFcXPHZ/GZolXpL7Rzqexy0FlKskUQZcs YkibpYevlLerwNm42h1zf+wKJHuY7HJgCIoAukeAkGDdNfx6u46Y8krrYDdu1D0Y8jer 3+/Q== MIME-Version: 1.0 Received: by 10.182.12.6 with SMTP id u6mr12137099obb.12.1332130657611; Sun, 18 Mar 2012 21:17:37 -0700 (PDT) Received: by 10.182.128.68 with HTTP; Sun, 18 Mar 2012 21:17:37 -0700 (PDT) In-Reply-To: References: Date: Mon, 19 Mar 2012 00:17:37 -0400 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=f46d0444edd3a4310804bb90d6be Subject: Re: [PHP-DEV] Scalar-type-hinting - which way is the best to go? From: adamjonr@gmail.com (Adam Jon Richardson) --f46d0444edd3a4310804bb90d6be Content-Type: text/plain; charset=ISO-8859-1 On Sun, Mar 18, 2012 at 7:11 PM, Simon Schick wrote: > Hi, Adam > > I totally agree that type-hinting should not cover what the programmer > should do for validating the given input ... > But I just wanted to point out that this is something the author (and > I) would never expect to happen ... > > in_array("123abc", array(3, 7, 123, 28)) === true > Hi Simon, That's how we differ in terms of perspective. When I see that in_array() accepts a third argument $strict and that $strict defaults to false, in_array("123abc", array(3, 7, 123)) === true is the behavior I expect for that function: http://php.net/manual/en/function.in-array.php That said, perhaps the documentation could be augmented to help clarify the issue. While example 2 on that page illustrates a non-match using the strict check, it does seem like showing the opposite (a surprising match when $strict is false, such as in the example your link pointed to) would also prove beneficial to users, too. Nice commentary. Adam --f46d0444edd3a4310804bb90d6be--