Re: Directoryiterator / preg_match behavior

From: Date: Thu, 09 Sep 2004 00:16:21 +0000
Subject: Re: Directoryiterator / preg_match behavior
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-12655@lists.php.net to get a copy of this message
Can you please try again (HEAD)? Let me know if it's OK and I'll merge to PHP_5_0 Andi At 05:51 PM 9/5/2004 +0000, Curt Zirzow wrote:
* Thus wrote Andi Gutmans: At 03:46 AM 9/4/2004 +0000, Curt Zirzow wrote:
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? It was getting lost in the call to preg_match, prior to the patch.
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). Correct. I might be wrong on blaming it on convert_to_xx_ex(), but there definately is something wrong when passing builtin classes to certain functions, user defined classes behave differently: <?php class o { function __toString() {
    return 'a string';
} } echo "User class:\n"; $o = new o(); preg_match('/x/', $o); /* warning issued: expected string */
var_dump($o);           /*  object(0) #1 */
echo "\nDirectory Iterator:\n"; $d = new DirectoryIterator('.'); preg_match('/x/', $d); /* no warning */
var_dump($d);           /* string(1) "." */
echo "\nTidy:\n"; $t = new Tidy(); preg_match('/x/', $t); /* no warning */
var_dump($t);           /* string(1) "\n" */
Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid! -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#12655) next »