Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53125 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28734 invoked from network); 7 Jun 2011 10:09:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jun 2011 10:09:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=j.boggiano@seld.be; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=j.boggiano@seld.be; sender-id=pass Received-SPF: pass (pb1.pair.com: domain seld.be designates 209.85.214.42 as permitted sender) X-PHP-List-Original-Sender: j.boggiano@seld.be X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:62957] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5D/02-16914-0D8FDED4 for ; Tue, 07 Jun 2011 06:09:21 -0400 Received: by bwz18 with SMTP id 18so4669926bwz.29 for ; Tue, 07 Jun 2011 03:09:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.233.15 with SMTP id jw15mr3316911bkb.48.1307441357145; Tue, 07 Jun 2011 03:09:17 -0700 (PDT) Received: by 10.204.119.6 with HTTP; Tue, 7 Jun 2011 03:09:17 -0700 (PDT) In-Reply-To: <4DED5C77.8040209@sugarcrm.com> References: <4DED3A29.1090209@sugarcrm.com> <4DED43D4.4070006@sugarcrm.com> <4DED5C77.8040209@sugarcrm.com> Date: Tue, 7 Jun 2011 12:09:17 +0200 Message-ID: To: Stas Malyshev Cc: "Matthew Weier O'Phinney" , "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Callable typehint From: j.boggiano@seld.be (Jordi Boggiano) On Tue, Jun 7, 2011 at 1:02 AM, Stas Malyshev wrot= e: > Sure. How about reducing boilterplate code like this: > > if(is_readable($foo)) { > =A0$var =3D file_get_contents($foo); > } else { > =A0throw =A0InvalidArgumentException(); > } > > Why won't we make language construct to do that too? I don't think these > things belong in the language syntax. The whole point is that callables are generally not constructed from user input, they're hardcoded in the code somewhere, and so if a fatal error occurs, the developer notices it, hopefully during development. With is_readable, a file can be anywhere, anytime, readable or not, it depends on the environment the code runs on, and not on the code itself, so it's not deterministic and you should therefore be able to easily handle this gracefully. Cheers --=20 Jordi Boggiano @seldaek :: http://seld.be/