2010-11-28 68 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>"; 
相关问题