|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-02-10 23:42 UTC] johannes@php.net
-Status: Open
+Status: Wont fix
[2012-02-10 23:42 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 19:00:01 2025 UTC |
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.