这是基本的类设计
class CustomModule {
public __construct() { }
//Run me first automaticly
public function exec($str) { }
}
class Randomizer extends CustomModule {
public __construct() { }
//Call me
public function exec($str) { }
}
当我为外部开发人员设计一个插件/模块系统时,我需要CustomModule->exec()首先运行,我不想让开发人员不得不调用 base->exec($str).
我想CustomModule::exec()在调用之前自动Randomizer::exec()调用,而无需将代码放入Randomizer::exec(). 这可能与魔术功能有关吗?