public function parse(SourceScanner $scanner) { // if (!$this->isExists()) { // $scanner->addNotExistsClass($this->class); // return $this; // } try { // 这里还是有可能会出错的,所以还是要try ... catch $ref = $this->getReflection(); } catch (Throwable $thrown) { $scanner->addMissItem(DocMen::CLS, $this->class, $this->inputPath, $thrown->getMessage()); return $this; } $file = $scanner->filterFile($ref->getFileName()); $filePath = $file !== false ? $file['path'] : ''; // 基础信息解析 $this->name = $ref->getName(); $this->shortName = $ref->getShortName(); $this->namespace = $ref->getNamespaceName(); $this->parent = $this->getParentClass($ref); $this->doc = DocCommentParser::autoParse($ref->getDocComment(), $scanner, $this->scope, $this->name, null); $this->file = $filePath; $this->startLine = $ref->getStartLine(); $this->endLine = $ref->getEndLine(); $this->isAbstract = $ref->isAbstract(); $this->isFinal = $ref->isFinal(); $this->isInternal = $ref->isInternal(); $nsStyle = $scanner->getOption(SourceScanner::OPS_NS_STYLE); if ($nsStyle === DocMen::NS_STYLE_OLD_PEAR || $nsStyle === DocMen::NS_STYLE_MIXED && empty($this->namespace)) { $split = explode('_', $this->name); array_pop($split); if (!empty($split)) { $this->namespace = implode('\\', $split); } } // 使用的Traits $traits = $ref->getTraits(); foreach ($traits as $trait) { $name = $trait->getName(); $this->traits[$name] = $name; $this->traitsCount += 1; } // 实现的接口 $impls = $ref->getInterfaces(); foreach ($impls as $impl) { $name = $impl->getName(); $this->impls[$name] = $name; $this->implsCount += 1; } $this->pushConstants($scanner, $ref); $this->pushMethods($scanner, $ref); $this->pushProperties($scanner, $ref); if (!empty($this->sort)) { array_multisort($this->sort, SORT_ASC, $this->packages); } $scanner->addClass($this); return $this; }