Skip to content

Commit 0e31897

Browse files
author
Kirill Nesmeyanov
committed
Improve type tag representation
1 parent a5cab59 commit 0e31897

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/DocBlock/Tag/TypedTag.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace TypeLang\PhpDocParser\DocBlock\Tag;
66

77
use TypeLang\Parser\Node\Stmt\TypeStatement;
8+
use TypeLang\Printer\PrettyPrinter;
89

910
abstract class TypedTag extends Tag implements TypeProviderInterface
1011
{
@@ -29,11 +30,19 @@ public function getType(): TypeStatement
2930
*/
3031
public function __toString(): string
3132
{
33+
$type = $this->type::class;
34+
35+
if (\property_exists($this->type, 'name')) {
36+
$type = (string)$this->type->name;
37+
}
38+
39+
if (\class_exists(PrettyPrinter::class)) {
40+
$type = (new PrettyPrinter())->print($this->type);
41+
}
42+
3243
return \rtrim(\vsprintf('@%s %s %s', [
3344
$this->name,
34-
\property_exists($this->type, 'name')
35-
? (string)$this->type->name
36-
: $this->type::class,
45+
$type,
3746
(string)$this->description,
3847
]));
3948
}

0 commit comments

Comments
 (0)