diff --git a/src/DocBlock/Tags/Var_.php b/src/DocBlock/Tags/Var_.php index e23c694..f431a86 100644 --- a/src/DocBlock/Tags/Var_.php +++ b/src/DocBlock/Tags/Var_.php @@ -111,8 +111,8 @@ class Var_ extends BaseTag implements Factory\StaticMethod */ public function __toString() { - return ($this->type ? $this->type . ' ' : '') - . '$' . $this->variableName - . ($this->description ? ' ' . $this->description : ''); + return ($this->type ? $this->type.' ' : '') + .(empty($this->variableName) ? null : ('$'.$this->variableName)) + .($this->description ? ' '.$this->description : ''); } } diff --git a/tests/unit/DocBlock/Tags/VarTest.php b/tests/unit/DocBlock/Tags/VarTest.php index 34f290a..bbc5d6b 100644 --- a/tests/unit/DocBlock/Tags/VarTest.php +++ b/tests/unit/DocBlock/Tags/VarTest.php @@ -37,6 +37,17 @@ class VarTest extends \PHPUnit_Framework_TestCase $this->assertSame('var', $fixture->getName()); } + /** + * @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__construct + * @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render + */ + public function testIfVariableNameIsOmmitedIfEmpty() + { + $fixture = new Var_('', null, null); + + $this->assertSame('@var', $fixture->render()); + } + /** * @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__construct * @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__toString