add more unit tests and fixed the output v2

This commit is contained in:
Lars Moelleken
2020-09-02 22:55:00 +02:00
parent be6ed8b0d8
commit bbe0f54877
6 changed files with 39 additions and 10 deletions
+2 -2
View File
@@ -140,11 +140,11 @@ final class Param extends TagWithType implements Factory\StaticMethod
*/
public function __toString() : string
{
return ($this->type ? $this->type . ' ' : '')
return ($this->type ? $this->type . ($this->variableName ? ' ' : '') : '')
. ($this->isReference() ? '&' : '')
. ($this->isVariadic() ? '...' : '')
. ($this->variableName ? '$' . $this->variableName : '')
. ($this->description ? ($this->variableName ? ' ' : '') . $this->description : '');
. (('' . $this->description) ? ' ' . $this->description : '');
}
private static function strStartsWithVariable(string $str) : bool
+2 -2
View File
@@ -98,8 +98,8 @@ final class Property extends TagWithType implements Factory\StaticMethod
*/
public function __toString() : string
{
return ($this->type ? $this->type . ' ' : '')
return ($this->type ? $this->type . ($this->variableName ? ' ' : '') : '')
. ($this->variableName ? '$' . $this->variableName : '')
. ($this->description ? ($this->variableName ? ' ' : '') . $this->description : '');
. (('' . $this->description) ? ' ' . $this->description : '');
}
}
+2 -2
View File
@@ -98,8 +98,8 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
*/
public function __toString() : string
{
return ($this->type ? $this->type . ' ' : '')
return ($this->type ? $this->type . ($this->variableName ? ' ' : '') : '')
. ($this->variableName ? '$' . $this->variableName : '')
. ($this->description ? ($this->variableName ? ' ' : '') . $this->description : '');
. (('' . $this->description) ? ' ' . $this->description : '');
}
}
+2 -2
View File
@@ -98,8 +98,8 @@ final class PropertyWrite extends TagWithType implements Factory\StaticMethod
*/
public function __toString() : string
{
return ($this->type ? $this->type . ' ' : '')
return ($this->type ? $this->type . ($this->variableName ? ' ' : '') : '')
. ($this->variableName ? '$' . $this->variableName : '')
. ($this->description ? ($this->variableName ? ' ' : '') . $this->description : '');
. (('' . $this->description) ? ' ' . $this->description : '');
}
}
+2 -2
View File
@@ -99,8 +99,8 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
*/
public function __toString() : string
{
return ($this->type ? $this->type . ' ' : '')
return ($this->type ? $this->type . ($this->variableName ? ' ' : '') : '')
. ($this->variableName ? '$' . $this->variableName : '')
. ($this->description ? ($this->variableName ? ' ' : '') . $this->description : '');
. (('' . $this->description) ? ' ' . $this->description : '');
}
}
+29
View File
@@ -237,6 +237,35 @@ class VarTest extends TestCase
$this->assertSame('My Description', $fixture->getDescription() . '');
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
*
* @covers ::create
*/
public function testFactoryMethodWithTypeWithoutComment() : void
{
$typeResolver = new TypeResolver();
$fqsenResolver = new FqsenResolver();
$tagFactory = new StandardTagFactory($fqsenResolver);
$descriptionFactory = new DescriptionFactory($tagFactory);
$context = new Context('');
$fixture = Var_::create(
'int',
$typeResolver,
$descriptionFactory,
$context
);
$this->assertSame('int', (string) $fixture);
$this->assertSame('', $fixture->getVariableName());
$this->assertInstanceOf(Integer::class, $fixture->getType());
$this->assertSame('', $fixture->getDescription() . '');
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::<public>
* @uses \phpDocumentor\Reflection\TypeResolver