Skip to content

Commit 1ac9106

Browse files
committed
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.
1 parent 1352ef5 commit 1ac9106

File tree

8 files changed

+59
-41
lines changed

8 files changed

+59
-41
lines changed

src/phpDocumentor/Reflection/DocBlock/Tag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function __construct($type, $content, DocBlock $docblock = null)
159159
{
160160
$this->tag = $type;
161161
$this->content = $content;
162-
$this->description = $content;
162+
$this->description = trim($content);
163163
$this->docblock = $docblock;
164164
}
165165

src/phpDocumentor/Reflection/DocBlock/Tag/AuthorTag.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace phpDocumentor\Reflection\DocBlock\Tag;
1414

15+
use phpDocumentor\Reflection\DocBlock;
1516
use phpDocumentor\Reflection\DocBlock\Tag;
1617

1718
/**
@@ -32,13 +33,18 @@ class AuthorTag extends Tag
3233
/**
3334
* Parses a tag and populates the member variables.
3435
*
35-
* @param string $type Tag identifier for this tag (should be 'author').
36-
* @param string $content The contents of the given tag.
36+
* @param string $type Tag identifier for this tag (should be 'author').
37+
* @param string $content Contents for this tag.
38+
* @param DocBlock $docblock The DocBlock which this tag belongs to.
3739
*/
38-
public function __construct($type, $content)
40+
public function __construct($type, $content, DocBlock $docblock = null)
3941
{
40-
parent::__construct($type, $content);
41-
if (preg_match('/^([^\<]*)(\<([^\>]*)\>)?$/', $content, $matches)) {
42+
parent::__construct($type, $content, $docblock);
43+
if (preg_match(
44+
'/^([^\<]*)(\<([^\>]*)\>)?$/',
45+
$this->description,
46+
$matches
47+
)) {
4248
$this->name = trim($matches[1]);
4349
if (isset($matches[3])) {
4450
$this->email = trim($matches[3]);

src/phpDocumentor/Reflection/DocBlock/Tag/LinkTag.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace phpDocumentor\Reflection\DocBlock\Tag;
1414

15+
use phpDocumentor\Reflection\DocBlock;
1516
use phpDocumentor\Reflection\DocBlock\Tag;
1617

1718
/**
@@ -29,13 +30,14 @@ class LinkTag extends Tag
2930
/**
3031
* Parses a tag and populates the member variables.
3132
*
32-
* @param string $type Tag identifier for this tag (should be 'link').
33-
* @param string $content The contents of the given tag.
33+
* @param string $type Tag identifier for this tag (should be 'link').
34+
* @param string $content Contents for this tag.
35+
* @param DocBlock $docblock The DocBlock which this tag belongs to.
3436
*/
35-
public function __construct($type, $content)
37+
public function __construct($type, $content, DocBlock $docblock = null)
3638
{
37-
$this->tag = $type;
38-
$pieces = explode(' ', $content);
39+
parent::__construct($type, $content, $docblock);
40+
$pieces = explode(' ', $this->description);
3941

4042
if (count($pieces) > 1) {
4143
$this->link = array_shift($pieces);

src/phpDocumentor/Reflection/DocBlock/Tag/MethodTag.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
namespace phpDocumentor\Reflection\DocBlock\Tag;
1414

15+
use phpDocumentor\Reflection\DocBlock;
16+
use phpDocumentor\Reflection\DocBlock\Tag;
17+
1518
/**
1619
* Reflection class for a @method in a Docblock.
1720
*
@@ -31,13 +34,13 @@ class MethodTag extends ReturnTag
3134
/**
3235
* Parses a tag and populates the member variables.
3336
*
34-
* @param string $type Tag identifier for this tag (should be 'method').
35-
* @param string $content The contents of the given tag.
37+
* @param string $type Tag identifier for this tag (should be 'method').
38+
* @param string $content Contents for this tag.
39+
* @param DocBlock $docblock The DocBlock which this tag belongs to.
3640
*/
37-
public function __construct($type, $content)
41+
public function __construct($type, $content, DocBlock $docblock = null)
3842
{
39-
$this->tag = $type;
40-
$this->content = $content;
43+
Tag::__construct($type, $content, $docblock);
4144

4245
$matches = array();
4346
// 1. none or more whitespace
@@ -51,7 +54,7 @@ public function __construct($type, $content)
5154
if (preg_match(
5255
'/^[\s]*(?:([\w\|_\\\\]+)[\s]+)?(?:[\w_]+\(\)[\s]+)?([\w\|_\\\\]+)'
5356
.'\(([^\)]*)\)[\s]*(.*)/u',
54-
$content,
57+
$this->description,
5558
$matches
5659
)) {
5760
list(

src/phpDocumentor/Reflection/DocBlock/Tag/ParamTag.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
namespace phpDocumentor\Reflection\DocBlock\Tag;
1414

15+
use phpDocumentor\Reflection\DocBlock;
16+
use phpDocumentor\Reflection\DocBlock\Tag;
17+
1518
/**
1619
* Reflection class for a @param tag in a Docblock.
1720
*
@@ -29,16 +32,16 @@ class ParamTag extends ReturnTag
2932
/**
3033
* Parses a tag and populates the member variables.
3134
*
32-
* @param string $type Tag identifier for this tag (should be 'param').
33-
* @param string $content Contents for this tag.
35+
* @param string $type Tag identifier for this tag (should be 'param').
36+
* @param string $content Contents for this tag.
37+
* @param DocBlock $docblock The DocBlock which this tag belongs to.
3438
*/
35-
public function __construct($type, $content)
39+
public function __construct($type, $content, DocBlock $docblock = null)
3640
{
37-
$this->tag = $type;
38-
$this->content = $content;
41+
Tag::__construct($type, $content, $docblock);
3942
$content = preg_split(
4043
'/(\s+)/u',
41-
trim($content),
44+
$this->description,
4245
3,
4346
PREG_SPLIT_DELIM_CAPTURE
4447
);

src/phpDocumentor/Reflection/DocBlock/Tag/ReturnTag.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace phpDocumentor\Reflection\DocBlock\Tag;
1414

15+
use phpDocumentor\Reflection\DocBlock;
1516
use phpDocumentor\Reflection\DocBlock\Tag;
1617

1718
/**
@@ -29,15 +30,14 @@ class ReturnTag extends Tag
2930
/**
3031
* Parses a tag and populates the member variables.
3132
*
32-
* @param string $type Tag identifier for this tag (should be 'return').
33-
* @param string $content Contents for this tag.
33+
* @param string $type Tag identifier for this tag (should be 'return').
34+
* @param string $content Contents for this tag.
35+
* @param DocBlock $docblock The DocBlock which this tag belongs to.
3436
*/
35-
public function __construct($type, $content)
37+
public function __construct($type, $content, DocBlock $docblock = null)
3638
{
37-
$this->tag = $type;
38-
$this->content = $content;
39-
40-
$content = preg_split('/[\ \t]+/u', trim($content), 2);
39+
parent::__construct($type, $content, $docblock);
40+
$content = preg_split('/[\ \t]+/u', $this->description, 2);
4141

4242
// any output is considered a type
4343
$this->type = array_shift($content);

src/phpDocumentor/Reflection/DocBlock/Tag/SeeTag.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace phpDocumentor\Reflection\DocBlock\Tag;
1414

15+
use phpDocumentor\Reflection\DocBlock;
1516
use phpDocumentor\Reflection\DocBlock\Tag;
1617

1718
/**
@@ -29,13 +30,13 @@ class SeeTag extends Tag
2930
/**
3031
* Parses a tag and populates the member variables.
3132
*
32-
* @param string $type Tag identifier for this tag (should be 'see').
33-
* @param string $content Contents for this tag.
33+
* @param string $type Tag identifier for this tag (should be 'see').
34+
* @param string $content Contents for this tag.
35+
* @param DocBlock $docblock The DocBlock which this tag belongs to.
3436
*/
35-
public function __construct($type, $content)
37+
public function __construct($type, $content, DocBlock $docblock = null)
3638
{
37-
$this->tag = $type;
38-
$this->content = $content;
39+
parent::__construct($type, $content, $docblock);
3940
$content = preg_split('/\s+/u', $content);
4041

4142
// any output is considered a type

src/phpDocumentor/Reflection/DocBlock/Tag/VarTag.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
namespace phpDocumentor\Reflection\DocBlock\Tag;
1414

15+
use phpDocumentor\Reflection\DocBlock;
16+
use phpDocumentor\Reflection\DocBlock\Tag;
17+
1518
/**
1619
* Reflection class for a @var tag in a Docblock.
1720
*
@@ -24,14 +27,14 @@ class VarTag extends ParamTag
2427
/**
2528
* Parses a tag and populates the member variables.
2629
*
27-
* @param string $type Tag identifier for this tag (should be 'var').
28-
* @param string $content Contents for this tag.
30+
* @param string $type Tag identifier for this tag (should be 'var').
31+
* @param string $content Contents for this tag.
32+
* @param DocBlock $docblock The DocBlock which this tag belongs to.
2933
*/
30-
public function __construct($type, $content)
34+
public function __construct($type, $content, DocBlock $docblock = null)
3135
{
32-
$this->tag = $type;
33-
$this->content = $content;
34-
$content = preg_split('/\s+/u', $content);
36+
Tag::__construct($type, $content, $docblock);
37+
$content = preg_split('/\s+/u', $this->description);
3538

3639
if (count($content) == 0) {
3740
return;

0 commit comments

Comments
 (0)