尊敬的Zend Framework專家,Zend_Reflection_Property的isPublic()和其他方法如何記錄和定義?
我想了解Zend框架API文檔是如何組織的。例如,看一下這個代碼片段:
$reflectionClass = new Zend_Reflection_Class($object);
$properties = $reflectionClass->getProperties();
foreach ($properties as $property) {
if ($property->isPublic()) {
// do something
}
}
打字時在Eclipse/PDT這個代碼,我注意到Eclipse並沒有給我的代碼完成提示什麼方法是可用的$屬性對象調用。我期望它列出像isPublic(),isStatic()等方法。
所以我去v1.11 Zend Framework API documentation這裏是它說的:Zend_Reflection_Class的getProperties()返回一個Zend_Reflection_Property對象數組,它使$ property(在上面的代碼中)成爲一個Zend_Reflection_Property。我檢查了Zend_Reflection_Property的API文檔,但沒有使用isPublic()方法。實際上,Zend_Reflection_Property中只列出了兩個方法:getDeclaringClass()和getDocComment()。該文檔甚至沒有告訴你Zend_Reflection_Property是否擴展了可以繼承isPublic()方法的另一個類。
接下來我將轉到Zend_Reflection_Property的實際代碼。在代碼中,我發現Zend_Reflection_Property擴展了ReflectionProperty,所以我認爲isPublic()是從ReflectionProperty繼承的。但是我無法找到ReflectionProperty類的文檔來驗證這一點。更糟糕的是,我甚至找不到通過在Zend目錄中執行遞歸grep來定義ReflectionProperty類的代碼!我的問題是這樣的:如何找到所有的方法(包括繼承的方法)可以在一般的ZF對象上調用,特別是在Zend_Reflection_Property對象中(比如在這種情況下)?
這是你想通過閱讀API文檔能夠回答的那種問題,對吧?理想情況下,您不必進入庫代碼來弄清楚如何使用它的類。但我甚至願意閱讀代碼 - Zend_Reflection_Property擴展的ReflectionProperty類的代碼在哪裏?
也許我只是不知道我的Zend框架API文檔的方式。我非常感謝Zend Framework專家的啓發。
在此先感謝。
謝謝,netcoder! (哎呀,不知道接受,對不起。) – RBR 2011-05-03 03:44:05