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\Objects;
 3: 
 4: use Pharborist\Functions\FunctionTrait;
 5: use Pharborist\Token;
 6: use Pharborist\TokenNode;
 7: 
 8: /**
 9:  * Trait used by any class method, including abstract methods.
10:  *
11:  * @see ClassMethodNode
12:  */
13: trait MethodTrait {
14:   use VisibilityTrait;
15:   use FunctionTrait;
16: 
17:   /**
18:    * @var TokenNode
19:    */
20:   protected $name;
21: 
22:   /**
23:    * @var TokenNode
24:    */
25:   protected $static;
26: 
27:   /**
28:    * @return TokenNode
29:    */
30:   public function getName() {
31:     return $this->name;
32:   }
33: 
34:   /**
35:    * @param string|TokenNode $name
36:    *
37:    * @return $this
38:    */
39:   public function setName($name) {
40:     if (is_string($name)) {
41:       $name = Token::identifier($name);
42:     }
43:     $this->name->replaceWith($name);
44:     return $this;
45:   }
46: 
47:   /**
48:    * @return TokenNode
49:    */
50:   public function getStatic() {
51:     return $this->static;
52:   }
53: 
54:   /**
55:    * @param boolean $is_static
56:    * @return $this
57:    */
58:   public function setStatic($is_static) {
59:     if ($is_static) {
60:       if (!isset($this->static)) {
61:         // Insert before T_FUNCTION.
62:         $function_token = $this->name->previous()->previous();
63:         $function_token->before([
64:           Token::_static(),
65:           Token::space(),
66:         ]);
67:       }
68:     }
69:     else {
70:       if (isset($this->static)) {
71:         // Remove whitespace after static keyword.
72:         $this->static->next()->remove();
73:         // Remove static keyword.
74:         $this->static->remove();
75:       }
76:     }
77:     return $this;
78:   }
79: }
80: 
Pharborist API documentation generated by ApiGen