[PEPr] Comment on File System::File_SearchReplace2

From: Date: Sun, 04 Dec 2005 11:00:26 +0000
Subject: [PEPr] Comment on File System::File_SearchReplace2
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-40584@lists.php.net to get a copy of this message
Anatoly Techtonik (http://pear.php.net/user/techtonik) has commented on the proposal for File System::File_SearchReplace2. Comment: To make it more clear - consider a new developer want to use a package. Package name indicates it's purpose - at the moment SearchReplace means only Replace operation, but from new release it will gain separate Search and Replace functionalities. So, when a new developer looks at API - (s)he sees two methods - doReplace() and doSearch(). Which one will be called to test replacement rules? I guess doSearch(), but it is easy to forgot to call it with necessary argument different from default to avoid replacements. Thus one can easily corrupt information in important files (including current sources). Another side - try to read the text of the package, which uses File_SearchReplace: <code> include('File/SearchReplace.php'); $files = glob("*.php"); $search[] = "sion 3.0 of the PHP lic"; $replace[] = "sion 3.01 of the PHP lic"; $search[] = "license/3_0.txt"; $replace[] = "license/3_01.txt"; $snr = new File_SearchReplace( $search, $replace, $files); $snr -> doSearch(false) ; </code> What the heck is this "false" search - does this mean replace will not happen or vice versa? doSearch() can be changed to require "true" to be passed, but the question is still the same - why doSearch(true) does replace and doSearch() does the same when there is doReplace() method what does the same?! BC break is a matter of common sense. New "only search" functionality requires API to be changed. I proposed File_SearchAndReplace at first, but was convinced to continue as File_SearchReplace2. Because of these BC requirements and proposal necessity package was delayed for at least half a year. Proposal information: http://pear.php.net/pepr/pepr-proposal-show.php?id=281 -- Sent by PEPr, the automatic proposal system at http://pear.php.net

« previous php.pear.dev (#40584) next »