/** * @param string $name * @param boolean */ public function __construct($name, $createNode = TRUE) { $this->name = $name; if ($createNode) { $this->node = Tx_PhpParser_Parser_NodeFactory::buildNamespaceNode($name); $this->initDocComment(); } }
/** * @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; } } }
/** * 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; }
/** * This methods is respsible for generating a statement array in the correct * order and to include all method and property nodes */ public function updateStmts() { $stmts = array(); $properties = array(); $methods = array(); foreach ($this->methods as $method) { $methods[$method->getName()] = $method->getNode(); } foreach ($this->properties as $property) { $properties[$property->getName()] = $property->getNode(); } //ksort($properties); //ksort($methods); foreach ($this->constants as $name => $value) { $stmts[] = Tx_PhpParser_Parser_NodeFactory::buildClassConstantNode($name, $value); } foreach ($properties as $property) { $stmts[] = $property; } foreach ($methods as $method) { $stmts[] = $method; } $this->node->setStmts($stmts); }
/** * Sets $typeHint. * * @param string $typeHint * @return */ public function setTypeHint($typeHint, $updateNodeTypeHint = TRUE) { if (!is_string($typeHint) && !empty($typeHint)) { $typeHint = Tx_PhpParser_Parser_Utility_NodeConverter::getValueFromNode($typeHint); } $this->typeHint = $typeHint; if ($updateNodeTypeHint) { $this->node->setType(Tx_PhpParser_Parser_NodeFactory::buildNodeFromName($typeHint)); } }