php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44957 Scripting stops after calling a magic setter from a static function
Submitted: 2008-05-10 03:39 UTC Modified: 2008-05-10 03:54 UTC
From: junker at slooz dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3CVS-2008-05-10 (snap) OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: junker at slooz dot com
New email:
PHP Version: OS:

 

 [2008-05-10 03:39 UTC] 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;

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-10 03:54 UTC] junker at slooz dot com
Sorry, false alarm. I had a missing __toString method, which was causing the problem.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 21 04:00:02 2025 UTC