/** * Processes the parent reflection object. * * @param \TokenReflection\IReflection $parent Parent reflection object * @param \TokenReflection\Stream\StreamBase $tokenStream Token substream * * @return \TokenReflection\ReflectionElement * @throws \TokenReflection\Exception\ParseException If an invalid parent reflection object was provided. */ protected function processParent(IReflection $parent, Stream $tokenStream) { if (!$parent instanceof ReflectionClass) { throw new Exception\ParseException($this, $tokenStream, 'The parent object has to be an instance of TokenReflection\\ReflectionClass.', Exception\ParseException::INVALID_PARENT); } $this->declaringClassName = $parent->getName(); if ($parent->isTrait()) { $this->declaringTraitName = $parent->getName(); } return parent::processParent($parent, $tokenStream); }
/** * 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(); }