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 9c108ef
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 31 deletions.
26 changes: 0 additions & 26 deletions packages/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,32 +296,6 @@ private function resolveTokenEnd(TokenIterator $tokenIterator): int
return $this->adjustTokenEndToFitClassAnnotation($tokenIterator, $tokenEnd);
}

// private function getOriginalContentFromTokenIterator(TokenIterator $tokenIterator): string
// {
// $originalTokens = $this->privatesAccessor->getPrivateProperty($tokenIterator, 'tokens');
// $originalContent = '';
//
// foreach ($originalTokens as $originalToken) {
// // skip opening
// if ($originalToken[1] === Lexer::TOKEN_OPEN_PHPDOC) {
// continue;
// }
//
// // skip closing
// if ($originalToken[1] === Lexer::TOKEN_CLOSE_PHPDOC) {
// continue;
// }
//
// if ($originalToken[1] === Lexer::TOKEN_PHPDOC_EOL) {
// $originalToken[0] = PHP_EOL;
// }
//
// $originalContent .= $originalToken[0];
// }
//
// return trim($originalContent);
// }

/**
* @see https://github.com/rectorphp/rector/issues/2158
*
Expand Down
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
2 changes: 0 additions & 2 deletions packages/BetterPhpDocParser/Printer/WhitespaceDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
use Nette\Utils\Strings;
use PHPStan\PhpDocParser\Ast\Node;
use PHPStan\PhpDocParser\Lexer\Lexer;
//use Rector\BetterPhpDocParser\Contract\Doctrine\DoctrineTagNodeInterface;
//use Rector\BetterPhpDocParser\Contract\PhpDocNode\ShortNameAwareTagInterface;
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;

final class WhitespaceDetector
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 9c108ef

Please sign in to comment.