/**
  * @return string
  */
 public function createForConstant(ReflectionConstant $constant)
 {
     // Class constant
     if ($className = $constant->getDeclaringClassName()) {
         return $this->createForClass($className) . '#' . $constant->getName();
     }
     // Constant in namespace or global space
     return sprintf($this->configuration->getOption(CO::TEMPLATE)['templates']['constant']['filename'], Filters::urlize($constant->getName()));
 }
示例#2
0
 /**
  * Sorts constants by FQN.
  *
  * @param \ApiGen\Reflection\ReflectionConstant $one
  * @param \ApiGen\Reflection\ReflectionConstant $two
  * @return integer
  */
 private function sortConstants(Reflection\ReflectionConstant $one, Reflection\ReflectionConstant $two)
 {
     return strcasecmp(($one->getDeclaringClassName() ?: $one->getNamespaceName()) . '\\' . $one->getName(), ($two->getDeclaringClassName() ?: $two->getNamespaceName()) . '\\' . $two->getName());
 }
 /**
  * @return string
  */
 private function getConstantFqnName(ReflectionConstant $reflection)
 {
     $class = $reflection->getDeclaringClassName() ?: $reflection->getNamespaceName();
     return $class . '\\' . $reflection->getName();
 }
 /**
  * @return string
  */
 private function getGlobalConstantName(ReflectionConstant $reflectionConstant)
 {
     if ($reflectionConstant->inNamespace()) {
         return $reflectionConstant->getNamespaceName() . '\\' . Html::el('b')->setText($reflectionConstant->getShortName());
     } else {
         return Html::el('b')->setText($reflectionConstant->getName());
     }
 }
示例#5
0
 /**
  * Returns a link to constant in class summary file or to constant summary file.
  *
  * @param \ApiGen\Reflection\ReflectionConstant $constant Constant reflection
  * @return string
  */
 public function getConstantUrl(Reflection\ReflectionConstant $constant)
 {
     // Class constant
     if ($className = $constant->getDeclaringClassName()) {
         return $this->getClassUrl($className) . '#' . $constant->getName();
     }
     // Constant in namespace or global space
     return sprintf($this->config->template->templates->main->constant->filename, $this->urlize($constant->getName()));
 }
 /**
  * Returns visible properties.
  *
  * @return array
  */
 public function getConstants()
 {
     if (null === $this->constants) {
         $this->constants = array();
         foreach ($this->reflection->getConstantReflections() as $constant) {
             $apiConstant = new ReflectionConstant($constant, self::$generator);
             if (!$this->isDocumented() || $apiConstant->isDocumented()) {
                 $this->constants[$constant->getName()] = $apiConstant;
             }
         }
     }
     return $this->constants;
 }