#26299 [NEW]: Inheritance problem: an object can have two same-named private variables

From: Date: Tue, 18 Nov 2003 15:05:05 +0000
Subject: #26299 [NEW]: Inheritance problem: an object can have two same-named private variables
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-50633@lists.php.net to get a copy of this message
From:             forseti at oak dot rpg dot pl
Operating system: Windows 98 SE
PHP version:      5.0.0b2 (beta2)
PHP Bug Type:     Zend Engine 2 problem
Bug description:  Inheritance problem: an object can have two same-named private variables

Description:
------------
When extending a class, private member variables from parent class are
retained even if child class defines same-named variable. 

Reproduce code:
---------------
<?php 
class A {
	private $a = 'From class A';
} 

class B extends A{
	private $a = 'From class B';
}
echo '<pre>';print_r(new B);echo '</pre>';
?>

Expected result:
----------------
b Object
(
    [a:private] => From class B
)



Actual result:
--------------
b Object
(
    [a:private] => From class B
    [a:private] => From class A
)



-- 
Edit bug report at http://bugs.php.net/?id=26299&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26299&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26299&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26299&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26299&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26299&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=26299&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26299&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26299&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26299&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26299&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26299&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26299&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26299&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26299&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26299&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26299&r=float


Thread (2 messages)

« previous php.bugs (#50633) next »