Skip to content

Commit 9a2f0eb

Browse files
committed
Support parsing SuppressWarnings tags in doc block
Signed-off-by: Andrew Smith <[email protected]>
1 parent bf44b75 commit 9a2f0eb

File tree

3 files changed

+108
-1
lines changed

3 files changed

+108
-1
lines changed

src/Barryvdh/Reflection/DocBlock/Tag.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ class Tag implements \Reflector
9595
'var'
9696
=> '\Barryvdh\Reflection\DocBlock\Tag\VarTag',
9797
'version'
98-
=> '\Barryvdh\Reflection\DocBlock\Tag\VersionTag'
98+
=> '\Barryvdh\Reflection\DocBlock\Tag\VersionTag',
99+
'SuppressWarnings'
100+
=> '\Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag'
99101
);
100102

101103
/**
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* phpDocumentor
4+
*
5+
* PHP Version 5.3
6+
*
7+
* @author Andrew Smith <[email protected]>
8+
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
9+
* @license http://www.opensource.org/licenses/mit-license.php MIT
10+
* @link http://phpdoc.org
11+
*/
12+
13+
namespace Barryvdh\Reflection\DocBlock\Tag;
14+
15+
use Barryvdh\Reflection\DocBlock\Tag;
16+
17+
/**
18+
* Reflection class for a @SuppressWarnings tag in a Docblock.
19+
*
20+
* @author Andrew Smith <[email protected]>
21+
* @license http://www.opensource.org/licenses/mit-license.php MIT
22+
* @link http://phpdoc.org
23+
*/
24+
class SuppressWarningsTag extends Tag
25+
{
26+
public function __toString()
27+
{
28+
return "@{$this->getName()}{$this->getContent()}";
29+
}
30+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
/**
3+
* phpDocumentor SuppressWarnings Tag Test
4+
*
5+
* PHP version 5.3
6+
*
7+
* @author Andrew Smith <[email protected]>
8+
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
9+
* @license http://www.opensource.org/licenses/mit-license.php MIT
10+
* @link http://phpdoc.org
11+
*/
12+
13+
namespace Barryvdh\Reflection\DocBlock\Tag;
14+
15+
use PHPUnit\Framework\Test;
16+
use PHPUnit\Framework\TestCase;
17+
18+
/**
19+
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag
20+
*
21+
* @author Andrew Smith <[email protected]>
22+
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
23+
* @license http://www.opensource.org/licenses/mit-license.php MIT
24+
* @link http://phpdoc.org
25+
*/
26+
class SuppressWarningsTagTest extends TestCase
27+
{
28+
/**
29+
* Test that the \Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag can
30+
* understand the @SuppressWarnings doc block.
31+
*
32+
* @param string $type
33+
* @param string $content
34+
* @param string $exType
35+
* @param string $exVariable
36+
* @param string $exDescription
37+
*
38+
* @covers \Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag
39+
* @dataProvider provideDataForConstuctor
40+
*
41+
* @return void
42+
*/
43+
public function testConstructorParesInputsIntoCorrectFields(
44+
$type,
45+
$content,
46+
$description
47+
) {
48+
$tag = new SuppressWarningsTag($type, $content);
49+
50+
$this->assertEquals($type, $tag->getName());
51+
$this->assertEquals($description, $tag->getDescription());
52+
}
53+
54+
/**
55+
* Data provider for testConstructorParesInputsIntoCorrectFields
56+
*
57+
* @return array
58+
*/
59+
public function provideDataForConstuctor()
60+
{
61+
// $type, $content, $description
62+
return array(
63+
array(
64+
'SuppressWarnings',
65+
'SuppressWarnings(PHPMD)',
66+
'SuppressWarnings(PHPMD)',
67+
),
68+
array(
69+
'SuppressWarnings',
70+
'SuppressWarnings(PHPMD.TooManyMethods)',
71+
'SuppressWarnings(PHPMD.TooManyMethods)',
72+
),
73+
);
74+
}
75+
}

0 commit comments

Comments
 (0)