php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53659 Implementing RegexIterator::getRegex() method
Submitted: 2011-01-05 23:01 UTC Modified: 2011-01-06 03:33 UTC
From: jthijssen at noxlogic dot nl Assigned: aharvey (profile)
Status: Closed Package: SPL related
PHP Version: 5.3SVN-2011-01-05 (SVN) OS: All
Private report: No CVE-ID: None
 [2011-01-05 23:01 UTC] jthijssen at noxlogic dot nl
Description:
------------
I'd like to see an getRegex() method in the regexIterator class that will return the regular expression that is initialized during its __construct(). 

Currently there is no way of retrieving that information except for saving it yourself outside the object or extending regexiterator in order to save the regex inside a custom constructor. 

It would be nice if the information about the object could actually be retrieved natively since this data is already present, just not visible to the outside world.

Attached is a patch with an implementation.  

Test script:
---------------
$array = array('cat', 'hat', 'sat');
$iterator = new ArrayIterator($array);
$regexIterator = new RegexIterator($iterator, '/.at/');
var_dump($regexIterator->getRegex());

Expected result:
----------------
string(5) "/.at/"

Actual result:
--------------
PHP Fatal error:  Call to undefined method ArrayIterator::getRegex() 

Patches

getregex.diff (last revision 2011-01-05 22:01 UTC by jthijssen at noxlogic dot nl)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-06 02:47 UTC] aharvey@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: aharvey
 [2011-01-06 02:47 UTC] aharvey@php.net
Looks good at a first pass. Let's see about getting it into trunk.
 [2011-01-06 03:32 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=307147
Log: Implement request #53659 (Implementing RegexIterator::getRegex() method). Patch
by Joshua Thijssen.
 [2011-01-06 03:33 UTC] aharvey@php.net
-Status: Assigned +Status: Closed
 [2011-01-06 03:33 UTC] aharvey@php.net
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.

Committed on trunk: the change to the _spl_dual_it_object struct will
prevent this going into 5.3. Thanks for the patch, Joshua!
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Dec 02 04:01:24 2020 UTC