Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61178 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24726 invoked from network); 12 Jul 2012 17:23:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jul 2012 17:23:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.160.170 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.160.170 mail-gh0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:36794] helo=mail-gh0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 28/B2-11045-B280FFF4 for ; Thu, 12 Jul 2012 13:23:56 -0400 Received: by ghbg2 with SMTP id g2so3144516ghb.29 for ; Thu, 12 Jul 2012 10:23:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding:x-gm-message-state; bh=k6apAfq6sDv/SLwA+LdGKF1k+OA26Fc+3svdBFdu7Ro=; b=cwWih67B+Z+PBM6VI/Plr1ccsSTHEAXveTwlxfzNo2jk5fIHnH0t2F6YeS2a1q2HWY nfdO7yyDsIXBqMuiuLDeC6RAik+BxfWvnQ3RpVkv0MCnfNmiFhFCPGRBNdIF5AgRV8HI 3URgfF5IkqVnUcBLiXxZfKAEVhe6GWuxjCZfPCLypUvQEFndu8JaN8uQeAzdy+oV4IuA 2AjH6YLsolagxVoV5nkUNs6bIatYj8JNcutj86D/tdeGdOG93m69D/XpSgIj3LiZJHSh szlRDHOqu7wThJnKTwddoYo8Gli7ExV45Ujl3fJPjlSweHKfE4Vw6DJKdcQ9d7MTBSaB Kz2A== Received: by 10.101.179.27 with SMTP id g27mr18549112anp.60.1342113832938; Thu, 12 Jul 2012 10:23:52 -0700 (PDT) Received: from [172.16.26.30] ([38.106.64.245]) by mx.google.com with ESMTPS id n37sm5006544anq.0.2012.07.12.10.23.51 (version=SSLv3 cipher=OTHER); Thu, 12 Jul 2012 10:23:52 -0700 (PDT) Message-ID: <4FFF0825.7040905@lerdorf.com> Date: Thu, 12 Jul 2012 10:23:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Stas Malyshev CC: Anthony Ferrara , "internals@lists.php.net" References: <4FFEFBB3.7090507@sugarcrm.com> <4FFEFD81.6020404@lerdorf.com> <4FFEFF71.2060202@sugarcrm.com> <4FFF0584.6080708@lerdorf.com> <4FFF0717.6050703@sugarcrm.com> In-Reply-To: <4FFF0717.6050703@sugarcrm.com> X-Enigmail-Version: 1.4.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnXDUQUvpOCdOwCBbT7X5eewCr4AI0V2HEzdvOE6t2nHrdGUl9PuDByRp7xyW93aP1gSl64 Subject: Re: [PHP-DEV] Iterable Type Hint From: rasmus@lerdorf.com (Rasmus Lerdorf) On 07/12/2012 10:19 AM, Stas Malyshev wrote: > Hi! > >> This gives quite a bit more info since we now know that it was an >> argument and specifically which argument it was, what its type was and >> what it should have been vs. having a fatal from somewhere deep in the >> function itself. So I disagree with you on it not making life easier for >> the caller in this specific case where there is no way for the type to >> be coerced into something that makes sense. > > You've traded bad error message for slightly better error message, but > on the way you've lost the ability to actually handle this situation. > Which exactly what bothers me - we're teaching people that the right way > of handling any unexpected situation is to rely on post-mortem error > logging after it blows up in runtime. I'm not sure it's such a good idea. I'm not sure what the right way would be to handle this situation. Should the function be doing this check manually, and if so, what would it tell the caller? "Hey, I was expecting a callable function but you seem to have passed me a MySQL resource handle". What else could it do? I completely agree on wanting to avoid trending people towards strict typing for interchangeable types, but this is completely different. -Rasmus