コード例 #1
0
 /**
  * @param ReflectionElement $element
  * @return string
  */
 private function getElementLinesAnchor(ReflectionElement $element)
 {
     $anchor = '#' . $element->getStartLine();
     if ($element->getStartLine() !== $element->getEndLine()) {
         $anchor .= '-' . $element->getEndLine();
     }
     return $anchor;
 }
コード例 #2
0
ファイル: Template.php プロジェクト: sirone/apigen
 /**
  * Returns a link to a element source code.
  *
  * @param \ApiGen\Reflection\ReflectionElement $element Element reflection
  * @param boolean $withLine Include file line number into the link
  * @return string
  */
 public function getSourceUrl(Reflection\ReflectionElement $element, $withLine = true)
 {
     if ($element instanceof Reflection\ReflectionClass || $element instanceof Reflection\ReflectionFunction || $element instanceof Reflection\ReflectionConstant && null === $element->getDeclaringClassName()) {
         $elementName = $element->getName();
         if ($element instanceof Reflection\ReflectionClass) {
             $file = 'class-';
         } elseif ($element instanceof Reflection\ReflectionConstant) {
             $file = 'constant-';
         } elseif ($element instanceof Reflection\ReflectionFunction) {
             $file = 'function-';
         }
     } else {
         $elementName = $element->getDeclaringClassName();
         $file = 'class-';
     }
     $file .= $this->urlize($elementName);
     $lines = null;
     if ($withLine) {
         $lines = $element->getStartLine() !== $element->getEndLine() ? sprintf('%s-%s', $element->getStartLine(), $element->getEndLine()) : $element->getStartLine();
     }
     return sprintf($this->config->template->templates->main->source->filename, $file) . (null !== $lines ? '#' . $lines : '');
 }