Skip to content

Commit

Permalink
Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Sep 11, 2023
1 parent b46e810 commit 259fe83
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/PhpDocDecorator/PhpDocFromTypeDeclarationDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Rector\Core\Reflection\ReflectionResolver;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory;
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
Expand All @@ -50,7 +51,8 @@ public function __construct(
private readonly PhpAttributeGroupFactory $phpAttributeGroupFactory,
private readonly ReflectionResolver $reflectionResolver,
private readonly PhpAttributeAnalyzer $phpAttributeAnalyzer,
private readonly PhpVersionProvider $phpVersionProvider
private readonly PhpVersionProvider $phpVersionProvider,
private readonly TypeComparator $typeComparator
) {
$this->classMethodWillChangeReturnTypes = [
// @todo how to make list complete? is the method list needed or can we use just class names?
Expand Down Expand Up @@ -223,11 +225,17 @@ private function moveParamTypeToParamDoc(
Param $param,
Type $type
): void {
$param->type = null;

$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
$paramName = $this->nodeNameResolver->getName($param);
$this->phpDocTypeChanger->changeParamType($functionLike, $phpDocInfo, $type, $param, $paramName);

$param->type = null;
$phpDocParamType = $phpDocInfo->getParamType($paramName);
if ($type::class === $phpDocParamType::class) {
return;
}

$this->phpDocTypeChanger->changeParamType($functionLike, $phpDocInfo, $type, $param, $paramName);
}

/**
Expand Down

0 comments on commit 259fe83

Please sign in to comment.