Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.1.4

Bug #14892 Notice: Array to string conversion in /home/clockwerx/pear/File_SearchReplace/S
Submitted: 2008-10-27 05:28 UTC
From: doconnor Assigned: doconnor
Status: Closed Package: File_SearchReplace (version CVS)
PHP Version: 5.2.4 OS:
Roadmaps: (Not assigned)    

 [2008-10-27 05:28 UTC] doconnor (Daniel O'Connor)
Description: ------------ Unit tests produce an array to string E_NOTICE Test script: --------------- pear run-tests Expected result: ---------------- Tests pass Actual result: -------------- 60) /home/clockwerx/pear/File_SearchReplace/tests/04normal_bof.phpt --- Expected +++ Actual @@ -1,10 +1,15 @@ +Notice: Array to string conversion in /home/clockwerx/pear/File_SearchReplace/SearchReplace.php on line 265 + +Notice: Array to string conversion in /home/clockwerx/pear/File_SearchReplace/SearchReplace.php on line 265 + +Notice: Array to string conversion in /home/clockwerx/pear/File_SearchReplace/SearchReplace.php on line 265 <?php // +-----------------------------------------------------------------------+ -// | Copyprotected. Richard Heyes | +// | Array Richard Heyes | // | All rights reserved. | // | |/** // +-----------------------------------------------------------------------+ -// | Copyprotected. Richard Heyes | +// | Array Richard Heyes | ... * * Search and Replace Utility


 [2008-10-27 12:51 UTC] techtonik (anatoly techtonik)
Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at If you can provide more information, feel free to add it to this bug and change the status back to "Open". Thank you for your interest in PEAR. According to documentation there is nothing wrong with line 265 - str_replace() should accept array arguments without any warning. Could you track argument types and contents in the place of failure?
 [2008-10-27 13:19 UTC] doconnor (Daniel O'Connor)
The test case (04normal_bof.phpt) covers str_replace('string', array('one','two', 'three')) says: If search and replace are arrays, then str_replace() takes a value from each array and uses them to do search and replace on subject . If replace has fewer values than search , then an empty string is used for the rest of replacement values. If search is an array and replace is a string, then this replacement string is used for every value of search . The converse would not make sense, though. ... which is why it raises the array to string conversion error.
 [2008-10-27 13:19 UTC] doconnor (Daniel O'Connor)
(and that's what old code covered off, this was just shifting it to elsewhere)
 [2008-10-27 14:27 UTC] techtonik (anatoly techtonik)
It doesn't seems as a bug in a library, but rather in test-suite that was designed for PHP4. It is better to accept E_NOTICE as appropriate warning to review the code for those who dared to supply meaningless arguments to function.
 [2008-10-27 14:36 UTC] doconnor (Daniel O'Connor)
If you look at the patch, you can see I just shifted $local_find = array_values((array) $this->find); $local_replace = (is_array($this->replace)) ? array_values($this->replace) : $this->replace; higher up - the php4 code was already explicitly dealing with this situation; so that smells like this E_NOTICE has been around for a while.
 [2008-10-27 14:43 UTC] techtonik (anatoly techtonik)
Well, ok. Go on. It is too late to revert it back.
 [2008-10-27 14:50 UTC] doconnor (Daniel O'Connor)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Committed in Rev 1.6 Thanks for the review/feedback :)
 [2008-10-31 17:04 UTC] doconnor (Daniel O'Connor)
Missed one additional occurrence of this style of problem (Fixed in Rev 1.23)