class MethodTag in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Tag/MethodTag.php \phpDocumentor\Reflection\DocBlock\Tag\MethodTag
Reflection class for a @method in a Docblock.
@author Mike van Riel <mike.vanriel@naenius.com> @license http://www.opensource.org/licenses/mit-license.php MIT @link http://phpdoc.org
Hierarchy
- class \phpDocumentor\Reflection\DocBlock\Tag implements \phpDocumentor\Reflection\DocBlock\Reflector
Expanded class hierarchy of MethodTag
File
- vendor/
phpdocumentor/ reflection-docblock/ src/ phpDocumentor/ Reflection/ DocBlock/ Tag/ MethodTag.php, line 24
Namespace
phpDocumentor\Reflection\DocBlock\TagView source
class MethodTag extends ReturnTag {
/** @var string */
protected $method_name = '';
/** @var string */
protected $arguments = '';
/** @var bool */
protected $isStatic = false;
/**
* {@inheritdoc}
*/
public function getContent() {
if (null === $this->content) {
$this->content = '';
if ($this->isStatic) {
$this->content .= 'static ';
}
$this->content .= $this->type . " {$this->method_name}({$this->arguments}) " . $this->description;
}
return $this->content;
}
/**
* {@inheritdoc}
*/
public function setContent($content) {
Tag::setContent($content);
// 1. none or more whitespace
// 2. optionally the keyword "static" followed by whitespace
// 3. optionally a word with underscores followed by whitespace : as
// type for the return value
// 4. then optionally a word with underscores followed by () and
// whitespace : as method name as used by phpDocumentor
// 5. then a word with underscores, followed by ( and any character
// until a ) and whitespace : as method name with signature
// 6. any remaining text : as description
if (preg_match('/^
# Static keyword
# Declates a static method ONLY if type is also present
(?:
(static)
\\s+
)?
# Return type
(?:
([\\w\\|_\\\\]+)
\\s+
)?
# Legacy method name (not captured)
(?:
[\\w_]+\\(\\)\\s+
)?
# Method name
([\\w\\|_\\\\]+)
# Arguments
\\(([^\\)]*)\\)
\\s*
# Description
(.*)
$/sux', $this->description, $matches)) {
list(, $static, $this->type, $this->method_name, $this->arguments, $this->description) = $matches;
if ($static) {
if (!$this->type) {
$this->type = 'static';
}
else {
$this->isStatic = true;
}
}
else {
if (!$this->type) {
$this->type = 'void';
}
}
$this->parsedDescription = null;
}
return $this;
}
/**
* Sets the name of this method.
*
* @param string $method_name The name of the method.
*
* @return $this
*/
public function setMethodName($method_name) {
$this->method_name = $method_name;
$this->content = null;
return $this;
}
/**
* Retrieves the method name.
*
* @return string
*/
public function getMethodName() {
return $this->method_name;
}
/**
* Sets the arguments for this method.
*
* @param string $arguments A comma-separated arguments line.
*
* @return void
*/
public function setArguments($arguments) {
$this->arguments = $arguments;
$this->content = null;
return $this;
}
/**
* Returns an array containing each argument as array of type and name.
*
* Please note that the argument sub-array may only contain 1 element if no
* type was specified.
*
* @return string[]
*/
public function getArguments() {
if (empty($this->arguments)) {
return array();
}
$arguments = explode(',', $this->arguments);
foreach ($arguments as $key => $value) {
$arguments[$key] = explode(' ', trim($value));
}
return $arguments;
}
/**
* Checks whether the method tag describes a static method or not.
*
* @return bool TRUE if the method declaration is for a static method, FALSE
* otherwise.
*/
public function isStatic() {
return $this->isStatic;
}
/**
* Sets a new value for whether the method is static or not.
*
* @param bool $isStatic The new value to set.
*
* @return $this
*/
public function setIsStatic($isStatic) {
$this->isStatic = $isStatic;
$this->content = null;
return $this;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MethodTag:: |
protected | property | @var string | |
MethodTag:: |
protected | property | @var bool | |
MethodTag:: |
protected | property | @var string | |
MethodTag:: |
public | function | Returns an array containing each argument as array of type and name. | |
MethodTag:: |
public | function |
Gets the content of this tag. Overrides ReturnTag:: |
|
MethodTag:: |
public | function | Retrieves the method name. | |
MethodTag:: |
public | function | Checks whether the method tag describes a static method or not. | |
MethodTag:: |
public | function | Sets the arguments for this method. | |
MethodTag:: |
public | function |
Sets the content of this tag. Overrides ReturnTag:: |
|
MethodTag:: |
public | function | Sets a new value for whether the method is static or not. | |
MethodTag:: |
public | function | Sets the name of this method. | |
ReturnTag:: |
protected | property | @var string The raw type component. | |
ReturnTag:: |
protected | property | @var Collection The parsed type component. | |
ReturnTag:: |
public | function | Returns the type section of the variable. | |
ReturnTag:: |
public | function | Returns the unique types of the variable. | |
ReturnTag:: |
protected | function | Returns the type collection. | |
Tag:: |
protected | property | When set to NULL, it means it needs to be regenerated. | |
Tag:: |
protected | property | @var string Description of the content of this tag | |
Tag:: |
protected | property | @var DocBlock The DocBlock which this tag belongs to. | |
Tag:: |
protected | property | @var Location Location of the tag. | |
Tag:: |
protected | property | When set to NULL, it means it needs to be regenerated. | |
Tag:: |
protected | property | @var string Name of the tag | |
Tag:: |
private static | property | handles it as an array value. The class is expected to inherit this class. | |
Tag:: |
final public static | function | Factory method responsible for instantiating the correct sub type. | |
Tag:: |
public static | function | Builds a string representation of this object. | |
Tag:: |
public | function | Gets the description component of this tag. | |
Tag:: |
public | function | Gets the docblock this tag belongs to. | |
Tag:: |
public | function | Gets the location of the tag. | |
Tag:: |
public | function | Gets the name of this tag. | |
Tag:: |
public | function | Gets the parsed text of this description. | |
Tag:: |
constant | PCRE regular expression matching a tag name. | ||
Tag:: |
final public static | function | Registers a handler for tags. | |
Tag:: |
public | function | Sets the description component of this tag. | |
Tag:: |
public | function | Sets the docblock this tag belongs to. | |
Tag:: |
public | function | Sets the location of the tag. | |
Tag:: |
public | function | Sets the name of this tag. | |
Tag:: |
public | function | Parses a tag and populates the member variables. | |
Tag:: |
public | function | Returns the tag as a serialized string |