Re: Orphan functions?
| From: | Al | Date: | Fri, 01 Jun 2007 19:01:48 +0000 |
| Subject: | Re: Orphan functions? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-255982@lists.php.net to get a copy of this message | ||
I gotcha now. I misspoke about writing a tokenizer function, I understood that it would be a script.
That's for the suggestion. Though, I was hoping to avoid reinventing something that already exists.
Robert Cummings wrote:
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.