mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Made all tag handlers call Tag::__construct() rather than "manually" duplicating it;
Tag::__construct() trims the description (as is common for most tag handlers), while the original contents is still in the $content property; Added the DocBlock argument to all tag handlers.
This commit is contained in:
@@ -159,7 +159,7 @@ class Tag implements \Reflector
|
|||||||
{
|
{
|
||||||
$this->tag = $type;
|
$this->tag = $type;
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
$this->description = $content;
|
$this->description = trim($content);
|
||||||
$this->docblock = $docblock;
|
$this->docblock = $docblock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,12 +34,17 @@ class AuthorTag extends Tag
|
|||||||
* Parses a tag and populates the member variables.
|
* Parses a tag and populates the member variables.
|
||||||
*
|
*
|
||||||
* @param string $type Tag identifier for this tag (should be 'author').
|
* @param string $type Tag identifier for this tag (should be 'author').
|
||||||
* @param string $content The contents of the given tag.
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct($type, $content, DocBlock $docblock = null)
|
||||||
{
|
{
|
||||||
parent::__construct($type, $content);
|
parent::__construct($type, $content, $docblock);
|
||||||
if (preg_match('/^([^\<]*)(\<([^\>]*)\>)?$/', $content, $matches)) {
|
if (preg_match(
|
||||||
|
'/^([^\<]*)(\<([^\>]*)\>)?$/',
|
||||||
|
$this->description,
|
||||||
|
$matches
|
||||||
|
)) {
|
||||||
$this->name = trim($matches[1]);
|
$this->name = trim($matches[1]);
|
||||||
if (isset($matches[3])) {
|
if (isset($matches[3])) {
|
||||||
$this->email = trim($matches[3]);
|
$this->email = trim($matches[3]);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,12 +31,13 @@ class LinkTag extends Tag
|
|||||||
* Parses a tag and populates the member variables.
|
* Parses a tag and populates the member variables.
|
||||||
*
|
*
|
||||||
* @param string $type Tag identifier for this tag (should be 'link').
|
* @param string $type Tag identifier for this tag (should be 'link').
|
||||||
* @param string $content The contents of the given tag.
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct($type, $content, DocBlock $docblock = null)
|
||||||
{
|
{
|
||||||
$this->tag = $type;
|
parent::__construct($type, $content, $docblock);
|
||||||
$pieces = explode(' ', $content);
|
$pieces = explode(' ', $this->description);
|
||||||
|
|
||||||
if (count($pieces) > 1) {
|
if (count($pieces) > 1) {
|
||||||
$this->link = array_shift($pieces);
|
$this->link = array_shift($pieces);
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a @method in a Docblock.
|
* Reflection class for a @method in a Docblock.
|
||||||
*
|
*
|
||||||
@@ -32,12 +35,12 @@ class MethodTag extends ReturnTag
|
|||||||
* Parses a tag and populates the member variables.
|
* Parses a tag and populates the member variables.
|
||||||
*
|
*
|
||||||
* @param string $type Tag identifier for this tag (should be 'method').
|
* @param string $type Tag identifier for this tag (should be 'method').
|
||||||
* @param string $content The contents of the given tag.
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct($type, $content, DocBlock $docblock = null)
|
||||||
{
|
{
|
||||||
$this->tag = $type;
|
Tag::__construct($type, $content, $docblock);
|
||||||
$this->content = $content;
|
|
||||||
|
|
||||||
$matches = array();
|
$matches = array();
|
||||||
// 1. none or more whitespace
|
// 1. none or more whitespace
|
||||||
@@ -51,7 +54,7 @@ class MethodTag extends ReturnTag
|
|||||||
if (preg_match(
|
if (preg_match(
|
||||||
'/^[\s]*(?:([\w\|_\\\\]+)[\s]+)?(?:[\w_]+\(\)[\s]+)?([\w\|_\\\\]+)'
|
'/^[\s]*(?:([\w\|_\\\\]+)[\s]+)?(?:[\w_]+\(\)[\s]+)?([\w\|_\\\\]+)'
|
||||||
.'\(([^\)]*)\)[\s]*(.*)/u',
|
.'\(([^\)]*)\)[\s]*(.*)/u',
|
||||||
$content,
|
$this->description,
|
||||||
$matches
|
$matches
|
||||||
)) {
|
)) {
|
||||||
list(
|
list(
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a @param tag in a Docblock.
|
* Reflection class for a @param tag in a Docblock.
|
||||||
*
|
*
|
||||||
@@ -31,14 +34,14 @@ class ParamTag extends ReturnTag
|
|||||||
*
|
*
|
||||||
* @param string $type Tag identifier for this tag (should be 'param').
|
* @param string $type Tag identifier for this tag (should be 'param').
|
||||||
* @param string $content Contents for this tag.
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct($type, $content, DocBlock $docblock = null)
|
||||||
{
|
{
|
||||||
$this->tag = $type;
|
Tag::__construct($type, $content, $docblock);
|
||||||
$this->content = $content;
|
|
||||||
$content = preg_split(
|
$content = preg_split(
|
||||||
'/(\s+)/u',
|
'/(\s+)/u',
|
||||||
trim($content),
|
$this->description,
|
||||||
3,
|
3,
|
||||||
PREG_SPLIT_DELIM_CAPTURE
|
PREG_SPLIT_DELIM_CAPTURE
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,13 +32,12 @@ class ReturnTag extends Tag
|
|||||||
*
|
*
|
||||||
* @param string $type Tag identifier for this tag (should be 'return').
|
* @param string $type Tag identifier for this tag (should be 'return').
|
||||||
* @param string $content Contents for this tag.
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct($type, $content, DocBlock $docblock = null)
|
||||||
{
|
{
|
||||||
$this->tag = $type;
|
parent::__construct($type, $content, $docblock);
|
||||||
$this->content = $content;
|
$content = preg_split('/[\ \t]+/u', $this->description, 2);
|
||||||
|
|
||||||
$content = preg_split('/[\ \t]+/u', trim($content), 2);
|
|
||||||
|
|
||||||
// any output is considered a type
|
// any output is considered a type
|
||||||
$this->type = array_shift($content);
|
$this->type = array_shift($content);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,11 +32,11 @@ class SeeTag extends Tag
|
|||||||
*
|
*
|
||||||
* @param string $type Tag identifier for this tag (should be 'see').
|
* @param string $type Tag identifier for this tag (should be 'see').
|
||||||
* @param string $content Contents for this tag.
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct($type, $content, DocBlock $docblock = null)
|
||||||
{
|
{
|
||||||
$this->tag = $type;
|
parent::__construct($type, $content, $docblock);
|
||||||
$this->content = $content;
|
|
||||||
$content = preg_split('/\s+/u', $content);
|
$content = preg_split('/\s+/u', $content);
|
||||||
|
|
||||||
// any output is considered a type
|
// any output is considered a type
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a @var tag in a Docblock.
|
* Reflection class for a @var tag in a Docblock.
|
||||||
*
|
*
|
||||||
@@ -26,12 +29,12 @@ class VarTag extends ParamTag
|
|||||||
*
|
*
|
||||||
* @param string $type Tag identifier for this tag (should be 'var').
|
* @param string $type Tag identifier for this tag (should be 'var').
|
||||||
* @param string $content Contents for this tag.
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct($type, $content, DocBlock $docblock = null)
|
||||||
{
|
{
|
||||||
$this->tag = $type;
|
Tag::__construct($type, $content, $docblock);
|
||||||
$this->content = $content;
|
$content = preg_split('/\s+/u', $this->description);
|
||||||
$content = preg_split('/\s+/u', $content);
|
|
||||||
|
|
||||||
if (count($content) == 0) {
|
if (count($content) == 0) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user