cakephp/cakephp — pull request #1663 by rooseveltrp (2013-09-21 01:52:29+00:00)
Title: Added a method File::replace() to the File Utilities

This method allows you to search the current file for a specific string, and replace it with a given argument.

Very useful for custom shell scripts or any general file operation where you need to replace contents of a file.

FYI, I wrote the method in such a way that it can handle large files. General file_get_contents() method may not work well for large files, so I used fgets() to read the string in a buffer and then try the replacement operations.