/** * Add property to class. * * @param string|ClassMemberListNode $property * @return $this */ public function appendProperty($property) { if (is_string($property)) { $property = ClassMemberListNode::create($property); } $properties = $this->statements->children(Filter::isInstanceOf('\\Pharborist\\ClassMemberListNode')); if ($properties->count() === 0) { $this->statements->firstChild()->after($property); } else { $properties->last()->after($property); } FormatterFactory::format($this); return $this; }
public function visitStatementBlockNode(StatementBlockNode $node) { $nested = FALSE; $first = $node->firstChild(); if ($first instanceof TokenNode && $first->getType() === '{') { if ($node->parent() instanceof StatementBlockNode) { $this->indentLevel++; $nested = TRUE; } $brace_newline = $this->config['declaration_brace_newline']; if ($brace_newline && $this->isDeclaration($node->parent())) { $this->newlineBefore($node, TRUE); } else { $this->spaceBefore($node); } $this->newlineAfter($first); } $this->nodeData[$node] = $nested; foreach ($node->getStatements() as $statement) { $this->newlineBefore($statement); } }