Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53215 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81225 invoked from network); 8 Jun 2011 14:48:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jun 2011 14:48:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=martinscotta@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=martinscotta@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: martinscotta@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:36003] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1F/64-48516-4CB8FED4 for ; Wed, 08 Jun 2011 10:48:36 -0400 Received: by vwl1 with SMTP id 1so449872vwl.29 for ; Wed, 08 Jun 2011 07:48:33 -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=nfzCGyIKtexSxwXp8gVAJOdjNqhuog9lCWp+j02q4DE=; b=dzgM43js3k+HxBhInF+sLFtsCHgGShXDiz68boG9GO9V1s3209hgSR9wGTpx/ystW3 2IPey8ZMu02BOKbxRjh5yihGOtTa0p3LXPxVC3WxeB50lcH812fgvfnX8SK6aOFpquoU PrwjjcneGLevKO4v0W8QvhG343l5lWgGqfmz4= 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=B5iNf7Z8T6cDHrHqnj6lon+GArkiKsKiHBwO482Rokg529m1CITdnbmrJ7L1blno0U 8JxzPUiO5IN6Wt7J0MDj+hqgVQbj0HmXfb/ZOsFLl2LCj0fVl/0X7FlwD+pKzCcBndwd XOOPZrH9OCn/yhzh3QQBRPeKGk7C8v6LQazHE= MIME-Version: 1.0 Received: by 10.220.6.11 with SMTP id 11mr1278154vcx.118.1307544513352; Wed, 08 Jun 2011 07:48:33 -0700 (PDT) Received: by 10.220.192.129 with HTTP; Wed, 8 Jun 2011 07:48:33 -0700 (PDT) In-Reply-To: References: <4DED3D5B.6030307@oracle.com> <4DEE782E.1020605@sugarcrm.com> <1307489981.23373.31.camel@guybrush> Date: Wed, 8 Jun 2011 11:48:33 -0300 Message-ID: To: Anthony Ferrara Cc: Hannes Magnusson , =?ISO-8859-1?Q?Johannes_Schl=FCter?= , Stas Malyshev , "Matthew Weier O'Phinney" , internals@lists.php.net Content-Type: multipart/alternative; boundary=0022152d62ad3f16b004a5346e25 Subject: Re: [PHP-DEV] Callable type From: martinscotta@gmail.com (Martin Scotta) --0022152d62ad3f16b004a5346e25 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Martin Scotta On Wed, Jun 8, 2011 at 10:31 AM, Anthony Ferrara wrote= : > > 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. > > Unless I mis-read what you said, we already have default array values > for array type-hinting: > > function foo(array $array =3D array('bar', 'baz')) { > var_dump($array); > } > > foo(); > > foo(array()); > > Works perfectly for me on 5.3.6... > it works since long time ago > > 2011/6/8 Hannes Magnusson : > > 2011/6/8 Johannes Schl=FCter : > >> 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 wil= l > >> 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 > recieved. > > > > gettype("strpos") will still return a string, not callable. > > > > A callable wouldn't be fully featured type. > > > >> What about default values? Will > >> function 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 typ= e > >> 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 typehin= t > > > > -Hannes > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --0022152d62ad3f16b004a5346e25--