Skip to content

Commit 0ce53e0

Browse files
committed
keep doc
1 parent ec7497b commit 0ce53e0

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

rules-tests/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector/Fixture/not_match_return_doc_with_native.php.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ namespace Rector\Tests\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDecl
2020

2121
final class NotMatchReturnDocWithNative
2222
{
23+
/**
24+
* @return \stdClass[]|null
25+
*/
2326
public function run($value)
2427
{
2528
}

src/PhpDocDecorator/PhpDocFromTypeDeclarationDecorator.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct(
5656
private readonly ReflectionResolver $reflectionResolver,
5757
private readonly PhpAttributeAnalyzer $phpAttributeAnalyzer,
5858
private readonly PhpVersionProvider $phpVersionProvider,
59-
private readonly AstResolver $astResolver,
59+
private readonly AstResolver $astResolver
6060
) {
6161
$this->classMethodWillChangeReturnTypes = [
6262
// @todo how to make list complete? is the method list needed or can we use just class names?
@@ -90,12 +90,7 @@ public function decorateReturn(ClassMethod|Function_|Closure|ArrowFunction $func
9090
return;
9191
}
9292

93-
if (! $this->isMatchingType($returnType, [$returnDocType])) {
94-
// not match between @return and native return type, just remove the doc
95-
$phpDocInfo->removeByName(ReturnTagValueNode::class);
96-
} else {
97-
$this->phpDocTypeChanger->changeReturnType($functionLike, $phpDocInfo, $returnDocType);
98-
}
93+
$this->phpDocTypeChanger->changeReturnType($functionLike, $phpDocInfo, $returnDocType);
9994

10095
$functionLike->returnType = null;
10196
if (! $functionLike instanceof ClassMethod) {

0 commit comments

Comments
 (0)