Merge branch 'patch-2' of https://github.com/boenrobot/ReflectionDocBlock into boenrobot-patch-2

Conflicts:
	src/phpDocumentor/Reflection/DocBlock/LongDescription.php
This commit is contained in:
Mike van Riel
2012-11-01 18:56:36 +01:00
2 changed files with 47 additions and 21 deletions
@@ -24,7 +24,10 @@ class LongDescription implements \Reflector
/** @var string */ /** @var string */
protected $contents = ''; protected $contents = '';
/** @var Tag[] */ /** @var array The contents, as an array of strings and Tag objects. */
protected $parsedContents = null;
/** @var \phpDocumentor\Reflection\DocBlock\Tags[] */
protected $tags = array(); protected $tags = array();
/** /**
@@ -35,13 +38,6 @@ class LongDescription implements \Reflector
*/ */
public function __construct($content) public function __construct($content)
{ {
if (preg_match('/\{\@(.+?)\}/u', $content, $matches)) {
array_shift($matches);
foreach ($matches as $tag) {
$this->tags[] = Tag::createInstance('@' . $tag);
}
}
$this->contents = trim($content); $this->contents = trim($content);
} }
@@ -55,6 +51,28 @@ class LongDescription implements \Reflector
return $this->contents; return $this->contents;
} }
/*
* Returns the parsed text of this description.
*
* @return array An array of strings and tag objects, in the order they
* occur within the description.
*/
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 a formatted variant of the Long Description using MarkDown. * Return a formatted variant of the Long Description using MarkDown.
* *
@@ -86,16 +104,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.
* *
+21 -3
View File
@@ -24,13 +24,16 @@ class Tag implements \Reflector
/** @var string Name of the tag */ /** @var string Name of the tag */
protected $tag = ''; protected $tag = '';
/** @var string content of the tag */ /** @var string Content of the tag */
protected $content = ''; protected $content = '';
/** @var string description of the content of this tag */ /** @var string Description of the content of this tag */
protected $description = ''; protected $description = '';
/** @var array The description, as an array of strings and Tag objects. */
protected $parsedDescription = null;
/** @var int line number of the tag */ /** @var int Line number of the tag */
protected $line_number = 0; protected $line_number = 0;
/** @var \phpDocumentor\Reflection\DocBlock docblock class */ /** @var \phpDocumentor\Reflection\DocBlock docblock class */
@@ -108,6 +111,21 @@ class Tag implements \Reflector
{ {
return $this->description; return $this->description;
} }
/*
* Returns the parsed text of this description.
*
* @return array An array of strings and tag objects, in the order they
* occur within the description.
*/
public function getParsedDescription()
{
if (null === $this->parsedDescription) {
$description = new LongDescription($this->description);
$this->parsedDescription = $description->getParsedContents();
}
return $this->parsedDescription;
}
/** /**
* Set the tag line number * Set the tag line number