Example #1
0
 /**
  * Processes the parent reflection object.
  *
  * @param \TokenReflection\IReflection $parent Parent reflection object
  * @param \TokenReflection\Stream\StreamBase $tokenStream Token substream
  * @return \TokenReflection\ReflectionClass
  * @throws \TokenReflection\ParseException On invalid parent reflection provided
  */
 protected function processParent(IReflection $parent, Stream $tokenStream)
 {
     if (!$parent instanceof ReflectionFileNamespace) {
         throw new Exception\ParseException($this, $tokenStream, sprintf('Invalid parent reflection provided: "%s".', get_class($parent)), Exception\ParseException::INVALID_PARENT);
     }
     $this->namespaceName = $parent->getName();
     $this->aliases = $parent->getNamespaceAliases();
     return parent::processParent($parent, $tokenStream);
 }
 /**
  * Magic __isset method.
  *
  * @param string $key Variable name
  *
  * @return boolean
  */
 public final function __isset($key)
 {
     return TokenReflection\ReflectionElement::exists($this, $key);
 }
 /**
  * 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 ReflectionFunctionBase) {
         throw new Exception\ParseException($this, $tokenStream, 'The parent object has to be an instance of TokenReflection\\ReflectionFunctionBase.', Exception\ParseException::INVALID_PARENT);
     }
     // Declaring function name
     $this->declaringFunctionName = $parent->getName();
     // Position
     $this->position = count($parent->getParameters());
     // Declaring class name
     if ($parent instanceof ReflectionMethod) {
         $this->declaringClassName = $parent->getDeclaringClassName();
     }
     return parent::processParent($parent, $tokenStream);
 }
 /**
  * Find the appropriate docblock.
  *
  * @param \TokenReflection\Stream\StreamBase $tokenStream Token substream
  * @param \TokenReflection\IReflection $parent Parent reflection
  * @return \TokenReflection\ReflectionElement
  */
 protected function parseDocComment(Stream $tokenStream, IReflection $parent)
 {
     if (!$tokenStream->is(T_NAMESPACE)) {
         $this->docComment = new ReflectionAnnotation($this);
         return $this;
     } else {
         return parent::parseDocComment($tokenStream, $parent);
     }
 }
 /**
  * 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\Parse 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);
 }
 /**
  * Parses reflected element metadata from the token stream.
  *
  * @param \TokenReflection\Stream\StreamBase $tokenStream Token substream
  * @param \TokenReflection\IReflection $parent Parent reflection object
  * @return \TokenReflection\ReflectionConstant
  */
 protected function parse(Stream $tokenStream, IReflection $parent)
 {
     if ($tokenStream->is(T_CONST)) {
         $tokenStream->skipWhitespaces(true);
     }
     if (false === $this->docComment->getDocComment()) {
         parent::parseDocComment($tokenStream, $parent);
     }
     return $this->parseName($tokenStream)->parseValue($tokenStream, $parent);
 }