Пример #1
0
 /**
  * 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();
 }
Пример #2
0
 /**
  * Will test if a method did get removed from a structure
  *
  * @param \TokenReflection\IReflection $structureReflection The current reflection to inspect
  * @param \TokenReflection\IReflection $formerReflection    The former inspection to compare to
  *
  * @return boolean
  */
 protected function didRemoveMethod(IReflection $structureReflection, IReflection $formerReflection)
 {
     // get the public methods of both current and former definition
     $currentMethods = $structureReflection->getMethods(\ReflectionMethod::IS_PUBLIC);
     $formerMethods = $formerReflection->getMethods(\ReflectionMethod::IS_PUBLIC);
     // if there aren't less methods now we don't have to do anything
     if (count($currentMethods) >= count($formerMethods)) {
         return false;
     }
     // as we reached this point there seems to be missing methods.
     // check which one is missing
     foreach ($formerMethods as $formerMethod) {
         // iterate all the current methods and check for a match
         $matchFound = false;
         foreach ($currentMethods as $currentMethod) {
             if ($formerMethod->getName() === $currentMethod->getName()) {
                 // we have a match, so no problem here
                 $matchFound = true;
                 continue;
             }
         }
         // did we find a match?
         if ($matchFound === false) {
             // report this public method as missing
             $this->result->addReason(new Reason($structureReflection, $formerMethod, Reason::METHOD_REMOVED, $this->mapper));
         }
     }
     // tell them at least one method is missing now
     return true;
 }