Skip to content

Commit f3ba681

Browse files
committed
skip return $this removal on trait on RemoveReturnTagIncompatibleWithNativeTypeRector
1 parent 34cebe0 commit f3ba681

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

rules/DeadCode/Rector/ClassMethod/RemoveReturnTagIncompatibleWithNativeTypeRector.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,15 @@ public function refactor(Node $node): ?Node
116116
return null;
117117
}
118118

119+
$nativeReturnType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($node->returnType);
119120
$classReflection = $scope->getClassReflection();
120121
if ($scope->isInClass() && $classReflection->isTrait()
121-
&& $returnTagValueNode->type instanceof ThisTypeNode) {
122+
&& $returnTagValueNode->type instanceof ThisTypeNode
123+
&& $nativeReturnType instanceof ObjectType
124+
) {
122125
return null;
123126
}
124127

125-
$nativeReturnType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($node->returnType);
126128
if ($this->isReturnTemplate($phpDocInfo, $returnTagValueNode)) {
127129
return null;
128130
}

0 commit comments

Comments
 (0)