diff --git a/src/phpDocumentor/Reflection/DocBlock/Tag/MethodTag.php b/src/phpDocumentor/Reflection/DocBlock/Tag/MethodTag.php index 23f8dc1..fba1070 100644 --- a/src/phpDocumentor/Reflection/DocBlock/Tag/MethodTag.php +++ b/src/phpDocumentor/Reflection/DocBlock/Tag/MethodTag.php @@ -19,7 +19,7 @@ namespace phpDocumentor\Reflection\DocBlock\Tag; * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ -class MethodTag extends ParamTag +class MethodTag extends ReturnTag { /** @var string */ diff --git a/src/phpDocumentor/Reflection/DocBlock/Tag/ParamTag.php b/src/phpDocumentor/Reflection/DocBlock/Tag/ParamTag.php index ade3c05..8688766 100644 --- a/src/phpDocumentor/Reflection/DocBlock/Tag/ParamTag.php +++ b/src/phpDocumentor/Reflection/DocBlock/Tag/ParamTag.php @@ -12,8 +12,6 @@ namespace phpDocumentor\Reflection\DocBlock\Tag; -use phpDocumentor\Reflection\DocBlock\Tag; - /** * Reflection class for a @param tag in a Docblock. * @@ -21,11 +19,8 @@ use phpDocumentor\Reflection\DocBlock\Tag; * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ -class ParamTag extends Tag +class ParamTag extends ReturnTag { - /** @var string */ - protected $type = ''; - /** * @var string */ @@ -62,32 +57,6 @@ class ParamTag extends Tag $this->description = implode(' ', $content); } - /** - * Returns the unique types of the variable. - * - * @return string[] - */ - public function getTypes() - { - $types = new \phpDocumentor\Reflection\DocBlock\Type\Collection( - array($this->type), - $this->docblock ? $this->docblock->getNamespace() : null, - $this->docblock ? $this->docblock->getNamespaceAliases() : array() - ); - - return $types->getArrayCopy(); - } - - /** - * Returns the type section of the variable. - * - * @return string - */ - public function getType() - { - return implode('|', $this->getTypes()); - } - /** * Returns the variable's name. * diff --git a/src/phpDocumentor/Reflection/DocBlock/Tag/ReturnTag.php b/src/phpDocumentor/Reflection/DocBlock/Tag/ReturnTag.php index 60d4d74..2d83b63 100644 --- a/src/phpDocumentor/Reflection/DocBlock/Tag/ReturnTag.php +++ b/src/phpDocumentor/Reflection/DocBlock/Tag/ReturnTag.php @@ -12,6 +12,8 @@ namespace phpDocumentor\Reflection\DocBlock\Tag; +use phpDocumentor\Reflection\DocBlock\Tag; + /** * Reflection class for a @return tag in a Docblock. * @@ -19,10 +21,10 @@ namespace phpDocumentor\Reflection\DocBlock\Tag; * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ -class ReturnTag extends ParamTag +class ReturnTag extends Tag { /** @var string */ - protected $type = null; + protected $type = ''; /** * Parses a tag and populates the member variables. @@ -42,4 +44,30 @@ class ReturnTag extends ParamTag $this->description = implode(' ', $content); } + + /** + * Returns the unique types of the variable. + * + * @return string[] + */ + public function getTypes() + { + $types = new \phpDocumentor\Reflection\DocBlock\Type\Collection( + array($this->type), + $this->docblock ? $this->docblock->getNamespace() : null, + $this->docblock ? $this->docblock->getNamespaceAliases() : array() + ); + + return $types->getArrayCopy(); + } + + /** + * Returns the type section of the variable. + * + * @return string + */ + public function getType() + { + return implode('|', $this->getTypes()); + } } diff --git a/tests/phpDocumentor/Reflection/DocBlock/Tag/CoversTagTest.php b/tests/phpDocumentor/Reflection/DocBlock/Tag/CoversTagTest.php index dbbb350..06dac8e 100644 --- a/tests/phpDocumentor/Reflection/DocBlock/Tag/CoversTagTest.php +++ b/tests/phpDocumentor/Reflection/DocBlock/Tag/CoversTagTest.php @@ -32,7 +32,7 @@ class CoversTagTest extends \PHPUnit_Framework_TestCase * @param string $exContent * @param string $exReference * - * @covers \phpDocumentor\Reflection\DocBlock\Tag\CoversTag::__construct + * @covers \phpDocumentor\Reflection\DocBlock\Tag\CoversTag * @dataProvider provideDataForConstuctor * * @return void @@ -40,22 +40,16 @@ class CoversTagTest extends \PHPUnit_Framework_TestCase public function testConstructorParesInputsIntoCorrectFields( $type, $content, - $exName, $exContent, $exDescription, $exReference ) { $tag = new CoversTag($type, $content); - $actualName = $tag->getName(); - $actualContent = $tag->getContent(); - $actualDescription = $tag->getDescription(); - $actualReference = $tag->getReference(); - - $this->assertEquals($exName, $actualName); - $this->assertEquals($exContent, $actualContent); - $this->assertEquals($exDescription, $actualDescription); - $this->assertEquals($exReference, $actualReference); + $this->assertEquals($type, $tag->getName()); + $this->assertEquals($exContent, $tag->getContent()); + $this->assertEquals($exDescription, $tag->getDescription()); + $this->assertEquals($exReference, $tag->getReference()); } /** @@ -68,25 +62,22 @@ class CoversTagTest extends \PHPUnit_Framework_TestCase // $type, $content, $exName, $exContent, $exDescription, $exReference return array( array( - 'uses', + 'covers', 'Foo::bar()', - 'uses', 'Foo::bar()', '', 'Foo::bar()' ), array( - 'uses', + 'covers', 'Foo::bar() Testing', - 'uses', 'Foo::bar() Testing', 'Testing', 'Foo::bar()', ), array( - 'uses', + 'covers', 'Foo::bar() Testing comments', - 'uses', 'Foo::bar() Testing comments', 'Testing comments', 'Foo::bar()', diff --git a/tests/phpDocumentor/Reflection/DocBlock/Tag/LinkTagTest.php b/tests/phpDocumentor/Reflection/DocBlock/Tag/LinkTagTest.php index 0d9abbe..571c671 100644 --- a/tests/phpDocumentor/Reflection/DocBlock/Tag/LinkTagTest.php +++ b/tests/phpDocumentor/Reflection/DocBlock/Tag/LinkTagTest.php @@ -34,6 +34,7 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase * @param string $exLink * * @covers \phpDocumentor\Reflection\DocBlock\Tag\LinkTag::__construct + * @covers \phpDocumentor\Reflection\DocBlock\Tag\LinkTag::getLink * @dataProvider provideDataForConstuctor * * @return void @@ -41,22 +42,16 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase public function testConstructorParesInputsIntoCorrectFields( $type, $content, - $exName, $exContent, $exDescription, $exLink ) { $tag = new LinkTag($type, $content); - $actualName = $tag->getName(); - $actualContent = $tag->getContent(); - $actualDescription = $tag->getDescription(); - $actualLink = $tag->getLink(); - - $this->assertEquals($exName, $actualName); - $this->assertEquals($exContent, $actualContent); - $this->assertEquals($exDescription, $actualDescription); - $this->assertEquals($exLink, $actualLink); + $this->assertEquals($type, $tag->getName()); + $this->assertEquals($exContent, $tag->getContent()); + $this->assertEquals($exDescription, $tag->getDescription()); + $this->assertEquals($exLink, $tag->getLink()); } /** @@ -71,7 +66,6 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase array( 'link', 'http://www.phpdoc.org/', - 'link', 'http://www.phpdoc.org/', 'http://www.phpdoc.org/', 'http://www.phpdoc.org/' @@ -79,7 +73,6 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase array( 'link', 'http://www.phpdoc.org/ Testing', - 'link', 'http://www.phpdoc.org/ Testing', 'Testing', 'http://www.phpdoc.org/' @@ -87,7 +80,6 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase array( 'link', 'http://www.phpdoc.org/ Testing comments', - 'link', 'http://www.phpdoc.org/ Testing comments', 'Testing comments', 'http://www.phpdoc.org/' diff --git a/tests/phpDocumentor/Reflection/DocBlock/Tag/MethodTagTest.php b/tests/phpDocumentor/Reflection/DocBlock/Tag/MethodTagTest.php index 08d5957..4bef7dc 100644 --- a/tests/phpDocumentor/Reflection/DocBlock/Tag/MethodTagTest.php +++ b/tests/phpDocumentor/Reflection/DocBlock/Tag/MethodTagTest.php @@ -34,6 +34,9 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase * @param string $description The short description mentioned in the * signature. * + * @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag::__construct + * @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag::getMethodName + * * @dataProvider getTestSignatures * * @return void diff --git a/tests/phpDocumentor/Reflection/DocBlock/Tag/ParamTagTest.php b/tests/phpDocumentor/Reflection/DocBlock/Tag/ParamTagTest.php index 5fae81d..b3c2503 100644 --- a/tests/phpDocumentor/Reflection/DocBlock/Tag/ParamTagTest.php +++ b/tests/phpDocumentor/Reflection/DocBlock/Tag/ParamTagTest.php @@ -33,6 +33,7 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase * @param string $extractedDescription * * @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag::__construct + * @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag::getVariableName * * @dataProvider provideDataForConstructor * @@ -42,12 +43,15 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase $type, $content, $extractedType, + $extractedTypes, $extractedVarName, $extractedDescription ) { $tag = new ParamTag($type, $content); - $this->assertEquals($extractedType, $tag->getTypes()); + $this->assertEquals($type, $tag->getName()); + $this->assertEquals($extractedType, $tag->getType()); + $this->assertEquals($extractedTypes, $tag->getTypes()); $this->assertEquals($extractedVarName, $tag->getVariableName()); $this->assertEquals($extractedDescription, $tag->getDescription()); } @@ -60,15 +64,15 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase public function provideDataForConstructor() { return array( - array('param', 'int', array('int'), '', ''), - array('param', '$bob', array(), '$bob', ''), + array('param', 'int', 'int', array('int'), '', ''), + array('param', '$bob', '', array(), '$bob', ''), array( - 'param', 'int Number of bobs', array('int'), '', + 'param', 'int Number of bobs', 'int', array('int'), '', 'Number of bobs' ), - array('param', 'int $bob', array('int'), '$bob', ''), + array('param', 'int $bob', 'int', array('int'), '$bob', ''), array( - 'param', 'int $bob Number of bobs', array('int'), '$bob', + 'param', 'int $bob Number of bobs', 'int', array('int'), '$bob', 'Number of bobs' ), ); diff --git a/tests/phpDocumentor/Reflection/DocBlock/Tag/ReturnTagTest.php b/tests/phpDocumentor/Reflection/DocBlock/Tag/ReturnTagTest.php index bdef29a..7fc5855 100644 --- a/tests/phpDocumentor/Reflection/DocBlock/Tag/ReturnTagTest.php +++ b/tests/phpDocumentor/Reflection/DocBlock/Tag/ReturnTagTest.php @@ -31,19 +31,25 @@ class ReturnTagTest extends ParamTagTest * @param string $extractedDescription * * @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag::__construct + * @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag::getType + * @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag::getTypes * * @dataProvider provideDataForConstructor * * @return void */ public function testConstructorParsesInputsIntoCorrectFields( + $type, $content, $extractedType, + $extractedTypes, $extractedDescription ) { - $tag = new ReturnTag('return', $content); + $tag = new ReturnTag($type, $content); - $this->assertEquals($extractedType, $tag->getTypes()); + $this->assertEquals($type, $tag->getName()); + $this->assertEquals($extractedType, $tag->getType()); + $this->assertEquals($extractedTypes, $tag->getTypes()); $this->assertEquals($extractedDescription, $tag->getDescription()); } @@ -55,9 +61,15 @@ class ReturnTagTest extends ParamTagTest public function provideDataForConstructor() { return array( - array('', array(), ''), - array('int', array('int'), ''), - array('int Number of Bobs', array('int'), 'Number of Bobs'), + array('return', '', '', array(), ''), + array('return', 'int', 'int', array('int'), ''), + array( + 'return', + 'int Number of Bobs', + 'int', + array('int'), + 'Number of Bobs' + ), ); } } diff --git a/tests/phpDocumentor/Reflection/DocBlock/Tag/SeeTagTest.php b/tests/phpDocumentor/Reflection/DocBlock/Tag/SeeTagTest.php index a74cac5..f789a65 100644 --- a/tests/phpDocumentor/Reflection/DocBlock/Tag/SeeTagTest.php +++ b/tests/phpDocumentor/Reflection/DocBlock/Tag/SeeTagTest.php @@ -33,6 +33,7 @@ class SeeTagTest extends \PHPUnit_Framework_TestCase * @param string $exReference * * @covers \phpDocumentor\Reflection\DocBlock\Tag\SeeTag::__construct + * @covers \phpDocumentor\Reflection\DocBlock\Tag\SeeTag::getReference * @dataProvider provideDataForConstuctor * * @return void @@ -40,22 +41,16 @@ class SeeTagTest extends \PHPUnit_Framework_TestCase public function testConstructorParesInputsIntoCorrectFields( $type, $content, - $exName, $exContent, $exDescription, $exReference ) { $tag = new SeeTag($type, $content); - $actualName = $tag->getName(); - $actualContent = $tag->getContent(); - $actualDescription = $tag->getDescription(); - $actualReference = $tag->getReference(); - - $this->assertEquals($exName, $actualName); - $this->assertEquals($exContent, $actualContent); - $this->assertEquals($exDescription, $actualDescription); - $this->assertEquals($exReference, $actualReference); + $this->assertEquals($type, $tag->getName()); + $this->assertEquals($exContent, $tag->getContent()); + $this->assertEquals($exDescription, $tag->getDescription()); + $this->assertEquals($exReference, $tag->getReference()); } /** @@ -65,28 +60,25 @@ class SeeTagTest extends \PHPUnit_Framework_TestCase */ public function provideDataForConstuctor() { - // $type, $content, $exName, $exContent, $exDescription, $exReference + // $type, $content, $exContent, $exDescription, $exReference return array( array( - 'uses', + 'see', 'Foo::bar()', - 'uses', 'Foo::bar()', '', 'Foo::bar()' ), array( - 'uses', + 'see', 'Foo::bar() Testing', - 'uses', 'Foo::bar() Testing', 'Testing', 'Foo::bar()', ), array( - 'uses', + 'see', 'Foo::bar() Testing comments', - 'uses', 'Foo::bar() Testing comments', 'Testing comments', 'Foo::bar()', diff --git a/tests/phpDocumentor/Reflection/DocBlock/Tag/UsesTagTest.php b/tests/phpDocumentor/Reflection/DocBlock/Tag/UsesTagTest.php index 0e61cbd..c059818 100644 --- a/tests/phpDocumentor/Reflection/DocBlock/Tag/UsesTagTest.php +++ b/tests/phpDocumentor/Reflection/DocBlock/Tag/UsesTagTest.php @@ -40,22 +40,16 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase public function testConstructorParesInputsIntoCorrectFields( $type, $content, - $exName, $exContent, $exDescription, $exReference ) { $tag = new UsesTag($type, $content); - $actualName = $tag->getName(); - $actualContent = $tag->getContent(); - $actualDescription = $tag->getDescription(); - $actualReference = $tag->getReference(); - - $this->assertEquals($exName, $actualName); - $this->assertEquals($exContent, $actualContent); - $this->assertEquals($exDescription, $actualDescription); - $this->assertEquals($exReference, $actualReference); + $this->assertEquals($type, $tag->getName()); + $this->assertEquals($exContent, $tag->getContent()); + $this->assertEquals($exDescription, $tag->getDescription()); + $this->assertEquals($exReference, $tag->getReference()); } /** @@ -70,7 +64,6 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase array( 'uses', 'Foo::bar()', - 'uses', 'Foo::bar()', '', 'Foo::bar()' @@ -78,7 +71,6 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase array( 'uses', 'Foo::bar() Testing', - 'uses', 'Foo::bar() Testing', 'Testing', 'Foo::bar()', @@ -86,7 +78,6 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase array( 'uses', 'Foo::bar() Testing comments', - 'uses', 'Foo::bar() Testing comments', 'Testing comments', 'Foo::bar()', diff --git a/tests/phpDocumentor/Reflection/DocBlock/Tag/VarTagTest.php b/tests/phpDocumentor/Reflection/DocBlock/Tag/VarTagTest.php index 2c53b56..603ef96 100644 --- a/tests/phpDocumentor/Reflection/DocBlock/Tag/VarTagTest.php +++ b/tests/phpDocumentor/Reflection/DocBlock/Tag/VarTagTest.php @@ -46,6 +46,7 @@ class VarTagTest extends \PHPUnit_Framework_TestCase ) { $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()); @@ -81,6 +82,13 @@ class VarTagTest extends \PHPUnit_Framework_TestCase '$bob', 'Number of bobs' ), + array( + 'var', + '', + '', + '', + '' + ), ); } } diff --git a/tests/phpDocumentor/Reflection/DocBlockTest.php b/tests/phpDocumentor/Reflection/DocBlockTest.php index 1b7652b..3015a25 100644 --- a/tests/phpDocumentor/Reflection/DocBlockTest.php +++ b/tests/phpDocumentor/Reflection/DocBlockTest.php @@ -49,6 +49,9 @@ DOCBLOCK; $this->assertFalse($object->hasTag('category')); } + /** + * @covers \phpDocumentor\Reflection\DocBlock::__construct + */ public function testConstructFromReflector() { $object = new DocBlock(new \ReflectionClass($this)); @@ -70,7 +73,7 @@ DOCBLOCK; */ public function testExceptionOnInvalidObject() { - $object = new DocBlock($this); + new DocBlock($this); } public function testDotSeperation()