private function isPhpClass(Link $link)
 {
     $className = $link->getDestination();
     if (!class_exists($className, false)) {
         return false;
     }
     $classReflection = new \ReflectionClass($link->getDestination());
     return $classReflection->isInternal();
 }
 private function formatInternalMethod(Link $link)
 {
     if (empty($this->scope->class)) {
         return;
     }
     $methodName = substr($link->getDestination(), 0, strlen($link->getDestination()) - 2);
     $methods = $this->scope->class->getMethods(true);
     if (empty($methodName) || !array_key_exists($methodName, $methods)) {
         return;
     }
     $linkToClass = $this->getLinkToApiClass($this->scope->class->getName());
     return sprintf('[%s](%s#%s)', $link->getDescription(), $linkToClass, strtolower($methodName));
 }
 private function logUnresolvedLink(Link $link)
 {
     $blacklist = array('array', 'string', 'mixed', 'int', 'integer', 'bool');
     if (in_array($link->getDestination(), $blacklist)) {
         return;
     }
     $message = 'Unresolved link: "' . $link->getDestination() . '"';
     if (empty($this->scope->class) && $this->scope->namespace) {
         $message .= ' in Namespace ' . $this->scope->namespace;
     } elseif (!empty($this->scope->class)) {
         $message .= ' in Class ' . $this->scope->class;
     }
     error_log($message);
 }
 private function formatApiClass(Link $link)
 {
     $linkToClass = $this->getLinkToApiClass($link->getDestination());
     if (empty($linkToClass)) {
         return;
     }
     $description = $link->getDescription();
     $parts = explode("\\", $description);
     $description = end($parts);
     $link = sprintf('[%s](%s)', $description, $linkToClass);
     return $link;
 }
 private function formatInternalProperty(Link $link)
 {
     if (empty($this->scope->class)) {
         return;
     }
     $properties = $this->scope->class->getProperties(true);
     $propertyName = substr($link->getDestination(), 1);
     if (!$propertyName || !array_key_exists($propertyName, $properties)) {
         return;
     }
     $linkToClass = $this->getLinkToApiClass($this->scope->class->getName());
     return sprintf('[%s](%s#$%s)', $link->getDescription(), $linkToClass, strtolower($propertyName));
 }
 public function parse($comment)
 {
     if (preg_match_all('/{\\@link(.*?)}/', $comment, $matches)) {
         foreach ($matches[0] as $key => $rawLink) {
             $linkParser = new LinkParser($this->scope);
             $linkFormatted = $linkParser->parse($matches[1][$key]);
             $comment = str_replace($rawLink, $linkFormatted, $comment);
         }
     }
     if (preg_match_all('/{\\@hook(.*?)}/', $comment, $matches)) {
         foreach ($matches[0] as $key => $rawLink) {
             $link = new Link($matches[1][$key]);
             $anchor = strtolower(str_replace('.', '', $link->getDestination()));
             $linkFormatted = sprintf('[%s](/api-reference/events#%s)', $link->getDescription(), $anchor);
             $comment = str_replace($rawLink, $linkFormatted, $comment);
         }
     }
     return $comment;
 }
 private function formatInternalConstant(Link $link)
 {
     $constName = $link->getDestination();
     if (empty($this->scope->class) || empty($constName)) {
         return;
     }
     $constants = $this->scope->class->getConstants(true);
     if (!array_key_exists($constName, $constants)) {
         return;
     }
     $constant = $constants[$constName];
     if (!$constant) {
         return;
     }
     $description = $link->getDescription();
     if ($constant->getLongDesc()) {
         // we are displaying a link only to constants having a long description.
         $linkToClass = $this->getLinkToApiClass($this->scope->class->getName());
         return sprintf('`[%s](%s#%s)`', $description, $linkToClass, strtolower($constant));
     }
     return sprintf('`%s`', $description);
 }
 protected function parseLinkToExternalClass(Link $link)
 {
     return explode('::', $link->getDestination());
 }
 public function formatting(Link $link)
 {
     return $this->formatExternalLink($link->getDestination(), $link->getDescription());
 }
예제 #10
0
 public function addLink(Link $link)
 {
     $linkID = $this->getLinkID($link->getSource(), $link->getDestination());
     $this->links[$linkID] = $link;
 }