Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53196 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7044 invoked from network); 8 Jun 2011 08:38:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jun 2011 08:38:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=hannes.magnusson@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=hannes.magnusson@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: hannes.magnusson@gmail.com X-Host-Fingerprint: 209.85.161.170 mail-gx0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:35268] helo=mail-gx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 43/A8-50253-E153FED4 for ; Wed, 08 Jun 2011 04:38:54 -0400 Received: by gxk27 with SMTP id 27so111529gxk.29 for ; Wed, 08 Jun 2011 01:38:51 -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 :content-transfer-encoding; bh=BXaMHJUH+m5RqK2uVc0Gs3ElYmYSz8xJ7m8C/fauar8=; b=vj2ilfMKNk4dqy7P7yvYpbw502uydB2b0lYgfvy1gwL4+HENIhAYHbLafm+d5mnA0a YxBfNvFM5dDfYGjBhlKGXg5nQgsLYi5AcIqh3PPEwnLsWW/c7uxZECidHaljCnx/qLiN 3zSO0the8TfCwGzBp1jteMoh1f1NqL2M70P1E= 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:content-transfer-encoding; b=n9/63rva0PWqZI9Ob52VEuQ+dNscd7GAgr6t9oP5GrGzeI+SBLo7jpjdv84AQSOm37 SJQnZpdt3iKcOP6vRdo1zd+1f6DcPG/2hrl3A9+UeMMJQuwMud6W6ZFDV1Tiinl/dHb7 4iFAwMH+zGf+Z9JVlO/lc39Hz9oHz/lkRQ238= MIME-Version: 1.0 Received: by 10.146.59.36 with SMTP id h36mr3345032yaa.7.1307522331671; Wed, 08 Jun 2011 01:38:51 -0700 (PDT) Received: by 10.146.210.3 with HTTP; Wed, 8 Jun 2011 01:38:51 -0700 (PDT) In-Reply-To: <1307489981.23373.31.camel@guybrush> References: <4DED3D5B.6030307@oracle.com> <4DEE782E.1020605@sugarcrm.com> <1307489981.23373.31.camel@guybrush> Date: Wed, 8 Jun 2011 10:38:51 +0200 Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: Stas Malyshev , "Matthew Weier O'Phinney" , internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Callable type From: hannes.magnusson@gmail.com (Hannes Magnusson) 2011/6/8 Johannes Schl=C3=BCter : > On Tue, 2011-06-07 at 12:12 -0700, Stas Malyshev wrote: >> Hi! >> >> > https://wiki.php.net/rfc/callable >> >> It is good there's an RFC. However it seems to lack code examples. I >> understand it may be obvious to the proposers how it looks like, but >> it'd be nice to have the actual example there as it is done nearly >> everywhere else. > > The RFC is missing information about what happens in codebases which > already have a "callable" type declared. Will that be prevented or will > they hit a runtime error? ("callable expected, callable type found") You mean an interface/class with that name? The error would be 'expected instanceof callable, string/array/closure reci= eved. gettype("strpos") will still return a string, not callable. A callable wouldn't be fully featured type. > What about default values? Will > =C2=A0 =C2=A0function foo(callback $cb =3D 'strpos') { } > be valid? No default values, other then NULL allowed. Otherwise we would need to support array("classname", "methodname") too, and then people would want default array values for array typehinting etc etc etc. > The information on reflection is limited. what shall > Reflection::Parameter::getTypehint() return? Will that method allow to > differ between a class type and this "magic"? There is no such method anymore :) > > What about ARGINFO? Will internal functions be able to define this type > via ARGINFO? How will this be reported in `php --rf function`? I didn't include arginfo in the patch, but good point. It should probably be included. As Felipe pointed out, ext/reflection hasn't been updated. It should return [ callable $foobar ], just like with any other typehint -Hannes