是否可以检查方法是否已被 PHP 中的子类覆盖?
<!-- language: lang-php -->
class foo {
    protected $url;
    protected $name;
    protected $id;
    var $baz;
    function __construct($name, $id, $url) {
        $this->name = $name;
        $this->id = $id;
        $this->url = $url;
    }
    function createTable($data) {
        // do default actions
    }
}
儿童班:
class bar extends foo {
    public $goo;
    public function createTable($data) {
        // different code here
    }
}
在遍历定义为此类成员的对象数组时,如何检查哪些对象具有新方法而不是旧方法?是否存在诸如此类的功能method_overridden(mixed $object, string $method name)?
foreach ($objects as $ob) {
    if (method_overridden($ob, "createTable")) {
        // stuff that should only happen if this method is overridden
    }
    $ob->createTable($dataset);
}
我知道模板方法模式,但是假设我希望程序的控制与类和方法本身分开。我需要一个功能method_overridden来完成这个。