Skip to content

Commit 9cea4c4

Browse files
committed
Only generate property var doc block if type / comment is set - Close #19
1 parent 998293a commit 9cea4c4

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/Code/PropertyGenerator.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,33 @@ private function generateAttributes(): array
177177
return ['comments' => [new Doc($this->docBlock->generate())]];
178178
}
179179

180-
if ($this->typed === false || $this->docBlockComment !== null) {
181-
$docBlockType = new VarTag($this->type->types());
180+
if ($this->typed === false || $this->docBlockComment !== null || $this->typeDocBlockHint !== null) {
181+
$docBlockType = null;
182182

183+
if ($this->type) {
184+
$docBlockType = new VarTag($this->type->types());
185+
}
183186
if ($typeHint = $this->getTypeDocBlockHint()) {
184-
$docBlockType->setTypes($typeHint);
187+
$docBlockType = new VarTag($typeHint);
185188
}
186-
$docBlock = new DocBlock($this->docBlockComment, $docBlockType);
189+
$docBlock = null;
190+
191+
if ($this->docBlockComment) {
192+
$docBlock = new DocBlock($this->docBlockComment);
187193

188-
$attributes = ['comments' => [new Doc($docBlock->generate())]];
194+
if ($docBlockType !== null) {
195+
$docBlock->addTag($docBlockType);
196+
}
197+
}
198+
if ($this->docBlockComment === null && $docBlockType !== null) {
199+
$docBlock = new DocBlock($this->docBlockComment, $docBlockType);
200+
}
201+
202+
if ($docBlock !== null) {
203+
$docBlock = new DocBlock($this->docBlockComment, $docBlockType);
204+
205+
$attributes = ['comments' => [new Doc($docBlock->generate())]];
206+
}
189207
}
190208

191209
return $attributes;

0 commit comments

Comments
 (0)