[英]Php runkit_import and final classes
我在這里閱讀: http ://osdir.com/ml/php.phpunit.user/2008-05/msg00009.html更改類的final
行為可能會通過Runkit進行更改-我只是不知道怎么做。
編輯:請不要-1我,我檢查了runkit_import()函數,而且http://php.net/manual/en/runkit.constants.php仍然找不到方法
用途有限。 插圖:
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
你通常是更好的寫一個裝飾為final
(或移除類final
從源頭)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.