#24471 [NEW]: protected data member redeclared as public

From: Date: Thu, 03 Jul 2003 05:09:43 +0000
Subject: #24471 [NEW]: protected data member redeclared as public
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-43141@lists.php.net to get a copy of this message
From:             greg at chiaraquartet dot net
Operating system: linux
PHP version:      5.0.0b1 (beta1)
PHP Bug Type:     Zend Engine 2 problem
Bug description:  protected data member redeclared as public

Description:
------------
if a protected data member is re-declared as public in a child class, it
is redefined as public.  Shouldn't the parent class protected declaration
override the child class as it does for private?

Reproduce code:
---------------
<?php
class test
{
	protected $a = 6;
	function __construct()
	{
		print $this->a;
	}
}

class my extends test
{
	var $a = 7;
	function __construct()
	{
		print $this->a;
		parent::__construct();
	}
}
$a = new test; // 6
$a = new my; // 77
print $a->a; // should give error, is 7
$a->a = 4;
print $a->a; // 4
?>

Expected result:
----------------
Fatal Error, cannot redeclare a protected data member as public

Actual result:
--------------
67774

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



Thread (2 messages)

« previous php.bugs (#43141) next »