|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-07-03 05:05 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 09:00:01 2025 UTC |
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