Skip to content

Commit 86e2401

Browse files
committed
Merge remote-tracking branch 'warxcell/empty_var_name'
2 parents 125c8b1 + b11ada4 commit 86e2401

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/DocBlock/Tags/Var_.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ public function getType()
111111
*/
112112
public function __toString()
113113
{
114-
return ($this->type ? $this->type . ' ' : '')
115-
. '$' . $this->variableName
116-
. ($this->description ? ' ' . $this->description : '');
114+
return ($this->type ? $this->type.' ' : '')
115+
.(empty($this->variableName) ? null : ('$'.$this->variableName))
116+
.($this->description ? ' '.$this->description : '');
117117
}
118118
}

tests/unit/DocBlock/Tags/VarTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ public function testIfCorrectTagNameIsReturned()
3737
$this->assertSame('var', $fixture->getName());
3838
}
3939

40+
/**
41+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__construct
42+
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
43+
*/
44+
public function testIfVariableNameIsOmmitedIfEmpty()
45+
{
46+
$fixture = new Var_('', null, null);
47+
48+
$this->assertSame('@var', $fixture->render());
49+
}
50+
4051
/**
4152
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__construct
4253
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__toString

0 commit comments

Comments
 (0)