Are there any scripts that can go through a collection of PHP files and detect multiple functions with the same name?
If you post a couple of files I'll see if I can write a script. I don't know php syntax but I might be able to toss something together with a few examples.
A regular expression or reflection may work.
couldnt you just do a grep/find (notepad++) on "function fnName("
Am I oversimplifying something?
I don't know much PHP, but if you simply want a list of function names with a count of how frequently they occur, you can do the heavy lifting in grep. Note, I used GNU Grep which I had to install on my mac with
brew install grep. The one that comes bundled on the mac is BSD Grep which has fewer options and doesn't support Perl-style regular expressions.
Here it is displaying the top twenty function names in Laravel.
grep -hroP '(?<=function )(\w+)' | sort | uniq -c | sort -r | head -n20 311 __construct 93 handle 49 get 40 register 39 __call 35 getFacadeAccessor 27 delete 25 send 25 getOptions 25 flush 24 make 24 forget 22 put 22 getStub 21 resolve 20 create 19 getDefaultNamespace 18 increment 18 has 18 exists
Alternatively, using The Silver Searcher (aka
ag) instead of
ag --only-matching --no-heading --no-filename '(?<=function )(\w+)'| sed '/^$/d' | sort | uniq -c | sort --reverse | head -n20
Obviously, run this from the root of your project. Or, after the regex supply a list of filenames to whichever
grep and it'll just search them.