Beispiel #1
0
 /**
  * Generate class / function info
  *
  * @param   Reflector $reflector      Class name or reflection object
  * @param   string $single            Skip parent classes
  * @param   Reflector|null $context   Object context (for methods)
  * @return  string
  */
 protected function fromReflector(\Reflector $reflector, $single = '', \Reflector $context = null)
 {
     // @todo: test this
     $hash = var_export(func_get_args(), true);
     //$hash = $reflector->getName() . ';' . $single . ';' . ($context ? $context->getName() : '');
     if ($this->fmt->didCache($hash)) {
         static::$debug['cacheHits']++;
         return;
     }
     $items = array($reflector);
     if ($single === '' && $reflector instanceof \ReflectionClass) {
         $items = static::getParentClasses($reflector);
     }
     $first = true;
     foreach ($items as $item) {
         if (!$first) {
             $this->fmt->sep(' :: ');
         }
         $first = false;
         $name = $single !== '' ? $single : $item->getName();
         $comments = $item->isInternal() ? array() : static::parseComment($item->getDocComment());
         $meta = array('sub' => array());
         $bubbles = array();
         if ($item->isInternal()) {
             $extension = $item->getExtension();
             $meta['title'] = $extension instanceof \ReflectionExtension ? sprintf('Internal - part of %s (%s)', $extension->getName(), $extension->getVersion()) : 'Internal';
         } else {
             $comments = static::parseComment($item->getDocComment());
             if ($comments) {
                 $meta += $comments;
             }
             $meta['sub'][] = array('Defined in', basename($item->getFileName()) . ':' . $item->getStartLine());
         }
         if ($item instanceof \ReflectionFunction || $item instanceof \ReflectionMethod) {
             if ($context !== null && $context->getShortName() !== $item->getDeclaringClass()->getShortName()) {
                 $meta['sub'][] = array('Inherited from', $item->getDeclaringClass()->getShortName());
             }
             if ($item instanceof \ReflectionMethod) {
                 try {
                     $proto = $item->getPrototype();
                     $meta['sub'][] = array('Prototype defined by', $proto->class);
                 } catch (\Exception $e) {
                 }
             }
             $this->fmt->text('name', $name, $meta, $this->linkify($item));
             continue;
         }
         // @todo: maybe - list interface methods
         if (!($item->isInterface() || static::$env['is54'] && $item->isTrait())) {
             if ($item->isAbstract()) {
                 $bubbles[] = array('A', 'Abstract');
             }
             if ($item->isFinal()) {
                 $bubbles[] = array('F', 'Final');
             }
             // php 5.4+ only
             if (static::$env['is54'] && $item->isCloneable()) {
                 $bubbles[] = array('C', 'Cloneable');
             }
             if ($item->isIterateable()) {
                 $bubbles[] = array('X', 'Iterateable');
             }
         }
         if ($item->isInterface() && $single !== '') {
             $bubbles[] = array('I', 'Interface');
         }
         if ($bubbles) {
             $this->fmt->bubbles($bubbles);
         }
         if ($item->isInterface() && $single === '') {
             $name .= sprintf(' (%d)', count($item->getMethods()));
         }
         $this->fmt->text('name', $name, $meta, $this->linkify($item));
     }
     $this->fmt->cacheLock($hash);
 }
Beispiel #2
0
 private function isValidTestFile(\Reflector $reflector, array $testFiles)
 {
     return in_array($reflector->getFileName(), $testFiles) && isValidTestName($reflector->getShortName());
 }