I'm sure there is some existing php code to do search+replace over multiple files, BUT if someone wants to make a new tool that does this, I have written some php classes and code that should make the job much easier, in my (open source)
mwimporter package. Again, it does *not* do search and replace, but it will nicely iterate through recursive directories of files and do a few more helpful things that could be used as a starting point.