Doing some code generation... need to find out args

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Doing some code generation... need to find out args

Post by Ambush Commander »

Okay, here's what I need to do. I need to create a script that will analyze another class, and then generate a decorator for it. My first line of thought was to use get_class_methods() and then iterate over that array, but that would not tell me what the arguments are.

There doesn't seem to be a way to examine arguments of a class, so I was thinking to ways to go about it:

1. Actually lex the page, and then figure out the args from the tokens, or
2. Use call_user_func_array() and func_get_args in tandem. (unfortunantely, they seem to pass by value, not by reference, which could cause problems)

Am I overlooking a third technique? I really, really don't want to have to lex the page.
Post Reply