|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-05-10 03:54 UTC] junker at slooz dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 23:00:01 2025 UTC |
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;