From: borysf at wp dot pl Operating system: Windows, Linux PHP version: 4.4.0RC1 PHP Bug Type: Class/Object related Bug description: PHP does not create references to $this
Description: ------------ There is a bug in creating references (This problem does not exist in PHP5). If you have, for example, two classes and the first class creates second and passes itself as reference to second's constructor, reference is not being created. I've been trying to create this reference in many ways, but always with the same result - there is no reference, only a copy of class which was passed as reference. Reproduce code: --------------- class B { var $Parent; function B(&$parent) { $this->Parent = $parent; $this->Parent->Data = 'foo'; } } class A { var $Data; var $B; function A() { $this->B = new B($this); } } $a = new A; echo $a->Data; Expected result: ---------------- echo should return 'foo', but returns nothing. In php5 it works properly. Note, that I have used the & operator in B's constructor to create a reference to A class. -- Edit bug report at http://bugs.php.net/?id=33370&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33370&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33370&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33370&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33370&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33370&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33370&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33370&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33370&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33370&r=support Expected behavior: http://bugs.php.net/fix.php?id=33370&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33370&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33370&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33370&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33370&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33370&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33370&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33370&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33370&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33370&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33370&r=mysqlcfg