Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56970 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7961 invoked from network); 20 Dec 2011 23:54:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Dec 2011 23:54:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=kassner@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kassner@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: kassner@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-ww0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:61242] helo=mail-ww0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/71-29615-D4021FE4 for ; Tue, 20 Dec 2011 18:54:54 -0500 Received: by wgbdt13 with SMTP id dt13so12307984wgb.11 for ; Tue, 20 Dec 2011 15:54:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=7bo92/yDo+LZd836tdyOCfITjiAwz1V769mU+K34FTo=; b=ZUKXzlV8/MkTRQ+V033dd7X7dTrIFdmFbITMlxUwqQ5x5kqV9w4DP4vOT29uHvQUjY HBJw7YB7idDcUO5liL1AtvE6ilop+39O70tjec+MGtVolIZBvmawldGruq8hd8PHwqAb HIIkK308lXrGh4Ijk1kE9s0aQBqPEgQexyw60= Received: by 10.227.206.6 with SMTP id fs6mr4071053wbb.20.1324425291221; Tue, 20 Dec 2011 15:54:51 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.105.212 with HTTP; Tue, 20 Dec 2011 15:54:30 -0800 (PST) In-Reply-To: References: Date: Tue, 20 Dec 2011 21:54:30 -0200 Message-ID: To: Mark Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] 5.3.8, Why is func_num_args() not working on a Clusure? From: kassner@gmail.com (Rafael Kassner) func_num_args() must be called inside the Closure to know the number of arguments that it received. If you are calling outside, it returns the number of arguments of your testClosure function. There is no other way than Reflection to do this. And, I think func_num_args() does not receive any parameter. On Tue, Dec 20, 2011 at 9:43 PM, Mark wrote: > Hi, > > Why is func_num_args not working on closures? > Example code (tested on PHP 5.3.8): > > > class Test > { > public function testClosure($oClosure) > =A0{ > echo '
';
> print_r(func_num_args($oClosure));
> =A0echo '
';
> }
> }
>
> $c =3D new Test();
> $c->testClosure(function($arg1, $arg2){
> });
>
> 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!
>
> Just something that i wonder...
> I would have expected num args to return the args of the function you
> provide it..
>
> Kind regards,
> Mark



--=20
Atenciosamente,
Rafael Kassner