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

From: Date: Tue, 18 Nov 2003 15:29:05 +0000
Subject: #26299 [Opn->Bgs]: Inheritance problem: an object can have two same-named private variables
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-50636@lists.php.net to get a copy of this message
 ID:               26299
 Updated by:       jay@php.net
 Reported By:      forseti at oak dot rpg dot pl
-Status:           Open
+Status:           Bogus
 Bug Type:         Zend Engine 2 problem
 Operating System: Windows 98 SE
 PHP Version:      5.0.0b2 (beta2)
 New Comment:

This is expected. When a member is private, it can only be 
seen by the class it is a member of. Class B has no idea 
class A also has a member called $a and goes ahead and 
creates one. It's just a matter of visibility. 
 
J 


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

[2003-11-18 10:05:05] forseti at oak dot rpg dot pl

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 this bug report at http://bugs.php.net/?id=26299&edit=1


Thread (2 messages)

« previous php.bugs (#50636) next »