Posted by Janwillem Borleffs on 05/29/05 01:55
Janwillem Borleffs wrote:
> Not possible, because only the class that extends the abstract class
> is forced to implement the method.
>
> Other classes just inherit the method.
>
However, there is a way using the Reflection API:
abstract class Foo {
final function __construct() {
$rm = new ReflectionMethod($this, 'init');
if (get_class($this) != $rm->getDeclaringClass()->getName()) {
throw new Exception("init() method must be implemented");
}
}
abstract function init();
}
But be aware that using the Reflection API in production applications can
have a negative impact on performance.
JW
[Back to original message]
|