Overview

Namespaces

  • Pharborist
    • Constants
    • ControlStructures
    • Exceptions
    • Functions
    • Generators
    • Namespaces
    • Objects
    • Operators
    • Types
    • Variables

Classes

  • Pharborist\Variables\CompoundVariableNode
  • Pharborist\Variables\GlobalStatementNode
  • Pharborist\Variables\ReferenceVariableNode
  • Pharborist\Variables\StaticVariableNode
  • Pharborist\Variables\StaticVariableStatementNode
  • Pharborist\Variables\VariableNode
  • Pharborist\Variables\VariableVariableNode

Interfaces

  • Pharborist\Variables\VariableExpressionNode
  • Overview
  • Namespace
  • Class
 1: <?php
 2: namespace Pharborist;
 3: 
 4: trait DocCommentTrait {
 5:   /**
 6:    * @var DocCommentNode
 7:    */
 8:   protected $docComment;
 9: 
10:   /**
11:    * Get the indent proceeding this node.
12:    *
13:    * @return string
14:    */
15:   public function getIndent() {
16:     /** @var ParentNode $this */
17:     $whitespace_token = $this->previousToken();
18:     if ($whitespace_token->getType() !== T_WHITESPACE) {
19:       return '';
20:     }
21:     $nl = FormatterFactory::getDefaultFormatter()->getConfig('nl');
22:     $lines = explode($nl, $whitespace_token->getText());
23:     $last_line = end($lines);
24:     return $last_line;
25:   }
26: 
27:   /**
28:    * @return DocCommentNode
29:    */
30:   public function getDocComment() {
31:     return $this->docComment;
32:   }
33: 
34:   /**
35:    * @param DocCommentNode $comment
36:    * @return $this
37:    */
38:   public function setDocComment(DocCommentNode $comment) {
39:     if (isset($this->docComment)) {
40:       $this->docComment->replaceWith($comment);
41:     }
42:     else {
43:       $indent = $this->getIndent();
44:       $comment->setIndent($indent);
45:       $nl = FormatterFactory::getDefaultFormatter()->getConfig('nl');
46:       /** @var ParentNode $this */
47:       $this->firstChild()->before([
48:         $comment,
49:         WhitespaceNode::create($nl . $indent),
50:       ]);
51:     }
52:     return $this;
53:   }
54: }
55: 
Pharborist API documentation generated by ApiGen