Edit report at http://bugs.php.net/bug.php?id=50579&edit=1
ID: 50579 Updated by: [email protected] Reported by: team at fazend dot com Summary: RegexIterator::REPLACE doesn't work Status: Closed Type: Bug Package: SPL related Operating System: * PHP Version: 5.*, 6 Assigned To: felipe Block user comment: N New Comment: You are right, I've fixed the property issue. Thanks for reviewing/testing/reporting! :) Previous Comments: ------------------------------------------------------------------------ [2010-11-08 13:46:51] jinmoku at hotmail dot com Hi, i saw the test file (bug50579.phpt), it's strange to put the replacement property on the iterator parameter insteed the Regexiterator instance, imagine i've this follow code : class foo extends ArrayIterator { public function __construct( ) { parent::__construct(array( 'test1'=>'test888', 'test2'=>'what?', 'test3'=>'test999', 'replacement' => 'replacement'), ArrayIterator::ARRAY_AS_PROPS); $this->replacement = '[$1]'; } } if a would read $h->replacement, i've '[$1]' insteed 'replacement'. it's more logical to do : $i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE); $i->replacement = '[$0]'; or maybe make a methode : $i->setReplacement('[$0]'); ------------------------------------------------------------------------ [2010-11-06 01:18:00] [email protected] This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. ------------------------------------------------------------------------ [2010-11-06 01:09:52] [email protected] Automatic comment from SVN on behalf of felipe Revision: http://svn.php.net/viewvc/?view=revision&revision=305121 Log: - Fixed bug #50579 (RegexIterator::REPLACE doesn't work) ------------------------------------------------------------------------ [2010-07-11 05:31:37] jinmoku at hotmail dot com In original doc (http://www.php.net/~helly/php/ext/spl/), RegexIterator::REPLACE wait for "replacement" property, but it's doesn't exist in __construct and properties. In ext/spl replacement exist as public property but not in __construct method, so I try to extends it like this public function __construct($iterator, $regex, $mode = 0, $flags = 0, $preg_flags = 0) { parent::__construct($iterator, $regex, $mode, $flags, $preg_flags); $this->replacement = '$1'; } but nothing append to :( ------------------------------------------------------------------------ [2009-12-29 15:04:20] [email protected] Seems like this thing never got finished. There aren't any tests for it either.. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=50579 -- Edit this bug report at http://bugs.php.net/bug.php?id=50579&edit=1
