public function parse(SourceScanner $scanner) { $ref = $this->reflection; $returnType = $ref->getReturnType(); if (!empty($returnType)) { $returnType = $returnType->__toString(); } $file = $scanner->filterFile($ref->getFileName()); $filePath = $file !== false ? $file['path'] : ''; $this->name = $ref->getName(); $this->namespace = $ref->getNamespaceName(); $this->file = $filePath; $this->startLine = $ref->getStartLine(); $this->endLine = $ref->getEndLine(); $this->returnType = $returnType; if ($ref instanceof ReflectionMethod) { $access = ReflectionProperty::IS_PUBLIC; if ($ref->isPrivate()) { $access = ReflectionProperty::IS_PRIVATE; } elseif ($ref->isProtected()) { $access = ReflectionProperty::IS_PROTECTED; } $this->access = $access; $this->class = $ref->getDeclaringClass()->getName(); $this->fullName = $this->class . '::' . $this->name; $this->isStatic = $ref->isStatic(); $this->isFinal = $ref->isFinal(); $this->isAbstract = $ref->isAbstract(); $this->isInternal = $ref->isInternal(); $this->isConstructor = $ref->isConstructor(); $this->isDestructor = $ref->isDestructor(); $this->doc = DocCommentParser::autoParse($ref->getDocComment(), $scanner, DocMen::METHOD, $this->class, $this->name); } else { $this->access = ReflectionProperty::IS_PUBLIC; $this->fullName = (empty($this->namespace) ? '' : $this->namespace . '\\') . $this->name; $this->isStatic = true; $this->isFinal = true; $this->isAbstract = false; $this->isInternal = $ref->isInternal(); $this->isConstructor = false; $this->isDestructor = false; $this->doc = DocCommentParser::autoParse($ref->getDocComment(), $scanner, DocMen::FUNC, null, $this->name); } $this->pushParams($scanner, $ref); if ($ref instanceof ReflectionMethod) { $scanner->addIndex(DocMen::METHOD, $this->fullName); } return $this; }
public function parseProp(SourceScanner $scanner, ReflectionProperty $prop, array $defaultProps = null) { $name = $prop->getName(); $class = $prop->getDeclaringClass()->getName(); $access = ReflectionProperty::IS_PUBLIC; if ($prop->isPrivate()) { $access = ReflectionProperty::IS_PRIVATE; } elseif ($prop->isProtected()) { $access = ReflectionProperty::IS_PROTECTED; } $doc = DocCommentParser::autoParse($prop->getDocComment(), $scanner, DocMen::PROP, $class, $name); return ['name' => $name, 'fullName' => $class . '::$' . $name, 'class' => $class, 'isStatic' => $prop->isStatic(), 'access' => $access, 'isDefault' => $prop->isDefault(), 'doc' => $doc]; }