Ejemplo n.º 1
0
 /**
  * @param \ReflectionProperty $property
  * @return Property
  */
 public static function createFromReflection(\ReflectionProperty $property)
 {
     $return = new Property();
     $return->setName($property->getName());
     $phpDoc = PhpDoc::parse($property->getDocComment());
     if (array_key_exists('comments', $phpDoc)) {
         $return->setComments($phpDoc['comments']);
     }
     if (array_key_exists('@var', $phpDoc)) {
         $return->setType($phpDoc['@var'][0]['type']);
     }
     return $return;
 }
Ejemplo n.º 2
0
 /**
  * @param Property $property
  * @return $this
  */
 public function addProperty(Property $property)
 {
     $this->properties[$property->getName()] = $property;
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * @param Property $property
  * @param int $tabs
  * @param int $endOfLines
  * @return string
  */
 public function getCodeForProperty(Property $property, $tabs = 1, $endOfLines = 1)
 {
     $return = null;
     $comments = array('comments' => $property->getComments());
     if ($property->getType() !== null) {
         $comments['@var'] = array('type' => $property->getType());
     }
     $return .= $this->getCodeForPhpDocComments($comments, $tabs);
     $declaration = $this->getCodeForVisibility($property->getVisibility());
     $declaration .= $this->getCodeForStatic($property->isStatic());
     $declaration .= substr($property->getName(), 0, 1) == '$' ? $property->getName() : '$' . $property->getName();
     if ($property->getDefaultValue() !== null) {
         $declaration .= ' = ' . $property->getDefaultValue();
     }
     $declaration .= ';';
     $return .= $this->getCodeForLine($declaration, $tabs, $endOfLines);
     return $return;
 }