/** * Gets a list of the class properties as [Kodoc_Method] objects. * * @return array */ public function methods() { $methods = $this->class->getMethods(); //usort($methods, array($this, '_method_sort')); $tmpArr = array(); #当implements一些接口后,会导致出现重复的方法 $out_methods = array(); foreach ($methods as $key => $method) { $method_name = $method->name; if (isset($tmpArr[$this->class->name][$method_name])) { continue; } $tmpArr[$this->class->name][$method_name] = true; $obj = new _Docs_Method($this->class, $method_name); if ($obj->method->isPrivate() && $obj->class->name != $this->class->name) { // 非被函数的私有方法忽略 } else { $out_methods[$method_name] = $obj->getArrayCopy(); } } return $out_methods; }
/** * 获取Tag分析需要用到的数据 * * @param string $class_name * @param string $f * @param boolean $is_poperty */ protected static function rf_tag_by_class($class_name, $f = null, $is_poperty = false) { try { if (class_exists($class_name, true)) { if ($f) { if ($is_poperty) { $rf = new _Docs_Property($class_name, $f); } else { $rf = new _Docs_Method($class_name, $f); } $data = $rf->getArrayCopy(); return array('class_name' => $data['class_name'], 'f' => $f, 'is_php_class' => $data['is_php_class'], 'comment' => $data['title']); } else { $rf = new ReflectionClass($class_name); $f = $rf->getFileName(); if (substr($f, -13) == 'ev' . 'al()\'d code' && !is_file($f)) { $parent = $rf; # 程序生成的代码 while ($parent = $parent->getParentClass()) { if (substr(strtolower($parent->name), 0, 3) == 'ex_') { # 扩展类或略 continue; } $rf2 = new ReflectionClass($parent->name); $f = $rf2->getFileName(); if (substr($f, -13) != 'ev' . 'al()\'d code' && is_file($f)) { return array('class_name' => $rf2->name, 'is_php_class' => $rf2->getStartLine() ? 0 : 1, 'comment' => current(self::parse($rf2->getDocComment(), true))); } unset($rf2); } } else { return array('class_name' => $rf->name, 'is_php_class' => $rf->getStartLine() ? 0 : 1, 'comment' => current(self::parse($rf->getDocComment(), true))); } } } else { return false; } } catch (Exception $e) { return false; } }