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 c8fe0e4e40
commit 37f5090d90
@@ -23,12 +23,9 @@ class LongDescription implements \Reflector
{
/** @var string */
protected $contents = '';
/** @var \phpDocumentor\Reflection\DocBlock\Tags[] */
protected $tags = array();
/** @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;
@@ -38,16 +35,7 @@ class LongDescription implements \Reflector
*/
public function __construct($content)
{
$this->parsedContents = preg_split(
'/\{(\@.*)\}/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]
);
}
$this->contents = trim($content);
}
/**
@@ -68,6 +56,17 @@ class LongDescription implements \Reflector
*/
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;
}
@@ -102,16 +101,6 @@ class LongDescription implements \Reflector
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.
*