Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12548 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26179 invoked by uid 1010); 2 Sep 2004 18:12:10 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 29465 invoked from network); 2 Sep 2004 17:44:07 -0000 Received: from unknown (HELO mrout2.yahoo.com) (216.145.54.172) by pb1.pair.com with SMTP; 2 Sep 2004 17:44:07 -0000 Received: from bourbon.corp.yahoo.com (bourbon.corp.yahoo.com [216.145.53.135]) by mrout2.yahoo.com (8.13.1/8.13.1/y.out) with ESMTP id i82Hh6j0011151; Thu, 2 Sep 2004 10:43:06 -0700 (PDT) Received: (from andrei@localhost) by bourbon.corp.yahoo.com (8.12.9/8.11.1) id i82Hh6D2016181; Thu, 2 Sep 2004 10:43:06 -0700 (PDT) (envelope-from andrei@gravitonic.com) X-Authentication-Warning: bourbon.corp.yahoo.com: andrei set sender to andrei@gravitonic.com using -f Date: Thu, 2 Sep 2004 10:43:06 -0700 To: internals@lists.php.net Cc: andi@zend.com Message-ID: <20040902174306.GA16138@gravitonic.com> References: <41366A46.60502@wormus.com> <20040902042411.GC3977@bagend.shire> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040902042411.GC3977@bagend.shire> User-Agent: Mutt/1.4.1i Subject: Re: [PHP-DEV] Directoryiterator / preg_match behavior From: andrei@gravitonic.com (Andrei Zmievski) On Thu, 02 Sep 2004, Curt Zirzow wrote: > Test 1: ($file holds last type conversion) > foreach (new DirectoryIterator('.') as $file) { > echo "\n--\n"; > var_dump($file); > preg_match("/xxx/", $file); > var_dump($file); > echo "\n--"; > } > > Output: > Object(DirectoryIterator)#1 (0) { > } > string(1) "." > -- > -- > string(1) "." > string(1) "." > -- > ... The culprit is this piece of code in zend_parse_arg_impl(): case IS_OBJECT: { if (Z_OBJ_HANDLER_PP(arg, cast_object) && Z_OBJ_HANDLER_PP(arg, cast_object)(*arg, *arg, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { *pl = Z_STRLEN_PP(arg); *p = Z_STRVAL_PP(arg); break; } The cast_object handler overwrites the value in *arg and that's why the original variable changes type. I think Andi made this change on Dec 02, 2003. I can see the rationale behind not using a new var for the conversion, because then we have to keep track of it and release it somehow, but changing variable types is not good either. Andi, any suggestions? - Andrei