Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
use PHPStan\Type\MixedType;
use PHPStan\Type\UnionType;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
use Rector\Rector\AbstractRector;
use Rector\StaticTypeMapper\StaticTypeMapper;
use Rector\TypeDeclarationDocblocks\NodeDocblockTypeDecorator;
use Rector\TypeDeclarationDocblocks\TagNodeAnalyzer\UsefulArrayTagNodeAnalyzer;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
Expand All @@ -26,9 +25,8 @@ final class DocblockGetterReturnArrayFromPropertyDocblockVarRector extends Abstr
{
public function __construct(
private readonly PhpDocInfoFactory $phpDocInfoFactory,
private readonly StaticTypeMapper $staticTypeMapper,
private readonly UsefulArrayTagNodeAnalyzer $usefulArrayTagNodeAnalyzer,
private readonly PhpDocTypeChanger $phpDocTypeChanger
private readonly NodeDocblockTypeDecorator $nodeDocblockTypeDecorator
) {
}

Expand Down Expand Up @@ -96,11 +94,6 @@ public function refactor(Node $node): ?Node
return null;
}

// // return tag is already given
// if ($phpDocInfo->getReturnTagValue() instanceof ReturnTagValueNode) {
// return null;
// }

$propertyFetch = $this->matchReturnLocalPropertyFetch($node);
if (! $propertyFetch instanceof PropertyFetch) {
return null;
Expand All @@ -118,14 +111,13 @@ public function refactor(Node $node): ?Node
return null;
}

$propertyFetchDocTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($propertyFetchType);

$this->phpDocTypeChanger->changeReturnTypeNode($node, $phpDocInfo, $propertyFetchDocTypeNode);

// $returnTagValueNode = new ReturnTagValueNode($propertyFetchDocTypeNode, '');
// $phpDocInfo->addTagValueNode($returnTagValueNode);
//
// $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node);
if (! $this->nodeDocblockTypeDecorator->decorateGenericIterableReturnType(
$propertyFetchType,
$phpDocInfo,
$node
)) {
return null;
}

return $node;
}
Expand Down