/**
* Parse a class to located and modify one of its properties.
*
* @param Stmt_Namespace $node contains a php namespace container
* @param string $name, name of the attribute
* @param Expr_Array $templateNode, key, value pairs from Template file
* @param bool $front, set location to the front of the array
*
* @return Stmt_Namespace
*/
public function parseClassProperty(&$node, $name, $templateNode, $front = fales)
{
$array = $this->node2Array($templateNode);
foreach ($node->stmts as $block) {
if ($block->getType() === 'Stmt_Class') {
$matchKey = null;
foreach ($block->stmts as $key => $property) {
if ($property->getType() === 'Stmt_Property' && $name === $property->props[0]->name) {
$matchKey = $key;
$array = $front ? array_merge($array, $this->node2Array($property->props[0]->default)) : array_merge($this->node2Array($property->props[0]->default), $array);
break;
}
}
// Append merged array,
$prop = new Property($name);
$prop->setDefault($array);
$prop->makeProtected();
if (!is_null($matchKey)) {
$block->stmts[$matchKey] = $prop->getNode();
} else {
$block->stmts[] = $prop->getNode();
}
}
}
return $node;
}