Skip to content

Commit 37f5090

Browse files
committed
Removed LongDescription::getTags() and made parsing to occur only the first time it's requested.
1 parent c8fe0e4 commit 37f5090

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

src/phpDocumentor/Reflection/DocBlock/LongDescription.php

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ class LongDescription implements \Reflector
2323
{
2424
/** @var string */
2525
protected $contents = '';
26-
27-
/** @var \phpDocumentor\Reflection\DocBlock\Tags[] */
28-
protected $tags = array();
2926

3027
/** @var array The contents, as an array of strings and Tag objects. */
31-
protected $parsedContents = array();
28+
protected $parsedContents = null;
3229

3330
/**
3431
* Parses the string for inline tags and if the Markdown class is included;
@@ -38,16 +35,7 @@ class LongDescription implements \Reflector
3835
*/
3936
public function __construct($content)
4037
{
41-
$this->parsedContents = preg_split(
42-
'/\{(\@.*)\}/uS',
43-
$this->contents = trim($content),
44-
null, PREG_SPLIT_DELIM_CAPTURE
45-
);
46-
for ($i=1, $l = count($this->parsedContents); $i<$l; $i += 2) {
47-
$this->parsedContents[$i] = $this->tags[] = Tag::createInstance(
48-
$this->parsedContents[$i]
49-
);
50-
}
38+
$this->contents = trim($content);
5139
}
5240

5341
/**
@@ -68,6 +56,17 @@ public function getContents()
6856
*/
6957
public function getParsedContents()
7058
{
59+
if (null === $this->parsedContents) {
60+
$this->parsedContents = preg_split(
61+
'/\{(\@.*)\}/uS', $this->contents,
62+
null, PREG_SPLIT_DELIM_CAPTURE
63+
);
64+
for ($i=1, $l = count($this->parsedContents); $i<$l; $i += 2) {
65+
$this->parsedContents[$i] = Tag::createInstance(
66+
$this->parsedContents[$i]
67+
);
68+
}
69+
}
7170
return $this->parsedContents;
7271
}
7372

@@ -102,16 +101,6 @@ public function getFormattedContents()
102101
return trim($result);
103102
}
104103

105-
/**
106-
* Returns a list of tags mentioned in the text.
107-
*
108-
* @return \phpDocumentor\Reflection\DocBlock\Tags[]
109-
*/
110-
public function getTags()
111-
{
112-
return $this->tags;
113-
}
114-
115104
/**
116105
* Builds a string representation of this object.
117106
*

0 commit comments

Comments
 (0)