mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-17 17:47:13 +00:00
add more unit tests and normalize the "__toString" methods
This commit is contained in:
@@ -71,7 +71,15 @@ final class Author extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->authorName . ($this->authorEmail !== '' ? ' <' . $this->authorEmail . '>' : '');
|
||||
if ($this->authorEmail) {
|
||||
$authorEmail = '<' . $this->authorEmail . '>';
|
||||
} else {
|
||||
$authorEmail = '';
|
||||
}
|
||||
|
||||
$authorName = (string) $this->authorName;
|
||||
|
||||
return $authorName . ($authorEmail !== '' ? ($authorName !== '' ? ' ' : '') . $authorEmail : '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,6 +72,14 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->refers . ($this->description ? ' ' . $this->description->render() : '');
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$refers = (string) $this->refers;
|
||||
|
||||
return $refers . ($description !== '' ? ($refers !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +95,14 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return ($this->version ?? '') . ($this->description ? ' ' . $this->description->render() : '');
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$version = (string) $this->version;
|
||||
|
||||
return $version . ($description !== '' ? ($version !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,10 @@ final class Example implements Tag, Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->filePath . ($this->content ? ' ' . $this->content : '');
|
||||
$filePath = (string) $this->filePath;
|
||||
$content = (string) $this->content;
|
||||
|
||||
return $filePath . ($content !== '' ? ($filePath !== '' ? ' ' : '') . $content : '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,7 +64,13 @@ final class Generic extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->description ? $this->description->render() : '';
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
return $description;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,6 +65,14 @@ final class Link extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->link . ($this->description ? ' ' . $this->description->render() : '');
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$link = (string) $this->link;
|
||||
|
||||
return $link . ($description !== '' ? ($link !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,12 +212,25 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
foreach ($this->arguments as $argument) {
|
||||
$arguments[] = $argument['type'] . ' $' . $argument['name'];
|
||||
}
|
||||
$argumentStr = '(' . implode(', ', $arguments) . ')';
|
||||
|
||||
return trim(($this->isStatic() ? 'static ' : '')
|
||||
. (string) $this->returnType . ' '
|
||||
. $this->methodName
|
||||
. '(' . implode(', ', $arguments) . ')'
|
||||
. ($this->description ? ' ' . $this->description->render() : ''));
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$static = $this->isStatic ? 'static' : '';
|
||||
|
||||
$returnType = (string) $this->returnType;
|
||||
|
||||
$methodName = (string) $this->methodName;
|
||||
|
||||
return $static
|
||||
. ($returnType !== '' ? ($static !== '' ? ' ' : '') . $returnType : '')
|
||||
. ($methodName !== '' ? ($static !== '' || $returnType !== '' ? ' ' : '') . $methodName : '')
|
||||
. $argumentStr
|
||||
. ($description !== '' ? ' ' . $description : '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,11 +140,23 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return ($this->type ? $this->type . ($this->variableName ? ' ' : '') : '')
|
||||
. ($this->isReference() ? '&' : '')
|
||||
. ($this->isVariadic() ? '...' : '')
|
||||
. ($this->variableName ? '$' . $this->variableName : '')
|
||||
. (('' . $this->description) ? ' ' . $this->description : '');
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$variableName = '';
|
||||
if ($this->variableName) {
|
||||
$variableName .= ($this->isReference ? '&' : '') . ($this->isVariadic ? '...' : '');
|
||||
$variableName .= ($this->variableName ? '$' . $this->variableName : '');
|
||||
}
|
||||
|
||||
$type = (string) $this->type;
|
||||
|
||||
return $type
|
||||
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
|
||||
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
|
||||
private static function strStartsWithVariable(string $str) : bool
|
||||
|
||||
@@ -98,8 +98,22 @@ final class Property extends TagWithType implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return ($this->type ? $this->type . ($this->variableName ? ' ' : '') : '')
|
||||
. ($this->variableName ? '$' . $this->variableName : '')
|
||||
. (('' . $this->description) ? ' ' . $this->description : '');
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
if ($this->variableName) {
|
||||
$variableName = ($this->variableName ? '$' . $this->variableName : '');
|
||||
} else {
|
||||
$variableName = '';
|
||||
}
|
||||
|
||||
$type = (string) $this->type;
|
||||
|
||||
return $type
|
||||
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
|
||||
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,8 +98,22 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return ($this->type ? $this->type . ($this->variableName ? ' ' : '') : '')
|
||||
. ($this->variableName ? '$' . $this->variableName : '')
|
||||
. (('' . $this->description) ? ' ' . $this->description : '');
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
if ($this->variableName) {
|
||||
$variableName = ($this->variableName ? '$' . $this->variableName : '');
|
||||
} else {
|
||||
$variableName = '';
|
||||
}
|
||||
|
||||
$type = (string) $this->type;
|
||||
|
||||
return $type
|
||||
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
|
||||
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,8 +98,22 @@ final class PropertyWrite extends TagWithType implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return ($this->type ? $this->type . ($this->variableName ? ' ' : '') : '')
|
||||
. ($this->variableName ? '$' . $this->variableName : '')
|
||||
. (('' . $this->description) ? ' ' . $this->description : '');
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
if ($this->variableName) {
|
||||
$variableName = ($this->variableName ? '$' . $this->variableName : '');
|
||||
} else {
|
||||
$variableName = '';
|
||||
}
|
||||
|
||||
$type = (string) $this->type;
|
||||
|
||||
return $type
|
||||
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
|
||||
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,14 @@ final class Return_ extends TagWithType implements Factory\StaticMethod
|
||||
|
||||
public function __toString() : string
|
||||
{
|
||||
return ($this->type ?: 'mixed') . ' ' . (string) $this->description;
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$type = $this->type ? '' . $this->type : 'mixed';
|
||||
|
||||
return $type . ($description !== '' ? ($type !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,14 @@ final class See extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->refers . ($this->description ? ' ' . $this->description->render() : '');
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$refers = (string) $this->refers;
|
||||
|
||||
return $refers . ($description !== '' ? ($refers !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,14 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return (string) $this->version . ($this->description ? ' ' . (string) $this->description : '');
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$version = (string) $this->version;
|
||||
|
||||
return $version . ($description !== '' ? ($version !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,8 +96,18 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->startingLine
|
||||
. ($this->lineCount !== null ? ' ' . $this->lineCount : '')
|
||||
. ($this->description ? ' ' . (string) $this->description : '');
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$startingLine = (string) $this->startingLine;
|
||||
|
||||
$lineCount = $this->lineCount !== null ? '' . $this->lineCount : '';
|
||||
|
||||
return $startingLine
|
||||
. ($lineCount !== '' ? ($startingLine !== '' ? ' ' : '') . $lineCount : '')
|
||||
. ($description !== '' ? ($startingLine !== '' || $lineCount !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,14 @@ final class Throws extends TagWithType implements Factory\StaticMethod
|
||||
|
||||
public function __toString() : string
|
||||
{
|
||||
return (string) $this->type . ' ' . (string) $this->description;
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$type = (string) $this->type;
|
||||
|
||||
return $type . ($description !== '' ? ($type !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,14 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->refers . ' ' . (string) $this->description;
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$refers = (string) $this->refers;
|
||||
|
||||
return $refers . ($description !== '' ? ($refers !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,8 +99,22 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return ($this->type ? $this->type . ($this->variableName ? ' ' : '') : '')
|
||||
. ($this->variableName ? '$' . $this->variableName : '')
|
||||
. (('' . $this->description) ? ' ' . $this->description : '');
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
if ($this->variableName) {
|
||||
$variableName = ($this->variableName ? '$' . $this->variableName : '');
|
||||
} else {
|
||||
$variableName = '';
|
||||
}
|
||||
|
||||
$type = (string) $this->type;
|
||||
|
||||
return $type
|
||||
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
|
||||
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,14 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString() : string
|
||||
{
|
||||
return ((string) $this->version) .
|
||||
($this->description instanceof Description ? ' ' . $this->description->render() : '');
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$version = (string) $this->version;
|
||||
|
||||
return $version . ($description !== '' ? ($version !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,23 @@ class AuthorTest extends TestCase
|
||||
$fixture = new Author('Mike van Riel', '[email protected]');
|
||||
|
||||
$this->assertSame('Mike van Riel <[email protected]>', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Author('0', '[email protected]');
|
||||
|
||||
$this->assertSame('0 <[email protected]>', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutName() : void
|
||||
{
|
||||
$fixture = new Author('', '[email protected]');
|
||||
|
||||
$this->assertSame('<[email protected]>', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -151,6 +151,40 @@ class CoversTest extends TestCase
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Covers(new Fqsen('\\'));
|
||||
|
||||
$this->assertSame('\\', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Covers(new Fqsen('\DateTime'));
|
||||
|
||||
$this->assertSame('\DateTime', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Covers(new Fqsen('\DateTime'), new Description(''));
|
||||
|
||||
$this->assertSame('\DateTime', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithDescription() : void
|
||||
{
|
||||
$fixture = new Covers(new Fqsen('\DateTime'), new Description('My Description'));
|
||||
|
||||
$this->assertSame('\DateTime My Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
*/
|
||||
|
||||
@@ -117,6 +117,37 @@ class DeprecatedTest extends TestCase
|
||||
$fixture = new Deprecated('1.0', new Description('Description'));
|
||||
|
||||
$this->assertSame('1.0 Description', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Deprecated(null, new Description('My Description'));
|
||||
|
||||
$this->assertSame('My Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Deprecated(null, new Description(''));
|
||||
|
||||
$this->assertSame('', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Deprecated('1.0', new Description(''));
|
||||
|
||||
$this->assertSame('1.0', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Deprecated('1.0');
|
||||
|
||||
$this->assertSame('1.0', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,7 @@ class ExampleTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
@@ -37,7 +37,7 @@ class ExampleTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
@@ -52,7 +52,7 @@ class ExampleTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
@@ -67,7 +67,7 @@ class ExampleTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
@@ -84,7 +84,7 @@ class ExampleTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
@@ -101,7 +101,7 @@ class ExampleTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
|
||||
@@ -107,6 +107,26 @@ class GenericTest extends TestCase
|
||||
$this->assertSame('Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Generic('generic');
|
||||
|
||||
$this->assertSame('', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Generic('generic', new Description(''));
|
||||
|
||||
$this->assertSame('', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -119,6 +119,25 @@ class LinkTest extends TestCase
|
||||
$this->assertSame('http://this.is.my/link Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Link('http://this.is.my/link');
|
||||
|
||||
$this->assertSame('http://this.is.my/link', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Link('http://this.is.my/link', new Description(''));
|
||||
|
||||
$this->assertSame('http://this.is.my/link', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -268,6 +268,36 @@ class MethodTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::isStatic
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Method('myMethod', [], null, false, new Description(''));
|
||||
|
||||
$this->assertSame(
|
||||
'void myMethod()',
|
||||
(string) $fixture
|
||||
);
|
||||
|
||||
// ---
|
||||
|
||||
$arguments = [
|
||||
['name' => 'argument1', 'type' => new String_()],
|
||||
['name' => 'argument2', 'type' => new Object_()],
|
||||
];
|
||||
$fixture = new Method('myMethod', $arguments, new Void_(), true);
|
||||
|
||||
$this->assertSame(
|
||||
'static void myMethod(string $argument1, object $argument2)',
|
||||
(string) $fixture
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -122,6 +122,25 @@ class ReturnTest extends TestCase
|
||||
$this->assertSame('string Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Return_(new String_());
|
||||
|
||||
$this->assertSame('string', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Return_(new String_(), new Description(''));
|
||||
|
||||
$this->assertSame('string', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -135,6 +135,27 @@ class SeeTest extends TestCase
|
||||
$this->assertSame('\DateTime::format() Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen
|
||||
* @uses \phpDocumentor\Reflection\Fqsen
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new See(new FqsenRef(new Fqsen('\DateTime::format()')));
|
||||
|
||||
$this->assertSame('\DateTime::format()', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new See(new FqsenRef(new Fqsen('\DateTime::format()')), new Description(''));
|
||||
|
||||
$this->assertSame('\DateTime::format()', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -119,6 +119,25 @@ class SinceTest extends TestCase
|
||||
$this->assertSame('1.0 Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Since('1.0');
|
||||
|
||||
$this->assertSame('1.0', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Since('1.0', new Description(''));
|
||||
|
||||
$this->assertSame('1.0', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -137,6 +137,32 @@ class SourceTest extends TestCase
|
||||
$this->assertSame('1 10 Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Source(1);
|
||||
|
||||
$this->assertSame('1', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Source(1, 0);
|
||||
|
||||
$this->assertSame('1 0', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Source(1, 10, new Description(''));
|
||||
|
||||
$this->assertSame('1 10', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -120,6 +120,31 @@ class ThrowsTest extends TestCase
|
||||
$fixture = new Throws(new String_(), new Description('Description'));
|
||||
|
||||
$this->assertSame('string Description', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Throws(new String_(), new Description('My Description'));
|
||||
|
||||
$this->assertSame('string My Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Throws(new String_());
|
||||
|
||||
$this->assertSame('string', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Throws(new String_(), new Description(''));
|
||||
|
||||
$this->assertSame('string', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -121,6 +121,25 @@ class UsesTest extends TestCase
|
||||
$this->assertSame('\DateTime Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Uses(new Fqsen('\DateTime'));
|
||||
|
||||
$this->assertSame('\DateTime', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Uses(new Fqsen('\DateTime'), new Description(''));
|
||||
|
||||
$this->assertSame('\DateTime', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -154,6 +154,32 @@ class VarTest extends TestCase
|
||||
$this->assertSame('string $myVariable Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Var_('myVariable');
|
||||
|
||||
$this->assertSame('$myVariable', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Var_('myVariable', new String_());
|
||||
|
||||
$this->assertSame('string $myVariable', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Var_('myVariable', new String_(), new Description(''));
|
||||
|
||||
$this->assertSame('string $myVariable', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -119,6 +119,25 @@ class VersionTest extends TestCase
|
||||
$this->assertSame('1.0 Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Version('1.0');
|
||||
|
||||
$this->assertSame('1.0', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Version('1.0', new Description(''));
|
||||
|
||||
$this->assertSame('1.0', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
Reference in New Issue
Block a user