From:             
Operating system: All
PHP version:      5.3SVN-2011-01-05 (SVN)
Package:          SPL related
Bug Type:         Feature/Change Request
Bug description:Implementing RegexIterator::getRegex() method

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() 

-- 
Edit bug report at http://bugs.php.net/bug.php?id=53659&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=53659&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=53659&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=53659&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=53659&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=53659&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=53659&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=53659&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=53659&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=53659&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=53659&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=53659&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=53659&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=53659&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=53659&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53659&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53659&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=53659&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=53659&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=53659&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=53659&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=53659&r=mysqlcfg

Reply via email to