Exemple #1
0
 /**
  * @param \PhpParser\Node\Stmt\Property $propertyNode
  * @return \EBT\ExtensionBuilder\Domain\Model\ClassObject\Property
  */
 public function buildPropertyObject(\PhpParser\Node\Stmt\Property $propertyNode)
 {
     $propertyName = '';
     $propertyDefault = null;
     foreach ($propertyNode->props as $subNode) {
         if ($subNode instanceof \PhpParser\Node\Stmt\PropertyProperty) {
             $propertyName = $subNode->name;
             if ($subNode->default) {
                 $propertyDefault = $subNode->default;
             }
         }
     }
     $propertyObject = new Model\ClassObject\Property($propertyName);
     $propertyObject->setModifiers($propertyNode->type);
     if (null !== $propertyDefault) {
         $propertyObject->setValue(NodeConverter::getValueFromNode($propertyDefault), false, $propertyObject->isTaggedWith('var'));
         $propertyObject->setDefaultValueNode($propertyDefault);
     }
     $this->addCommentsFromAttributes($propertyObject, $propertyNode);
     return $propertyObject;
 }
 /**
  * @param \EBT\ExtensionBuilder\Domain\Model\ClassObject\Property $classProperty
  * @return void
  */
 public function setProperty($classProperty)
 {
     $this->properties[$classProperty->getName()] = $classProperty;
 }
Exemple #3
0
 /**
  * @param \EBT\ExtensionBuilder\Domain\Model\ClassObject\Property $property
  * @return \PhpParser\Node\Stmt\Property
  */
 public function buildPropertyNode(\EBT\ExtensionBuilder\Domain\Model\ClassObject\Property $property)
 {
     $factory = new \PhpParser\BuilderFactory();
     $propertyNodeBuilder = $factory->property($property->getName());
     $propertyNode = $propertyNodeBuilder->getNode();
     $propertyNode->type = $property->getModifiers();
     foreach ($propertyNode->props as $subNode) {
         if ($subNode instanceof \PhpParser\Node\Stmt\PropertyProperty) {
             if (!is_null($property->getDefaultValueNode())) {
                 $subNode->default = $property->getDefaultValueNode();
             } else {
                 $subNode->default = $this->buildNodeFromValue($property->getDefault());
             }
         }
     }
     $this->addCommentAttributes($property, $propertyNode);
     $propertyNode->default = $property->getDefault();
     return $propertyNode;
 }
 /**
  * @param \EBT\ExtensionBuilder\Domain\Model\ClassObject\Property $classProperty
  * @return bool TRUE if successfull added
  */
 public function addProperty(Property $classProperty)
 {
     if (!$this->propertyExists($classProperty->getName())) {
         $this->propertyNames[] = $classProperty->getName();
         $this->properties[$classProperty->getName()] = $classProperty;
         $result = TRUE;
     } else {
         $result = FALSE;
     }
     return $result;
 }