Esempio n. 1
0
 public function buildNamespaceObjectFromNode(PHPParser_Node_Stmt_Namespace $node)
 {
     $nameSpaceObject = new Tx_PhpParser_Domain_Model_Namespace(Tx_PhpParser_Parser_Utility_NodeConverter::getValueFromNode($node->getName()));
     $nameSpaceObject->setNode($node);
     $nameSpaceObject->initDocComment();
     return $nameSpaceObject;
 }
 /**
  * @param \PHPParser_Node $node
  * @return PHPParser_Node|void
  */
 public function leaveNode(PHPParser_Node $node)
 {
     if (NULL !== $node->__get('class')) {
         $oldClassName = Tx_PhpParser_Parser_Utility_NodeConverter::getValueFromNode($node->__get('class'));
         if (strpos($oldClassName, $this->oldClassPrefix) !== FALSE) {
             $newClassName = str_replace($this->oldClassPrefix, $this->newClassPrefix, $oldClassName);
             $node->setClass(Tx_PhpParser_Parser_NodeFactory::buildNodeFromName($newClassName));
             return $node;
         }
     }
 }
Esempio n. 3
0
 /**
  * Setter for value
  *
  * @param mixed
  * @return
  */
 public function setValue($value, $updateNode = TRUE, $updateVarType = TRUE)
 {
     $this->value = $value;
     if ($updateNode) {
         $props = $this->node->getProps();
         $valueNode = Tx_PhpParser_Parser_NodeFactory::buildNodeFromValue($value);
         $props[0]->setDefault($valueNode);
         $this->node->setProps($props);
     }
     if ($updateVarType) {
         $varType = Tx_PhpParser_Parser_Utility_NodeConverter::getVarTypeFromValue($value);
         if (!empty($varType)) {
             $this->setVarType($varType);
         }
     }
     return $this;
 }
Esempio n. 4
0
 /**
  * getModifierNames
  *
  * @return
  */
 public function getModifierNames()
 {
     $modifiers = $this->getModifiers();
     return Tx_PhpParser_Parser_Utility_NodeConverter::modifierToNames($modifiers);
 }
Esempio n. 5
0
 /**
  * @param string $varType
  */
 public function setVarType($varType, $updateNodeType = TRUE)
 {
     if ($updateNodeType) {
         $this->setTypeHint(Tx_PhpParser_Parser_Utility_NodeConverter::getTypeHintFromVarType($varType), TRUE);
     }
     $this->varType = $varType;
 }
Esempio n. 6
0
 /**
  * @param PHPParser_Node $node
  */
 public function leaveNode(PHPParser_Node $node)
 {
     array_pop($this->contextStack);
     if ($this->isContainerNode(end($this->contextStack)) || count($this->contextStack) === 0) {
         // we are on the first level
         if ($node instanceof PHPParser_Node_Stmt_Class) {
             if (count($this->contextStack) > 0) {
                 if (end($this->contextStack)->getNodeType() == 'Stmt_Namespace') {
                     $currentNamespaceName = Tx_PhpParser_Parser_Utility_NodeConverter::getValueFromNode(end($this->contextStack));
                     $this->currentClassObject->setNamespaceName($currentNamespaceName);
                     $this->currentNamespace->addClass($this->currentClassObject);
                 }
             } else {
                 $this->fileObject->addClass($this->currentClassObject);
                 $this->currentClassObject = NULL;
                 $this->currentContainer = $this->fileObject;
             }
         } elseif ($node instanceof PHPParser_Node_Stmt_Namespace) {
             $this->fileObject->addNamespace($this->currentNamespace);
             $this->currentNamespace = NULL;
             $this->currentContainer = $this->fileObject;
         } elseif ($node instanceof PHPParser_Node_Stmt_Use) {
             $this->currentContainer->addAliasDeclaration($node);
         } elseif ($node instanceof PHPParser_Node_Stmt_ClassConst) {
             $constants = Tx_PhpParser_Parser_Utility_NodeConverter::convertClassConstantNodeToArray($node);
             foreach ($constants as $constant) {
                 $this->currentContainer->setConstant($constant['name'], $constant['value']);
             }
         } elseif ($node instanceof PHPParser_Node_Stmt_ClassMethod) {
             $this->onFirstLevel = TRUE;
             $method = $this->classFactory->buildClassMethodObjectFromNode($node);
             $this->currentClassObject->addMethod($method);
         } elseif ($node instanceof PHPParser_Node_Stmt_Property) {
             $property = $this->classFactory->buildPropertyObjectFromNode($node);
             $this->currentClassObject->addProperty($property);
         } elseif ($node instanceof PHPParser_Node_Stmt_Function) {
             $this->onFirstLevel = TRUE;
             $function = $this->classFactory->buildFunctionObjectFromNode($node);
             $this->currentContainer->addFunction($function);
         } elseif (!$node instanceof PHPParser_Node_Name) {
             // any other nodes (except the name node of the current container node)
             // go into statements container
             if ($this->currentContainer->getFirstClass() === FALSE) {
                 $this->currentContainer->addPreClassStatements($node);
             } else {
                 $this->currentContainer->addPostClassStatements($node);
             }
         }
     }
 }