Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53090 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4466 invoked from network); 6 Jun 2011 22:27:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2011 22:27:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-wy0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:53429] helo=mail-wy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 28/94-23189-3345DED4 for ; Mon, 06 Jun 2011 18:27:00 -0400 Received: by wyb34 with SMTP id 34so3574987wyb.29 for ; Mon, 06 Jun 2011 15:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=lmnlU+NkRpGJPC9c2sRHa92TflQZoA+gY4Gvi2LEdmY=; b=wqlNXeN0CQ83OTKb+EheZQqhteoUac2Gob06Hw+36UobloqvQqhyzWX4RwklpUo0tF 1a1457gt15HT/LDL8d0rI0rghOLPdtnzFKuEcht0XZsAr9yILOmiVTX4RhwRd4CtzK9h 64lIuRlM2IDxe8EVxZ8d3gom/VNE980MCHeAA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=rGW6nRZIU+dtBDVnOwiq6bD97kLT5mzAoSicMy51k9gr9CzzTmlWvuIvYP678afurd 4z/iMxT5Z7vlotiQWK3P/vLhAvZQZfDDSn/YSmTqpyEH+qiai0rq4yoXMBPz49uU1/6S X0xHCXhzSn31hZzOjMoDDP+w76+N3CFZgdKe4= MIME-Version: 1.0 Received: by 10.216.28.200 with SMTP id g50mr5174425wea.92.1307399216283; Mon, 06 Jun 2011 15:26:56 -0700 (PDT) Received: by 10.216.253.168 with HTTP; Mon, 6 Jun 2011 15:26:56 -0700 (PDT) Received: by 10.216.253.168 with HTTP; Mon, 6 Jun 2011 15:26:56 -0700 (PDT) In-Reply-To: References: <4DED3A29.1090209@sugarcrm.com> <4DED43D4.4070006@sugarcrm.com> Date: Tue, 7 Jun 2011 00:26:56 +0200 Message-ID: To: "Matthew Weier O'Phinney" Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=0016e6de0029ddc06f04a5129914 Subject: Re: [PHP-DEV] Callable typehint From: pierre.php@gmail.com (Pierre Joye) --0016e6de0029ddc06f04a5129914 Content-Type: text/plain; charset=ISO-8859-1 How is this argument different than the one in favor of type hinting (or whatever was what ended in trunk)? On 7 Jun 2011 00:16, "Matthew Weier O'Phinney" wrote: > On 2011-06-06, Stas Malyshev wrote: >> > Like I mentioned in the other thread (which I probably should had >> > repeated here), a lot of libs/frameworks are using the 'Closure' >> > typehint for callbacks. >> >> Well, they are wrong (unless they mean to use only closures and not >> callbacks). But that's no reason to do wrong thing in the language >> too. >> >> > The problem with that is a function name as a string and >> > array("classname", "functionname") are considered is_callable(). To >> > get through the intentions of the Closure hint, I would have to wrap >> > the actual callback in a closure - which doesn't make any sense. >> >> "callable" is not actually even a type. If we make it a language >> construct, then why 'authenticated DB connection', 'name of readable >> file', 'valid stream URL', 'validated XML', 'string in UTF-8 no longer >> than 255 characters' or 'balanced binary tree' is not a language >> construct? I don't think we need to put every data check into the >> language, especially that it actually makes it worse - you can >> gracefully handle user-space check, but not a strict typing error. > > The point, though, is that with such a typehint available, we can reduce > boilerplate code like the following: > > public function addCallback($callback) > { > if (!is_callback($callback)) { > throw new InvalidArgumentException(); > } > > The typehint makes this simpler: > > public function addCallback(callback $callback) > > which allows us to rely on PHP's native error handling. I, for one, > would love to see this. > > -- > Matthew Weier O'Phinney > Project Lead | matthew@zend.com > Zend Framework | http://framework.zend.com/ > PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --0016e6de0029ddc06f04a5129914--