Re: Orphan functions?
| From: | Robert Cummings | Date: | Fri, 01 Jun 2007 18:51:57 +0000 |
| Subject: | Re: Orphan functions? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-255981@lists.php.net to get a copy of this message | ||
On Fri, 2007-06-01 at 14:40 -0400, Al wrote:
> I appreciate the response and looked at the tokenizer doc; but, I'm missing your
> point. Are you implying I should write a Tokenizer Function to do the job?
Nope, tokenizer function already exists. I'm suggesting it wouldn't be
too hard to write a script that traverses your source tree, parses the
scripts using PHP's tokenizer functions, traverses the tokens and tells
you exactly what you want to know :)
Just a matter of:
1. Recording declared functions/methods.
2. Tracking a counter for when the function is used.
3. After all is done, displaying functions/methods with 0 counter.
This won't catch eval'd uses of functions, or other dynamic calling of
functions. But it will probably give you a good idea where to look,
possibly using grep. Dynamically called functions are non-deterministic
and so the only way to catch their usage is via a profiler, and then
again, it'll only get counted if it actually gets used during run-time.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'