forked from phpDocumentor/ReflectionDocBlock
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support parsing SuppressWarnings tags in doc block
Signed-off-by: Andrew Smith <[email protected]>
- Loading branch information
Showing
2 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/Barryvdh/Reflection/DocBlock/Tag/SyppressWarningsTag.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?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; | ||
|
||
/** | ||
* 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 ParamTag | ||
{ | ||
public function __toString() | ||
{ | ||
return "@{$this->getName()}{$this->getContent()}"; | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
tests/Barryvdh/Reflection/DocBlock/Tag/SuppressWarningsTagTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?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, | ||
$exType, | ||
$exVariable, | ||
$exDescription | ||
) { | ||
$tag = new VarTag($type, $content); | ||
|
||
$this->assertEquals($type, $tag->getName()); | ||
$this->assertEquals($exType, $tag->getType()); | ||
$this->assertEquals($exVariable, $tag->getVariableName()); | ||
$this->assertEquals($exDescription, $tag->getDescription()); | ||
} | ||
|
||
/** | ||
* Data provider for testConstructorParesInputsIntoCorrectFields | ||
* | ||
* @return array | ||
*/ | ||
public function provideDataForConstuctor() | ||
{ | ||
// $type, $content, $exType, $exVariable, $exDescription | ||
return array( | ||
array( | ||
'SuppressWarnings', | ||
'SuppressWarnings(PHPMD)', | ||
'SuppressWarnings' | ||
'(PHPMD)', | ||
'SuppressWarnings(PHPMD)', | ||
), | ||
array( | ||
'SuppressWarnings', | ||
'SuppressWarnings(PHPMD.TooManyMethods)', | ||
'SuppressWarnings', | ||
'(PHPMD.TooManyMethods)', | ||
'SuppressWarnings(PHPMD.TooManyMethods)', | ||
), | ||
); | ||
} | ||
} |