ID:               29174
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jbeall at heraldic dot us
-Status:           Open
+Status:           Bogus
 Bug Type:         Zend Engine 2 problem
-Operating System: Linux
+Operating System: *
 PHP Version:      5.0.0
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Move get/set to base class.


Previous Comments:
------------------------------------------------------------------------

[2004-07-23 06:46:18] imprestavel at gameguru dot com dot br

i think extends works the other way around
"class Super extends Sub", means that Super will inherit Sub stuff, not
the opposite
so, when you do:
> $foo = new Sub();
you are instantiating Sub, which doesn't inherit Super, ending up
without the __get and __set methods

try:
<?
class Super
{
        function __get($prop)
        {
                echo "Property $prop called\n";
        }

        function __set($prop, $val)
        {
                echo "Property $prop set to $val\n";
        }
}

class Sub extends Super
{
}

$foo = new Sub();

$foo->someProp = 10;
echo $foo->someProp;
?>

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

[2004-07-15 03:50:59] jbeall at heraldic dot us

Description:
------------
the __get() and __set() functions work fine to overload a class when
that class has no parent class.  However, if the class you put __get()
and __set() in has a parent class, they are not called whenever a
property is called.

Reproduce code:
---------------
class Sub
{
}

class Super extends Sub
{
        function __get($prop)
        {
                echo "Property $prop called\n";
        }

        function __set($prop, $val)
        {
                echo "Property $prop set to $val\n";
        }
}


$foo = new Sub();

$foo->someProp = 10;
echo $foo->someProp;

Expected result:
----------------
Property someProp set to 10
Property someProp called

Actual result:
--------------
10


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


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

Reply via email to