|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34924 Decorator pattern - php implementation
Submitted: 2005-10-20 02:22 UTC Modified: 2005-10-20 20:51 UTC
Avg. Score:3.7 ± 1.9
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: axo at axolander dot de Assigned: dmitry (profile)
Status: Wont fix Package: Class/Object related
PHP Version: 5.0.5 OS: UNIX
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: axo at axolander dot de
New email:
PHP Version: OS:


 [2005-10-20 02:22 UTC] axo at axolander dot de
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:

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();


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 />


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-20 10:30 UTC] stochnagara at hotmail dot com
This bug is also present in latest 5.1 snap.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Aug 01 10:01:24 2021 UTC