Removed LongDescription::getTags() and made parsing to occur only the first time it's requested.

This commit is contained in:
Vasil Rangelov
2012-10-17 17:33:52 +03:00
parent a2bf8995dc
commit f001c3cd92
@@ -24,11 +24,8 @@ class LongDescription implements \Reflector
/** @var string */ /** @var string */
protected $contents = ''; protected $contents = '';
/** @var \phpDocumentor\Reflection\DocBlock\Tags[] */
protected $tags = array();
/** @var array The contents, as an array of strings and Tag objects. */ /** @var array The contents, as an array of strings and Tag objects. */
protected $parsedContents = array(); protected $parsedContents = null;
/** /**
* Parses the string for inline tags and if the Markdown class is included; * Parses the string for inline tags and if the Markdown class is included;
@@ -38,16 +35,7 @@ class LongDescription implements \Reflector
*/ */
public function __construct($content) public function __construct($content)
{ {
$this->parsedContents = preg_split( $this->contents = trim($content);
'/\{(\@.*)\}/uS',
$this->contents = trim($content),
null, PREG_SPLIT_DELIM_CAPTURE
);
for ($i=1, $l = count($this->parsedContents); $i<$l; $i += 2) {
$this->parsedContents[$i] = $this->tags[] = Tag::createInstance(
$this->parsedContents[$i]
);
}
} }
/** /**
@@ -68,6 +56,17 @@ class LongDescription implements \Reflector
*/ */
public function getParsedContents() public function getParsedContents()
{ {
if (null === $this->parsedContents) {
$this->parsedContents = preg_split(
'/\{(\@.*)\}/uS', $this->contents,
null, PREG_SPLIT_DELIM_CAPTURE
);
for ($i=1, $l = count($this->parsedContents); $i<$l; $i += 2) {
$this->parsedContents[$i] = Tag::createInstance(
$this->parsedContents[$i]
);
}
}
return $this->parsedContents; return $this->parsedContents;
} }
@@ -102,16 +101,6 @@ class LongDescription implements \Reflector
return trim($result); return trim($result);
} }
/**
* Returns a list of tags mentioned in the text.
*
* @return \phpDocumentor\Reflection\DocBlock\Tags[]
*/
public function getTags()
{
return $this->tags;
}
/** /**
* Builds a string representation of this object. * Builds a string representation of this object.
* *