From:             
Operating system: Mac OS X
PHP version:      5.3.2
Package:          Class/Object related
Bug Type:         Bug
Bug description:overloaded __set is called from parent class

Description:
------------
If you overwrite __set in a child class, the parent implementation is
called first 

and than triggers the child version.



I found another bug, which says that you should implement the __set method
in the 

parent class, but it in this case both methods are called.



A similar bug is reported in #44807, but it's only about the recursion
prevention.

Test script:
---------------
<?php

        class Foo {

                function __set($key, $value) {

                        $this->{$key} = $value . ' (Foo)';

                }

        }

        

        class Bar extends Foo {

                function __set($key, $value) {

                        $this->{$key} = $value . ' (Bar)';

                }

                

                function set() {

                        parent::__set('foobar', 'Test');

                }

        }

        

        $bar = new Bar();

        $bar->set();

        echo $bar->foobar;

?>

Expected result:
----------------
Test (Foo)

Actual result:
--------------
Test (Foo) (Bar)

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51888&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=51888&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=51888&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=51888&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=51888&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51888&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=51888&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=51888&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=51888&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=51888&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=51888&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=51888&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=51888&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=51888&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=51888&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51888&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51888&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=51888&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=51888&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=51888&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=51888&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=51888&r=mysqlcfg

Reply via email to