From: Operating system: Any PHP version: 5.3.8 Package: *General Issues Bug Type: Bug Bug description:$this as byref
Description: ------------ take a look at the following script <?php class B { public $b = 50; public function whoami () { var_dump (__CLASS__); } } class A { public $a = 6; function thisref () { var_dump ($this); // A $this->ref ($this); // exchange $this by a B object var_dump ($this); // B var_dump ($this->a); // 6 var_dump ($this->b); // Notice: Undefined property: A::$b var_dump (isset ($this->a)); // true var_dump (property_exists ($this, "a")); // false var_dump (__CLASS__); // A $this->whoami (); // A var_dump ($this instanceof self ? "A" : "B"); // B } function ref (A &$ref) { $ref = new B(); } public function whoami () { var_dump (__CLASS__); } } $a = new A(); $a->thisref (); ?> it supplies $this variable as a property to a byref function, then changing it to a diffrent type. if gives some strange results Expected result: ---------------- it should not be possible to supply $this as a byref param Actual result: -------------- $this seems to be changed, however any call upon $this seems not, so properties and methods remain unchanged. -- Edit bug report at https://bugs.php.net/bug.php?id=60428&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60428&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60428&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60428&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60428&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60428&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60428&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60428&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60428&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60428&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60428&r=support Expected behavior: https://bugs.php.net/fix.php?id=60428&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60428&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60428&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60428&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60428&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60428&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60428&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60428&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60428&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60428&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60428&r=mysqlcfg