1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Don’t convert trait self to trait name

This commit is contained in:
Matthew Brown 2019-06-26 00:28:43 -04:00
parent c66a106622
commit 372a512a86
2 changed files with 15 additions and 2 deletions

View File

@ -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(

View File

@ -854,6 +854,19 @@ class TraitTest extends TestCase
$f1 = new Foo();
$f2 = (new Foo())->bar($f1);',
],
'traitSelfDocblockReturn' => [
'<?php
trait T {
/** @return self */
public function getSelf() {
return $this;
}
}
class C {
use T;
}'
],
];
}