#34924 [NEW]: Decorator pattern - php implementation
| From: | axo at axolander dot de | Date: | Thu, 20 Oct 2005 00:22:07 +0000 |
| Subject: | #34924 [NEW]: Decorator pattern - php implementation | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-86781@lists.php.net to get a copy of this message | ||
From: axo at axolander dot de
Operating system: UNIX
PHP version: 5.0.5
PHP Bug Type: Class/Object related
Bug description: Decorator pattern - php implementation
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 bug report at http://bugs.php.net/?id=34924&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34924&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34924&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34924&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34924&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34924&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34924&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34924&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34924&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34924&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34924&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=34924&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=34924&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34924&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34924&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34924&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34924&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34924&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34924&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34924&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34924&r=mysqlcfg