Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56971 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9231 invoked from network); 20 Dec 2011 23:55:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Dec 2011 23:55:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=gergo@gergoerdosi.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=gergo@gergoerdosi.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain gergoerdosi.com from 217.70.183.196 cause and error) X-PHP-List-Original-Sender: gergo@gergoerdosi.com X-Host-Fingerprint: 217.70.183.196 relay4-d.mail.gandi.net Linux 2.6 Received: from [217.70.183.196] ([217.70.183.196:47531] helo=relay4-d.mail.gandi.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 81/C1-29615-B8021FE4 for ; Tue, 20 Dec 2011 18:55:56 -0500 X-Originating-IP: 217.70.178.144 Received: from mfilter16-d.gandi.net (mfilter16-d.gandi.net [217.70.178.144]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 2BC3A172087 for ; Wed, 21 Dec 2011 00:55:53 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter16-d.gandi.net Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by mfilter16-d.gandi.net (mfilter16-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 5CqOVu1jEQ2c for ; Wed, 21 Dec 2011 00:55:51 +0100 (CET) X-Originating-IP: 89.135.155.50 Received: from [192.168.1.101] (catv-89-135-155-50.catv.broadband.hu [89.135.155.50]) (Authenticated sender: gergo@gergoerdosi.com) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 9FD2517208D for ; Wed, 21 Dec 2011 00:55:51 +0100 (CET) Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Apple Message framework v1251.1) In-Reply-To: Date: Wed, 21 Dec 2011 00:55:50 +0100 Content-Transfer-Encoding: quoted-printable Message-ID: References: To: PHP internals X-Mailer: Apple Mail (2.1251.1) Subject: Re: [PHP-DEV] 5.3.8, Why is func_num_args() not working on a Clusure? From: gergo@gergoerdosi.com (Gergo Erdosi) Hi, The function func_num_args() doesn't accept any parameters, so calling = func_num_args($oClosure) is the same as calling simple func_num_args(). = That's why it returns 1 instead of 2, which is I think the expected and = correct behavior. Gergo Erdosi On Dec 21, 2011, at 24:43 , Mark wrote: > Hi, >=20 > Why is func_num_args not working on closures? > Example code (tested on PHP 5.3.8): >=20 > =20 > class Test > { > public function testClosure($oClosure) > { > echo '
';
> print_r(func_num_args($oClosure));
> echo '
';
> }
> }
>=20
> $c =3D new Test();
> $c->testClosure(function($arg1, $arg2){
> });
>=20
> That returns 1 (the num of args in which function the closure is
> (testClosure), but not the number of args from the closure itself.
> Now Reflection can be used to get the number of args but that is =
overkill!
> Also when you would do print_r(func_get_args($oClosure)); you do get
> "something" back including the arguments but no way (that i know) to =
use
> them!
>=20
> Just something that i wonder...
> I would have expected num args to return the args of the function you
> provide it..
>=20
> Kind regards,
> Mark