I read here: http://osdir.com/ml/php.phpunit.user/2008-05/msg00009.html that changing a class final
behaviour may be changed with runkit - I just cant see the way how.
EDIT: dont -1 me pls, I checked the runkit_import() function and also the http://php.net/manual/en/runkit.constants.php still cant find the way
It's of... limited use. An illustration:
final class Foo {
protected $var = '456';
function doSomething(){
return '123';
}
function getVar(){
return $this->var;
}
}
class Bar {
}
runkit_class_adopt('Bar','Foo');
$d = new Bar();
var_dumP($d->doSomething());
//string(3) "123"
var_dumP($d->getVar());
//PHP Notice: Undefined property: Bar::$var in .... on line 10
//NULL
You're usually better of writing a Decorator for final
classes (or removing the final
from the source).