2010-11-28 103 views

回答

2

如果一個函數有一個定義良好的返回值,那麼您可以簡單地從源代碼中提取出來。想象一下這樣的事情:

return $this->isValid() ? $result : $this->createNullObject(); 

這很難(/不可能)解析只是爲了得到返回值。您可以改用DocComments。 @return是用於該用途)上的ReflectionMethod -object通常的標籤

/** 
* MyMethod 
* 
* @return int 
*/ 

呼叫getDocComment(,然後解析docComment。

0

的內部功能,你可以使用

$reflect = new ReflectionExtension('standard'); 
echo "<pre>" . $reflect . "</pre>"; 
相關問題