Skip to content

Commit

Permalink
Don’t convert trait self to trait name
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jun 26, 2019
1 parent c66a106 commit 372a512
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Visitor/ReflectorVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2157,7 +2157,7 @@ private function registerFunctionLike(PhpParser\Node\FunctionLike $stmt, $fake_m
$docblock_info->params,
$stmt,
$fake_method,
$class_storage ? $class_storage->name : null
$class_storage && !$class_storage->is_trait ? $class_storage->name : null
);
}

Expand Down Expand Up @@ -2279,7 +2279,7 @@ function (FunctionLikeParameter $p) {
$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(
Expand Down
13 changes: 13 additions & 0 deletions tests/TraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,19 @@ class Foo {
$f1 = new Foo();
$f2 = (new Foo())->bar($f1);',
],
'traitSelfDocblockReturn' => [
'<?php
trait T {
/** @return self */
public function getSelf() {
return $this;
}
}
class C {
use T;
}'
],
];
}

Expand Down

0 comments on commit 372a512

Please sign in to comment.