1 | <?php |
||
20 | class MethodDeclaration extends NamedDeclaration implements ReplaceableInterface |
||
21 | { |
||
22 | use CommentTrait, AccessTrait; |
||
23 | |||
24 | /** |
||
25 | * @var bool |
||
26 | */ |
||
27 | private $static = false; |
||
28 | |||
29 | /** |
||
30 | * @var ParameterAggregator |
||
31 | */ |
||
32 | private $parameters = null; |
||
33 | |||
34 | /** |
||
35 | * @var Source |
||
36 | */ |
||
37 | private $source = null; |
||
38 | |||
39 | /** |
||
40 | * @param string $name |
||
41 | * @param string|array $source |
||
42 | * @param string $comment |
||
43 | */ |
||
44 | public function __construct(string $name, $source = '', string $comment = '') |
||
45 | { |
||
46 | parent::__construct($name); |
||
47 | |||
48 | $this->parameters = new ParameterAggregator([]); |
||
49 | |||
50 | $this->initSource($source); |
||
51 | $this->initComment($comment); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param bool $static |
||
56 | * |
||
57 | * @return self |
||
58 | */ |
||
59 | public function setStatic(bool $static = true): MethodDeclaration |
||
65 | |||
66 | /** |
||
67 | * @return bool |
||
68 | */ |
||
69 | public function isStatic(): bool |
||
73 | |||
74 | /** |
||
75 | * Rename to getSource()? |
||
76 | * |
||
77 | * @return Source |
||
78 | */ |
||
79 | public function getSource(): Source |
||
83 | |||
84 | /** |
||
85 | * Set method source. |
||
86 | * |
||
87 | * @param string|array $source |
||
88 | * |
||
89 | * @return self |
||
90 | */ |
||
91 | public function setSource($source): MethodDeclaration |
||
103 | |||
104 | /** |
||
105 | * @return ParameterAggregator|ParameterDeclaration[] |
||
106 | */ |
||
107 | public function getParameters(): ParameterAggregator |
||
111 | |||
112 | /** |
||
113 | * @param string $name |
||
114 | * |
||
115 | * @return ParameterDeclaration |
||
116 | */ |
||
117 | public function parameter(string $name): ParameterDeclaration |
||
121 | |||
122 | /** |
||
123 | * {@inheritdoc} |
||
124 | * |
||
125 | * @return $this |
||
126 | */ |
||
127 | public function replace($search, $replace): MethodDeclaration |
||
133 | |||
134 | /** |
||
135 | * @param int $indentLevel |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | public function render(int $indentLevel = 0): string |
||
164 | |||
165 | /** |
||
166 | * Init source value. |
||
167 | * |
||
168 | * @param string|array $source |
||
169 | */ |
||
170 | private function initSource($source) |
||
184 | } |