/**
  * Adds a new property to the class using an array of tokens.
  *
  * @param ClassReflection $class       Class reflection
  * @param string          $propertyTag Property tag contents
  *
  * @return bool
  */
 protected function injectProperty(ClassReflection $class, $propertyTag)
 {
     if (!($data = $this->parseProperty($propertyTag))) {
         return false;
     }
     $property = new PropertyReflection($data['name'], $class->getLine());
     $property->setDocComment($data['description']);
     $property->setShortDesc($data['description']);
     if (isset($data['hint'])) {
         $property->setHint(array(array($data['hint'], null)));
     }
     $class->addProperty($property);
     return true;
 }
 public function acceptProperty(PropertyReflection $property)
 {
     if ($property->isPrivate()) {
         return false;
     }
     if ($property->isProtected() && !$this->hasApiTag($property)) {
         return false;
     }
     if ($this->hasApiTag($property)) {
         return true;
     }
     if ($this->hasApiTag($property->getClass())) {
         return true;
     }
     return false;
 }
Example #3
0
 public function pathForProperty(array $context, PropertyReflection $property)
 {
     return $this->relativeUri($this->currentDepth) . str_replace('\\', '/', $property->getClass()->getName()) . '.html#property_' . $property->getName();
 }
Example #4
0
 protected function addProperty(\PHPParser_Node_Stmt_Property $node)
 {
     foreach ($node->props as $prop) {
         $property = new PropertyReflection($prop->name, $prop->getLine());
         $property->setModifiers($node->type);
         if ($this->context->getFilter()->acceptProperty($property)) {
             $this->context->getClass()->addProperty($property);
             $property->setDefault($prop->default);
             $comment = $this->context->getDocBlockParser()->parse($node->getDocComment(), $this->context, $property);
             $property->setDocComment($node->getDocComment());
             $property->setShortDesc($comment->getShortDesc());
             $property->setLongDesc($comment->getLongDesc());
             if ($errors = $comment->getErrors()) {
                 $this->context->addErrors((string) $property, $prop->getLine(), $errors);
             } else {
                 if ($tag = $comment->getTag('var')) {
                     $property->setHint($this->resolveHint($tag[0][0]));
                     $property->setHintDesc($tag[0][1]);
                 }
                 $property->setTags($comment->getOtherTags());
             }
         }
     }
 }
 public function acceptProperty(PropertyReflection $property)
 {
     return $property->isPublic();
 }
Example #6
0
 public static function fromArray(Project $project, $array)
 {
     $class = new self($array['name'], $array['line']);
     $class->shortDesc = $array['short_desc'];
     $class->longDesc = $array['long_desc'];
     $class->hint = $array['hint'];
     $class->tags = $array['tags'];
     $class->namespace = $array['namespace'];
     $class->hash = $array['hash'];
     $class->file = $array['file'];
     $class->relativeFilePath = $array['relative_file'];
     $class->modifiers = $array['modifiers'];
     if ($array['is_interface']) {
         $class->setInterface(true);
     }
     if ($array['is_trait']) {
         $class->setTrait(true);
     }
     $class->aliases = $array['aliases'];
     $class->errors = $array['errors'];
     $class->parent = $array['parent'];
     $class->interfaces = $array['interfaces'];
     $class->constants = $array['constants'];
     $class->traits = $array['traits'];
     $class->setProject($project);
     foreach ($array['methods'] as $method) {
         $method = MethodReflection::fromArray($project, $method);
         $method->setClass($class);
         $class->addMethod($method);
     }
     foreach ($array['properties'] as $property) {
         $property = PropertyReflection::fromArray($project, $property);
         $property->setClass($class);
         $class->addProperty($property);
     }
     foreach ($array['constants'] as $constant) {
         $constant = ConstantReflection::fromArray($project, $constant);
         $constant->setClass($class);
         $class->addConstant($constant);
     }
     return $class;
 }
 public function testSetGetModifiers()
 {
     $property = new PropertyReflection('foo', 0);
     $property->setModifiers(0);
     $this->assertTrue($property->isPublic());
     $property->setModifiers(PropertyReflection::MODIFIER_PUBLIC);
     $this->assertTrue($property->isPublic());
     $property->setModifiers(PropertyReflection::MODIFIER_PROTECTED);
     $this->assertTrue($property->isProtected());
     $property->setModifiers(PropertyReflection::MODIFIER_PRIVATE);
     $this->assertTrue($property->isPrivate());
     $property->setModifiers(PropertyReflection::MODIFIER_STATIC);
     $this->assertTrue($property->isPublic());
     $this->assertTrue($property->isStatic());
 }
 public function addProperty(PropertyReflection $property)
 {
     $this->properties[$property->getName()] = $property;
     $property->setClass($this);
 }
Example #9
0
 public function acceptProperty(PropertyReflection $property)
 {
     return !$property->isPrivate();
 }