ID: 26841 Comment by: nlhowell at cableone dot net Reported By: [EMAIL PROTECTED] Status: Verified Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5CVS-2004-03-15 New Comment:
While this *is* wrong (imo), I also see another problem, which is that there's not enough qualification with this. IMO, 'parent::$a' should refer to the static $a, while '$this->parent::$a' should refer to the derived $a, much like 'self::$a' refers to the static $a and '$this->a' refers to the instance $a. Although you can't have a static $a and a public $a, you can have a static $a that operates as both. Somehow this should be changed to provide a consistant way to access static and instance members. Nick Previous Comments: ------------------------------------------------------------------------ [2004-01-12 07:19:38] [EMAIL PROTECTED] Sorry, the actual output is : int(2) int(2) PHP Fatal error: Cannot access protected property base::$a in /home/andrey/test/t.php on line 15 ------------------------------------------------------------------------ [2004-01-08 07:08:29] [EMAIL PROTECTED] Description: ------------ Hello,.. today I tried the code which I post as reproduce code. I expect in public_func2() the property which is declared as protected in the base class to be visible. However PHP bails out with message : PHP Fatal error: Cannot access protected property base::$a in /home/andrey/test/t.php on line 16 . Use of parent:: does not help also. AFAIK protected member vars should be visible in the generalization classes. As a side note please refer to bug #18024, for an additional effect which can be seen when using the reproduce code - shadowing of the variable declared in the base class. Method public_func1() of the base class uses the variable $a of "child" which is shadowing $a of "base". Is this an expected behaviour? Thanks Reproduce code: --------------- <?php class base { protected $a = array(); public function public_func1() { var_dump($this->a); } } class child extends base { public $a = 2; public function public_func2() { var_dump($this->a); var_dump(parent::$a); } } $a = new child(); $a->public_func1(); $a->public_func2(); ?> Expected result: ---------------- int(2) int(2) array(0) { } Actual result: -------------- int(2) int(2) PHP Fatal error: Cannot access protected property base::$a in /home/andrey/test/t.php on line 16 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26841&edit=1