ID: 34924
Updated by: [EMAIL PROTECTED]
Reported By: axo at axolander dot de
-Status: Assigned
+Status: Wont fix
Bug Type: Class/Object related
Operating System: UNIX
PHP Version: 5.0.5
Assigned To: dmitry
Previous Comments:
------------------------------------------------------------------------
[2005-10-20 10:30:00] stochnagara at hotmail dot com
This bug is also present in latest 5.1 snap.
------------------------------------------------------------------------
[2005-10-20 02:22:06] axo at axolander dot de
Description:
------------
i'm often making heavy use of the decorator pattern.
while this works in c++ or java, php tells me the 'protected' context
does not work.
how's this to interpret?
Reproduce code:
---------------
<?php
abstract class A {
protected abstract function func();
}
class Decorator extends A {
private $_decorated;
public function __construct(A $a) {
$this -> _decorated = $a;
}
protected function func() {
$this -> _decorated -> func();
}
public function doCall() {
$this -> func();
}
}
class ASmall extends A {
protected function func() {
printf("%s::%s called!\n",__CLASS__,__FUNCTION__);
}
}
$a = new ASmall();
$dec = new Decorator($a);
$dec -> doCall();
die();
Expected result:
----------------
ASmall::func called!
Actual result:
--------------
<br />
<b>Fatal error</b>: Call to protected method ASmall::func() from
context 'Decorator' in <b>fileName</b> on line <b>12</b><br />
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34924&edit=1