Skip to content

Commit

Permalink
rector: skip false positive return type
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Mar 19, 2021
1 parent 4a7b8b1 commit b38f56f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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/*',
Expand Down

0 comments on commit b38f56f

Please sign in to comment.