From b38f56f258e7c2ebceab66548c74eaa7c64e6340 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Fri, 19 Mar 2021 15:20:15 +0100 Subject: [PATCH] rector: skip false positive return type --- .../BetterPhpDocParser/Printer/PhpDocInfoPrinter.php | 11 ++++++++--- rector.php | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php b/packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php index 95a84cc1d7bd..1953a011c8c6 100644 --- a/packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php +++ b/packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php @@ -349,7 +349,9 @@ private function printAttributeWithAsterisk(Node $node): string */ private function getRemovedNodesPositions(): array { - $removedNodePositions = []; + if ($this->removedNodePositions !== []) { + return $this->removedNodePositions; + } $removedNodes = array_diff( $this->phpDocInfo->getOriginalPhpDocNode() @@ -381,10 +383,13 @@ private function getRemovedNodesPositions(): array $lastEndPosition = $removedPhpDocNodeInfo->getEnd(); - $removedNodePositions[] = new StartAndEnd(max(0, $seekPosition - 1), $removedPhpDocNodeInfo->getEnd()); + $this->removedNodePositions[] = new StartAndEnd(max( + 0, + $seekPosition - 1 + ), $removedPhpDocNodeInfo->getEnd()); } - return $removedNodePositions; + return $this->removedNodePositions; } /** diff --git a/rector.php b/rector.php index eb4e22b89fcc..b3caa3cbefd8 100644 --- a/rector.php +++ b/rector.php @@ -14,6 +14,7 @@ use Rector\Restoration\Rector\ClassMethod\InferParamFromClassMethodReturnRector; use Rector\Restoration\ValueObject\InferParamFromClassMethodReturn; use Rector\Set\ValueObject\SetList; +use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symplify\SymfonyPhpConfig\ValueObjectInliner; @@ -74,6 +75,11 @@ PrivatizeLocalPropertyToPrivatePropertyRector::class => [__DIR__ . '/src/Rector/AbstractRector.php'], + ReturnTypeDeclarationRector::class => [ + __DIR__ . '/packages/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php', + __DIR__ . '/packages/PHPStanStaticTypeMapper/TypeMapper/ObjectTypeMapper.php', + ], + // test paths '*/Fixture/*', '*/Fixture/*',