diff --git a/src/Psalm/Internal/Visitor/ReflectorVisitor.php b/src/Psalm/Internal/Visitor/ReflectorVisitor.php index a9b399619..4833f99ac 100644 --- a/src/Psalm/Internal/Visitor/ReflectorVisitor.php +++ b/src/Psalm/Internal/Visitor/ReflectorVisitor.php @@ -2157,7 +2157,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse $docblock_info->params, $stmt, $fake_method, - $class_storage ? $class_storage->name : null + $class_storage && !$class_storage->is_trait ? $class_storage->name : null ); } @@ -2279,7 +2279,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse $this->aliases, $this->function_template_types + $this->class_template_types, $this->type_aliases, - $class_storage ? $class_storage->name : null + $class_storage && !$class_storage->is_trait ? $class_storage->name : null ); $storage->return_type = Type::parseTokens( diff --git a/tests/TraitTest.php b/tests/TraitTest.php index 032e3b446..67a16aa7e 100644 --- a/tests/TraitTest.php +++ b/tests/TraitTest.php @@ -854,6 +854,19 @@ class TraitTest extends TestCase $f1 = new Foo(); $f2 = (new Foo())->bar($f1);', ], + 'traitSelfDocblockReturn' => [ + '