Edit report at http://bugs.php.net/bug.php?id=53053&edit=1

 ID:                 53053
 User updated by:    dave dot a dot roberts at gmail dot com
 Reported by:        dave dot a dot roberts at gmail dot com
 Summary:            Magic Method __set changes object class
-Status:             Feedback
+Status:             Closed
 Type:               Bug
 Package:            Class/Object related
 Operating System:   FreeBSD 8.1-RELEASE
 PHP Version:        5.3.3
 Block user comment: N

 New Comment:

I think this was happening because I was trying to pull an object out of
an array by the wrong key.  Sorry to waste your time.


Previous Comments:
------------------------------------------------------------------------
[2010-10-14 04:43:28] ahar...@php.net

Please provide a complete reproduction script, preferably (well) under
50 lines of code.



For the record, I can't reproduce this with the following script:



<?php

class C {

    public function __set($name, $value) {

        $this->$name = $value;

    }

}



$c = new C;

var_dump(get_class($c));

$c->foo = 'bar';

var_dump(get_class($c));

?>

------------------------------------------------------------------------
[2010-10-13 17:49:42] dave dot a dot roberts at gmail dot com

Description:
------------
I have an object I created from class Post.



$p = new Post();



get_class($p) will return the class Post.



After I assign a variable to the class using the magic method __set



$p->datereceived = "1234";



get_class($p) will return stdClass.

Test script:
---------------
$p = new Post();

print(get_class($p)); // returns Post

$p->datereceived = "1234";

print(get_class($p)); // returns stdClass.

Expected result:
----------------
The classname of Post should be returned twice.

Actual result:
--------------
Post is returned the first time, stdClass is returned the second time.


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53053&edit=1

Reply via email to