Exemple #1
0
 /**
  * Returns a link to a element documentation at php.net.
  *
  * @param \ApiGen\Reflection\ReflectionBase $element Element reflection
  * @return string
  */
 public function getManualUrl(Reflection\ReflectionBase $element)
 {
     static $manual = 'http://php.net/manual';
     static $reservedClasses = array('stdClass', 'Closure', 'Directory');
     // Extension
     if ($element instanceof Reflection\ReflectionExtension) {
         $extensionName = strtolower($element->getName());
         if ('core' === $extensionName) {
             return $manual;
         }
         if ('date' === $extensionName) {
             $extensionName = 'datetime';
         }
         return sprintf('%s/book.%s.php', $manual, $extensionName);
     }
     // Class and its members
     $class = $element instanceof Reflection\ReflectionClass ? $element : $element->getDeclaringClass();
     if (in_array($class->getName(), $reservedClasses)) {
         return $manual . '/reserved.classes.php';
     }
     $className = strtolower($class->getName());
     $classUrl = sprintf('%s/class.%s.php', $manual, $className);
     $elementName = strtolower(strtr(ltrim($element->getName(), '_'), '_', '-'));
     if ($element instanceof Reflection\ReflectionClass) {
         return $classUrl;
     } elseif ($element instanceof Reflection\ReflectionMethod) {
         return sprintf('%s/%s.%s.php', $manual, $className, $elementName);
     } elseif ($element instanceof Reflection\ReflectionProperty) {
         return sprintf('%s#%s.props.%s', $classUrl, $className, $elementName);
     } elseif ($element instanceof Reflection\ReflectionConstant) {
         return sprintf('%s#%s.constants.%s', $classUrl, $className, $elementName);
     }
 }