예제 #1
0
파일: Document.php 프로젝트: dotink/sage
 /**
  * Creates a new document
  *
  * @access public
  * @param IReflection $reflection The reflection to use
  * @param Generator $generator The generator that is creating this document
  * @param IReflection $context The context where the reflection was found
  * @return Document The document for method chaining
  */
 public function __construct(IReflection $reflection, $generator, IReflection $context)
 {
     $this->reflection = $reflection;
     $this->generator = $generator;
     $this->context = $context;
     if ($reflection instanceof TokenReflection\IReflectionConstant) {
         $this->type = self::TYPE_CONSTANT;
     } elseif ($reflection instanceof TokenReflection\IReflectionFunction) {
         $this->type = self::TYPE_FUNCTION;
     } elseif ($reflection instanceof TokenReflection\IReflectionProperty) {
         $this->type = self::TYPE_PROPERTY;
         $this->keys[] = 'property';
         $this->keyModifiers($context);
     } elseif ($reflection instanceof TokenReflection\IReflectionMethod) {
         $this->type = self::TYPE_METHOD;
         $this->keys[] = 'method';
         $this->keyModifiers($context);
     } elseif ($reflection instanceof TokenReflection\IReflectionClass) {
         $this->type = $reflection->isTrait() ? self::TYPE_TRAIT : ($reflection->isInterface() ? self::TYPE_INTERFACE : self::TYPE_CLASS);
         foreach ($reflection->getProperties() as $property) {
             $document = new self($property, $this->generator, $reflection);
             $this->documents[] = $document;
         }
         foreach ($reflection->getMethods() as $method) {
             $document = new self($method, $this->generator, $reflection);
             $this->documents[] = $document;
         }
     }
     $this->parseDocComment();
 }