views:

45

answers:

3

We have a PHP project and this is our first product delivery. We want to add a disclaimer to all *.php files in the project. Is there any free/OS tool that we can use to avoid donkey work :( ? We have around 100 source code files.

A: 

You could write a script to do it.

It is fairly unlikely that there is a tool out there that does specifically this, seeing that is fairly trivial. (Not to say that such a tool does not exist)

phsr
Why the downvote?
phsr
of course I can. why to reinvent the wheel if there is already.and if i will write, I will share with rest of the world. (i did not give down vote)
Ankit Jain
The way your question is asked, it makes it sound like you want to avoid manually pasting the disclaimer to the code, not that you want to avoid writing a ~5 line script. (Ack'd that you didn't give the downvote, Ankit)
phsr
+1  A: 

A simple shell script would do, if you are using linux. You can write a small PHP command line script which will take as input a file name, open the file, and replace the first <?php with <?php /* Your disclaimer */

Then you can call this script with something like this:

find . -name '*.php' exec php yourscript.php \{\} \;

But try first on some copy, and be sure you don't introduce regressions.

In linux there are tools too, (kfilereplace for instance), but I don't trust that.

Or grep and sed, if you are the hardcore kind :)

Palantir
A: 

Please don't do that. It just annoys the developer who takes over. I always do a huge regex replace to get rid of those annoying disclaimers.

Coronatus
this is a comment, not an answer
Palantir
I don't mind other developers adding disclaimers to their source code, as long as the script was in fact wrote by them and they use the PHPDoc standard?
Martin Bean