/** * Remove the visibility modifier. */ protected function removeVisibility() { // Remove whitespace after visibility keyword. $this->visibility->next()->remove(); // Remove visibility keyword. $this->visibility->remove(); }
/** * @param boolean $is_reference * @return $this */ public function setReference($is_reference) { if ($is_reference) { if (!isset($this->reference)) { /** @var \Pharborist\Functions\FunctionDeclarationNode|\Pharborist\Objects\ClassMethodNode|\Pharborist\Objects\InterfaceMethodNode $this */ $this->reference = Token::reference(); $this->name->before($this->reference); } } else { if (isset($this->reference)) { $this->reference->remove(); } } return $this; }
public function clearLexicalVariables() { if ($this->hasLexicalVariables()) { $this->lexicalUse->nextUntil(Filter::is($this->body))->remove(); $this->lexicalUse->remove(); } }
/** * @param boolean $is_static * * @return $this */ public function setStatic($is_static) { if ($is_static) { if (!isset($this->static)) { $this->static = Token::_static(); $this->visibility->after([Token::space(), $this->static]); } } else { if (isset($this->static)) { // Remove whitespace after static keyword. $this->static->next()->remove(); // Remove static keyword. $this->static->remove(); } } return $this; }
/** * Name bounded inside namespace. * * @return string */ public function getBoundedName() { if ($this->alias) { return $this->alias->getText(); } else { return $this->name->lastChild()->getText(); } }
/** * @param boolean $is_static * @return $this */ public function setStatic($is_static) { if ($is_static) { if (!isset($this->static)) { // Insert before T_FUNCTION. $function_token = $this->name->previous()->previous(); $this->static = Token::_static(); $function_token->before([$this->static, Token::space()]); } } else { if (isset($this->static)) { // Remove whitespace after static keyword. $this->static->next()->remove(); // Remove static keyword. $this->static->remove(); } } return $this; }
/** * @param boolean $is_final * @return $this */ public function setFinal($is_final) { if ($is_final) { if (!isset($this->final)) { $this->final = Token::_final(); $this->prepend([$this->final, Token::space()]); $this->setAbstract(FALSE); } } else { if (isset($this->final)) { // Remove whitespace. $this->final->next()->remove(); // Remove final. $this->final->remove(); } } return $this; }
/** * Get the type of the parameter as defined by type hinting or doc comment. * * @return string[] * The types as defined by phpdoc standard. Default is ['mixed']. */ public function getTypes() { // If type hint is set then that is the type of the parameter. if ($this->typeHint) { if ($this->typeHint instanceof TokenNode) { if ($this->typeHint->getType() === T_ARRAY) { $docTypes = $this->getDocTypes(); foreach ($docTypes as $docType) { if ($docType !== 'array' && substr($docType, -2) !== '[]') { return [$this->typeHint->getText()]; } } return $docTypes; } else { return [$this->typeHint->getText()]; } } else { return [$this->typeHint->getAbsolutePath()]; } } return $this->getDocTypes(); }
public function visitTokenNode(TokenNode $node) { switch ($node->getType()) { case T_DOUBLE_ARROW: $this->spaceBefore($node); $this->spaceAfter($node); break; } }
/** * Move iterator to next non hidden token. * @param bool $capture_doc_comment */ private function nextToken($capture_doc_comment = FALSE) { $this->iterator->next(); $capture_doc_comment ? $this->skipHiddenCaptureDocComment() : $this->skipHidden(); $this->current = $this->iterator->current(); if ($this->current) { $this->currentType = $this->current->getType(); } else { $this->currentType = NULL; } }