/**
  * {@inheritDoc}
  */
 public function getPropertyAnnotations(\ReflectionProperty $property)
 {
     return $this->parser->parse($property->getDocComment(), 'property ' . $property->getDeclaringClass()->name . '::$' . $property->getName());
 }
Exemple #2
0
function parse_doc($php_doc_comment)
{
    $p = new DocParser();
    return $p->parse($php_doc_comment);
    $p = new Parser($php_doc_comment);
    return $p;
    $php_doc_comment = preg_replace("/(^[\\s]*\\/\\*\\*)\n        |(^[\\s]\\*\\/)\n        |(^[\\s]*\\*?\\s)\n        |(^[\\s]*)\n        |(^[\\t]*)/ixm", "", $php_doc_comment);
    $php_doc_comment = str_replace("\r", "", $php_doc_comment);
    $php_doc_comment = preg_replace("/([\\t])+/", "\t", $php_doc_comment);
    return explode("\n", $php_doc_comment);
    $php_doc_comment = trim(preg_replace('/\\r?\\n *\\* */', ' ', $php_doc_comment));
    return $php_doc_comment;
    preg_match_all('/@([a-z]+)\\s+(.*?)\\s*(?=$|@[a-z]+\\s)/s', $php_doc_comment, $matches);
    return array_combine($matches[1], $matches[2]);
}
Exemple #3
0
    foreach ($objs as $className) {
        $class = new \ReflectionClass($className);
        $json['path'] = strtolower("/resources/" . $class->getShortName() . ".{format}");
        $json['description'] = "";
        $config['apis'][] = $json;
    }
    echo json_encode($config, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
} else {
    if (array_key_exists($className, $objs)) {
        $class = new \ReflectionClass($objs[$className]);
        $methods = $class->getMethods();
        $DocParser = new DocParser();
        foreach ($methods as $method) {
            //公共方法才生成文档
            if ($method->isPublic()) {
                $info = $DocParser->parse($method->getDocComment());
                $json = array();
                $json['path'] = strtolower('/' . $class->getShortName() . '/' . $method->getName() . ".{format}");
                $json['description'] = $info['description'];
                $operation['nickname'] = $method->getName();
                $operation['summary'] = $info['description'];
                foreach ($method->getParameters() as $key => $parameter) {
                    $temp = explode('$' . $parameter->getName(), $info['param'][$key]);
                    $dataType = str_replace('(', '', $temp[0]);
                    $dataType = str_replace(')', '', $dataType);
                    $params = ["name" => $parameter->getName(), "description" => $info['param'][$key], "paramType" => "query", "required" => true, "defaultValue" => 0, "allowMultiple" => false, "dataType" => $dataType];
                    try {
                        if ($parameter->isOptional()) {
                            $params['required'] = false;
                        }
                    } catch (\Exception $e) {