Re: Directoryiterator / preg_match behavior

From: Date: Sat, 04 Sep 2004 17:01:18 +0000
Subject: Re: Directoryiterator / preg_match behavior
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-12577@lists.php.net to get a copy of this message
At 03:46 AM 9/4/2004 +0000, Curt Zirzow wrote:
* Thus wrote Andi Gutmans: It probably makes sense to add SEPARATE_ZVAL_IF_NOT_REF() to that code. This would provide the same behavior as for example for long's. Can you please check out the following patch? Nice! That fixed the $file holding the value between iterations Test 1: ($file now is reset on iteration) <?php foreach (new DirectoryIterator('.') as $file) {
    echo "\n--\n";
    var_dump($file);
    preg_match("/xxx/", $file);
    var_dump($file);
    echo "--";
} -- object(DirectoryIterator)#1 (0) { } string(1) "." -- -- object(DirectoryIterator)#1 (0) { } string(2) ".." -- What are the possibilities of thrown E_STRICT or E_WARNING, since the object gets lost? Or should this simply be a documented behaviour? If possible, any pointers where to consider applying them at?
Didn't quite understand. Why does the object get lost after my fix?
From what I've seen there are a lot of convert_to_xxx_ex()'s around and can cause a some of unexpected results, without some sort of notice. Of course ideally, an attempt to fetch a __toString() value would be really nice :) I'm way over my head at this point.
convert_to_xx_ex() does not destroy any values (except if they are by reference). Andi

« previous php.internals (#12577) next »