/** * @param boolean $is_abstract * @return $this */ public function setAbstract($is_abstract) { if ($is_abstract) { if (!isset($this->abstract)) { $this->abstract = Token::_abstract(); $this->prepend([$this->abstract, Token::space()]); $this->setFinal(FALSE); // Remove method body since abstract method doesn't have one. $this->getBody()->previous(Filter::isInstanceOf('\\Pharborist\\WhitespaceNode'))->remove(); $this->getBody()->replaceWith(Token::semiColon()); $this->body = NULL; } } else { if (isset($this->abstract)) { // Remove whitespace. $this->abstract->next()->remove(); // Remove abstract. $this->abstract->remove(); // Add empty body. $body = new StatementBlockNode(); $body->append([Token::openBrace(), Token::closeBrace()]); $this->lastChild()->replaceWith($body); $this->lastChild()->before(Token::space()); $this->body = $body; } } return $this; }
/** * @param boolean $is_abstract * @return $this */ public function setAbstract($is_abstract) { if ($is_abstract) { if (!isset($this->abstract)) { $this->abstract = Token::_abstract(); $this->prepend([$this->abstract, Token::space()]); $this->setFinal(FALSE); } } else { if (isset($this->abstract)) { // Remove whitespace. $this->abstract->next()->remove(); // Remove abstract. $this->abstract->remove(); } } return $this; }