#33061 [Bgs->Opn]: Pass object by value then modify initialized sub-object: passes by reference

From: Date: Mon, 06 Jun 2005 09:59:39 +0000
Subject: #33061 [Bgs->Opn]: Pass object by value then modify initialized sub-object: passes by reference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-79944@lists.php.net to get a copy of this message
ID: 33061 Updated by: sniper@php.net Reported By: online at natweiss dot com -Status: Bogus +Status: Open Bug Type: Class/Object related Operating System: Linux -PHP Version: 4.3.10 +PHP Version: 5.*, 4.* Previous Comments: ------------------------------------------------------------------------ [2005-06-06 11:58:35] tony2001@php.net Do not file bugs when you have Zend extensions (zend_extension=) loaded. Examples are Zend Optimizer, Zend Debugger, Turck MM Cache, APC, Xdebug and ionCube loader. These extensions often modify engine behavior which is not related to PHP itself. ------------------------------------------------------------------------ [2005-06-04 07:58:33] online at natweiss dot com Tried latest snapshot. Still get the bug. Here is output of php -v and also the output of the reproduce code: php -v ------ PHP 4.3.12-dev (cli) (built: Jun 3 2005 22:16:42) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies with Turck MMCache v2.4.6, Copyright (c) 2002-2003 TurckSoft, St. Petersburg, by Dmitry Stogov output of reproduce code ------------------------ member->val should be empty! something Object ( [member] => something Object ( [val] => 1 ) ) ------------------------------------------------------------------------ [2005-06-03 13:08:00] tony2001@php.net Please try using this CVS snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-STABLE-latest.zip ------------------------------------------------------------------------ [2005-05-19 02:39:30] online at natweiss dot com Description: ------------ See reproduce code. php.ini is stock / no changes. Reproduce code: --------------- <?php // a class that does nothing class something{ function nothing(){ } } // a pass-by-value function that modifies a member's member function pass_by_value($value){ $value->member->val = 1; } // create a something with a member something $object = new something; $object->member = new something; // call nothing, then call pass_by_value and print results $object->member->nothing(); echo "member->val should be empty!\n"; pass_by_value($object); print_r($object); ?> Expected result: ---------------- $object->member should be empty Actual result: -------------- $object->member->val == 1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33061&edit=1

« previous php.bugs (#79944) next »