Using ReflectionParameter in PHP5

This is a discussion on Using ReflectionParameter in PHP5 within the PHP Language forums, part of the PHP Programming Forums category; Hello! I want to get the parameters of an internal php function and have tried to use the new reflection ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-18-2004
Lucius
 
Posts: n/a
Default Using ReflectionParameter in PHP5

Hello!

I want to get the parameters of an internal php function and have tried
to use the new reflection classes introduced in PHP5. This is what I've
done:

<?php

$funcArr = get_defined_functions();

echo $funcArr["internal"][5] . "\r";

$ref = new ReflectionFunction($funcArr["internal"][5]);

echo $ref;

foreach ($ref->getParameters() as $i => $param)
{
printf("-- Parameter #%d: %s \n" $i, $param->getName());
}

?>

this outputs:

strcmp Function [ public function strcmp ] { }

that output is only done by the two echo:s. There is nothing outputed
by the foreach loop.

Thanks in advance!

Reply With Quote
  #2 (permalink)  
Old 12-19-2004
Janwillem Borleffs
 
Posts: n/a
Default Re: Using ReflectionParameter in PHP5

Lucius wrote:
> I want to get the parameters of an internal php function and have
> tried to use the new reflection classes introduced in PHP5. This is
> what I've done:

[...]
> this outputs:
>
> strcmp Function [ public function strcmp ] { }
>
> that output is only done by the two echo:s. There is nothing outputed
> by the foreach loop.
>


I don't think you can reverse-engineer native functions with the
ReflectionFunction class, only user-defined:

function foo($name, $bla) {}

$ref = new ReflectionFunction("foo");

foreach ($ref->getParameters() as $i => $param) {
printf("-- Parameter #%d: %s \n", $i, $param->getName());
}


JW



Reply With Quote
  #3 (permalink)  
Old 12-19-2004
Lucius
 
Posts: n/a
Default Re: Using ReflectionParameter in PHP5

Hello!

That's sad =( I though you could because in the PHP5 Power Programming
book they do: ReflectionClass::export("ReflectionParameter");

I am working on a simple phpeditor know of any other way to
automatically get information (name, returntype, description,
parametersname and returntype)? I am going to add it to an XML file. I
guess I'll have to do it by hand then.

Reply With Quote
  #4 (permalink)  
Old 12-19-2004
cyberhorse
 
Posts: n/a
Default Re: Using ReflectionParameter in PHP5

use the documentation on php.net? getting the .html files from there or
something should be the second easiest way I suppose.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:30 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0