ID: 44957
User updated by: junker at slooz dot com
Reported By: junker at slooz dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Windows XP
PHP Version: 5.3CVS-2008-05-10 (snap)
New Comment:
Sorry, false alarm. I had a missing __toString method, which was
causing the problem.
Previous Comments:
------------------------------------------------------------------------
[2008-05-10 03:39:09] junker at slooz dot com
Description:
------------
Magic __set function fails when called from a static method.
The sample code will work as expected if "$o->Dummy = $o2;" is replaced
with, for example, "$o->Dummy = 'abc';".
Reproduce code:
---------------
<?
class A {
public static function who () { return __CLASS__; }
public static function create () {
$type = static::who ();
$o = new $type ();
if ($type == 'B') {
$o2 = C::create ();
$o->Dummy = $o2;
}
return $o;
}
public function __set ($key, $value) {
echo "[setting $key]";
}
}
class B extends A {public static function who () { return __CLASS__;
}}
class C extends A {public static function who () { return __CLASS__;
}}
$obj_b = B::create (); echo '[Done]';
?>
Expected result:
----------------
[setting Dummy][Done]
Actual result:
--------------
No output. The scripting of the code seems to stop during this command:
$o->Dummy = $o2;
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44957&edit=1