예제 #1
0
 /**
  * Will start the inspection for a specific structure
  *
  * @param \TokenReflection\IReflection $structureReflection The current reflection to inspect
  * @param \TokenReflection\IReflection $formerReflection    The former reflection to compare to
  *
  * @return null
  *
  * @throws \Exception Will throw exception on errors
  *
  * TODO make this check different based on the structure we got
  */
 public function inspect(IReflection $structureReflection, IReflection $formerReflection)
 {
     if ($formerReflection->getName() !== $structureReflection->getName()) {
         // we seem to have been passed a mismatching structure pair, fail here
         throw new \Exception(sprintf('Mismatch of former and current structure information. %s !== %s', $formerReflection->getName(), $structureReflection->getName()));
     }
     // determine which type of reflection we have on our hands
     if ($structureReflection instanceof IReflectionClass && !$structureReflection->isInterface()) {
         // we got a class on our hands, so use class inspection
         $result = $this->inspectClass($structureReflection, $formerReflection);
     } elseif ($structureReflection instanceof IReflectionClass && $structureReflection->isInterface()) {
         // we got an interface, inspect it
         $result = $this->inspectInterface($structureReflection, $formerReflection);
     } else {
         // no inspection method found, fail here
         throw new \Exceptions(sprintf('Could not find inspection method for unknown type %s', \get_class($structureReflection)));
     }
     return $result;
 }
예제 #2
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();
 }