Skip to content

Commit

Permalink
Merge pull request #13 from EspadaV8/suppress-warnings-tag-handler
Browse files Browse the repository at this point in the history
Support parsing SuppressWarnings tags in doc block
  • Loading branch information
barryvdh authored Nov 25, 2022
2 parents bf44b75 + 9a2f0eb commit e5e1727
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Barryvdh/Reflection/DocBlock/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ class Tag implements \Reflector
'var'
=> '\Barryvdh\Reflection\DocBlock\Tag\VarTag',
'version'
=> '\Barryvdh\Reflection\DocBlock\Tag\VersionTag'
=> '\Barryvdh\Reflection\DocBlock\Tag\VersionTag',
'SuppressWarnings'
=> '\Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag'
);

/**
Expand Down
30 changes: 30 additions & 0 deletions src/Barryvdh/Reflection/DocBlock/Tag/SuppressWarningsTag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* phpDocumentor
*
* PHP Version 5.3
*
* @author Andrew Smith <[email protected]>
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/

namespace Barryvdh\Reflection\DocBlock\Tag;

use Barryvdh\Reflection\DocBlock\Tag;

/**
* Reflection class for a @SuppressWarnings tag in a Docblock.
*
* @author Andrew Smith <[email protected]>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class SuppressWarningsTag extends Tag
{
public function __toString()
{
return "@{$this->getName()}{$this->getContent()}";
}
}
75 changes: 75 additions & 0 deletions tests/Barryvdh/Reflection/DocBlock/Tag/SuppressWarningsTagTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
/**
* phpDocumentor SuppressWarnings Tag Test
*
* PHP version 5.3
*
* @author Andrew Smith <[email protected]>
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/

namespace Barryvdh\Reflection\DocBlock\Tag;

use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestCase;

/**
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag
*
* @author Andrew Smith <[email protected]>
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class SuppressWarningsTagTest extends TestCase
{
/**
* Test that the \Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag can
* understand the @SuppressWarnings doc block.
*
* @param string $type
* @param string $content
* @param string $exType
* @param string $exVariable
* @param string $exDescription
*
* @covers \Barryvdh\Reflection\DocBlock\Tag\SuppressWarningsTag
* @dataProvider provideDataForConstuctor
*
* @return void
*/
public function testConstructorParesInputsIntoCorrectFields(
$type,
$content,
$description
) {
$tag = new SuppressWarningsTag($type, $content);

$this->assertEquals($type, $tag->getName());
$this->assertEquals($description, $tag->getDescription());
}

/**
* Data provider for testConstructorParesInputsIntoCorrectFields
*
* @return array
*/
public function provideDataForConstuctor()
{
// $type, $content, $description
return array(
array(
'SuppressWarnings',
'SuppressWarnings(PHPMD)',
'SuppressWarnings(PHPMD)',
),
array(
'SuppressWarnings',
'SuppressWarnings(PHPMD.TooManyMethods)',
'SuppressWarnings(PHPMD.TooManyMethods)',
),
);
}
}

0 comments on commit e5e1727

Please sign in to comment.