I totally <3 that you wrote it in python.
On Mon, May 2, 2011 at 4:21 PM, Russell N. Nelson - rnnelson rnnelson@clarkson.edu wrote:
Maybe there's a better tool to tell you what function is defined in what class in PHP, but I couldn't find one in the time it would take me to write it, so I wrote it. It's not even a screenful. Give it the class definitions, in class hierarchy order, on the command line. It will pull out the class name and function names, and tell you which function is actually being implemented by which class. It doesn't pay any attention to parent::self() calls, so you should watch out for them. -russ
#!/usr/bin/python
import sys, re
functions = {} classes = {} cl = None for fn in sys.argv[1:]: for line in open(fn): match = re.match(r'(abstract\s+)?class\s+(.*?)\s+(extends\s+(.*?)\s+)?{', line) if match: cl = match.group(2) supercl = match.group(4) classes[cl] = supercl if supercl: classes[supercl] # superclass should already be exist
match = re.match(r'\s*(public\s+|static\s+)?function\s+(.*?)(', line) if match: # we have a function definition. funct = match.group(2) functions[funct] = cl
keys = functions.keys() keys.sort() for key in keys: print key,functions[key]
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l