#22489 [Opn]: Private members are available to derived classes

From: Date: Sat, 01 Mar 2003 16:46:24 +0000
Subject: #22489 [Opn]: Private members are available to derived classes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-34579@lists.php.net to get a copy of this message
ID: 22489 Updated by: helly@php.net Reported By: marcot at tabini dot ca Status: Open Bug Type: Zend Engine 2 problem Operating System: Shouldn't matter PHP Version: 5CVS-2003-03-01 (dev) New Comment: NO! & YES there is an error. No: You are declaring a *new* dynamic property c in b which hides c from a. YES: there is a memory leak: /usr/src/php4-HEAD/Zend/zend_language_scanner.l(1084) : Freeing 0x40998D38 (7 bytes), script=/usr/src/php4-HEAD/tests/classes/private_members.php I'll have a look into it Previous Comments: ------------------------------------------------------------------------ [2003-03-01 10:36:25] marcot at tabini dot ca Configure: ./configure \ --with-apxs=/usr/local/apache/bin/apxs For example: <? class a { private $c; function __construct() { $this->c = "a::c"; } } class b extends a { private $d; function _construct() { $this->d = 'b::d'; } function test() { echo $this->c; } } $b = new b; //echo $b->d; $b->test(); ?> If executed, The first echo statement returns an error, as expected. The $b->test() call, however, returns `a::c', which I think is incorrect, as it should either not return anything or produce an error, since a::$c is declared as private and should not be available to the b namespace. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22489&edit=1

« previous php.bugs (#34579) next »