7 * @author Mike van Riel <mike.vanriel@naenius.com>
8 * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
9 * @license http://www.opensource.org/licenses/mit-license.php MIT
10 * @link http://phpdoc.org
13 namespace phpDocumentor\Reflection\DocBlock\Tag;
15 use phpDocumentor\Reflection\DocBlock\Tag;
18 * Reflection class for a @method in a Docblock.
20 * @author Mike van Riel <mike.vanriel@naenius.com>
21 * @license http://www.opensource.org/licenses/mit-license.php MIT
22 * @link http://phpdoc.org
24 class MethodTag extends ReturnTag
28 protected $method_name = '';
31 protected $arguments = '';
34 protected $isStatic = false;
39 public function getContent()
41 if (null === $this->content) {
43 if ($this->isStatic) {
44 $this->content .= 'static ';
46 $this->content .= $this->type .
47 " {$this->method_name}({$this->arguments}) " .
51 return $this->content;
57 public function setContent($content)
59 Tag::setContent($content);
60 // 1. none or more whitespace
61 // 2. optionally the keyword "static" followed by whitespace
62 // 3. optionally a word with underscores followed by whitespace : as
63 // type for the return value
64 // 4. then optionally a word with underscores followed by () and
65 // whitespace : as method name as used by phpDocumentor
66 // 5. then a word with underscores, followed by ( and any character
67 // until a ) and whitespace : as method name with signature
68 // 6. any remaining text : as description
72 # Declates a static method ONLY if type is also present
82 # Legacy method name (not captured)
107 $this->type = 'static';
109 $this->isStatic = true;
113 $this->type = 'void';
116 $this->parsedDescription = null;
123 * Sets the name of this method.
125 * @param string $method_name The name of the method.
129 public function setMethodName($method_name)
131 $this->method_name = $method_name;
133 $this->content = null;
138 * Retrieves the method name.
142 public function getMethodName()
144 return $this->method_name;
148 * Sets the arguments for this method.
150 * @param string $arguments A comma-separated arguments line.
154 public function setArguments($arguments)
156 $this->arguments = $arguments;
158 $this->content = null;
163 * Returns an array containing each argument as array of type and name.
165 * Please note that the argument sub-array may only contain 1 element if no
166 * type was specified.
170 public function getArguments()
172 if (empty($this->arguments)) {
176 $arguments = explode(',', $this->arguments);
177 foreach ($arguments as $key => $value) {
178 $arguments[$key] = explode(' ', trim($value));
185 * Checks whether the method tag describes a static method or not.
187 * @return bool TRUE if the method declaration is for a static method, FALSE
190 public function isStatic()
192 return $this->isStatic;
196 * Sets a new value for whether the method is static or not.
198 * @param bool $isStatic The new value to set.
202 public function setIsStatic($isStatic)
204 $this->isStatic = $isStatic;
206 $this->content = null;