Skip to content

Commit

Permalink
Updated Rector to commit bfa1891c50677b01136a9308fd3c3ecc12e267d9
Browse files Browse the repository at this point in the history
rectorphp/rector-src@bfa1891 [cleanup] Remove 73 unused public methods (#3245)
  • Loading branch information
TomasVotruba committed Dec 23, 2022
1 parent 680ba23 commit 727b9f4
Show file tree
Hide file tree
Showing 119 changed files with 482 additions and 820 deletions.
69 changes: 12 additions & 57 deletions packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
Expand Down Expand Up @@ -177,15 +176,6 @@ public function getReturnType() : Type
{
return $this->getTypeOrMixed($this->getReturnTagValue());
}
/**
* @template TNode as \PHPStan\PhpDocParser\Ast\Node
* @param class-string<TNode> $type
* @return TNode[]
*/
public function getByType(string $type) : array
{
return $this->phpDocNodeByTypeFinder->findByType($this->phpDocNode, $type);
}
/**
* @param class-string<Node> $type
*/
Expand Down Expand Up @@ -233,6 +223,9 @@ public function getByAnnotationClasses(array $classes) : ?DoctrineAnnotationTagV
$doctrineAnnotationTagValueNodes = $this->phpDocNodeByTypeFinder->findDoctrineAnnotationsByClasses($this->phpDocNode, $classes);
return $doctrineAnnotationTagValueNodes[0] ?? null;
}
/**
* @api doctrine/symfony
*/
public function getByAnnotationClass(string $class) : ?DoctrineAnnotationTagValueNode
{
$doctrineAnnotationTagValueNodes = $this->phpDocNodeByTypeFinder->findDoctrineAnnotationsByClass($this->phpDocNode, $class);
Expand Down Expand Up @@ -268,14 +261,6 @@ public function findOneByAnnotationClass(string $desiredClass) : ?DoctrineAnnota
$foundTagValueNodes = $this->findByAnnotationClass($desiredClass);
return $foundTagValueNodes[0] ?? null;
}
/**
* @param class-string $desiredClass
* @return DoctrineAnnotationTagValueNode[]
*/
public function findByAnnotationClass(string $desiredClass) : array
{
return $this->phpDocNodeByTypeFinder->findDoctrineAnnotationsByClass($this->phpDocNode, $desiredClass);
}
/**
* @template T of \PHPStan\PhpDocParser\Ast\Node
* @param class-string<T> $typeToRemove
Expand All @@ -302,18 +287,6 @@ public function removeByType(string $typeToRemove) : void
return PhpDocNodeTraverser::NODE_REMOVE;
});
}
/**
* @return array<string, Type>
*/
public function getParamTypesByName() : array
{
$paramTypesByName = [];
foreach ($this->phpDocNode->getParamTagValues() as $paramTagValueNode) {
$parameterType = $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($paramTagValueNode, $this->node);
$paramTypesByName[$paramTagValueNode->parameterName] = $parameterType;
}
return $paramTypesByName;
}
public function addTagValueNode(PhpDocTagValueNode $phpDocTagValueNode) : void
{
if ($phpDocTagValueNode instanceof DoctrineAnnotationTagValueNode) {
Expand Down Expand Up @@ -388,21 +361,6 @@ public function getTemplateTagValueNodes() : array
{
return $this->phpDocNode->getTemplateTagValues();
}
public function hasInheritDoc() : bool
{
if ($this->hasByNames(['inheritdoc', 'inheritDoc'])) {
return \true;
}
foreach ($this->phpDocNode->children as $children) {
if (!$children instanceof PhpDocTextNode) {
continue;
}
if (\in_array($children->text, ['{@inheritdoc}', '{@inheritDoc}'], \true)) {
return \true;
}
}
return \false;
}
/**
* @deprecated
* Should be handled by attributes of phpdoc node - if stard_and_end is missing in one of nodes, it has been changed
Expand Down Expand Up @@ -431,17 +389,6 @@ public function hasChanged() : bool
$phpDocNodeTraverser->traverse($this->phpDocNode);
return $changedPhpDocNodeVisitor->hasChanged();
}
/**
* @return string[]
*/
public function getMethodTagNames() : array
{
$methodTagNames = [];
foreach ($this->phpDocNode->getMethodTagValues() as $methodTagValueNode) {
$methodTagNames[] = $methodTagValueNode->methodName;
}
return $methodTagNames;
}
public function makeMultiLined() : void
{
$this->isSingleLine = \false;
Expand All @@ -450,7 +397,7 @@ public function getNode() : \PhpParser\Node
{
return $this->node;
}
public function resolveNameForPhpDocTagValueNode(PhpDocTagValueNode $phpDocTagValueNode) : ?string
private function resolveNameForPhpDocTagValueNode(PhpDocTagValueNode $phpDocTagValueNode) : ?string
{
foreach (self::TAGS_TYPES_TO_NAMES as $tagValueNodeType => $name) {
/** @var class-string<PhpDocTagNode> $tagValueNodeType */
Expand All @@ -460,6 +407,14 @@ public function resolveNameForPhpDocTagValueNode(PhpDocTagValueNode $phpDocTagVa
}
return null;
}
/**
* @param class-string $desiredClass
* @return DoctrineAnnotationTagValueNode[]
*/
private function findByAnnotationClass(string $desiredClass) : array
{
return $this->phpDocNodeByTypeFinder->findDoctrineAnnotationsByClass($this->phpDocNode, $desiredClass);
}
/**
* @return \PHPStan\Type\MixedType|\PHPStan\Type\Type
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ public function copyPropertyDocToParam(Property $property, Param $param) : void
$this->changeParamType($phpDocInfo, $paramType, $param, $paramVarName);
$this->processKeepComments($property, $param);
}
/**
* @api doctrine
*/
public function changeVarTypeNode(PhpDocInfo $phpDocInfo, TypeNode $typeNode) : void
{
// add completely new one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@
namespace Rector\BetterPhpDocParser\PhpDocManipulator;

use PhpParser\Node;
use PhpParser\Node\Stmt\Expression;
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
use PHPStan\Type\MixedType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeWithClassName;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
final class VarAnnotationManipulator
{
/**
Expand All @@ -25,28 +19,10 @@ final class VarAnnotationManipulator
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger
*/
private $phpDocTypeChanger;
/**
* @readonly
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
*/
private $betterNodeFinder;
public function __construct(PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, BetterNodeFinder $betterNodeFinder)
public function __construct(PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger)
{
$this->phpDocInfoFactory = $phpDocInfoFactory;
$this->phpDocTypeChanger = $phpDocTypeChanger;
$this->betterNodeFinder = $betterNodeFinder;
}
public function decorateNodeWithInlineVarType(Node $node, TypeWithClassName $typeWithClassName, string $variableName) : void
{
$phpDocInfo = $this->resolvePhpDocInfo($node);
// already done
if ($phpDocInfo->getVarTagValueNode() !== null) {
return;
}
$fullyQualifiedIdentifierTypeNode = new FullyQualifiedIdentifierTypeNode($typeWithClassName->getClassName());
$varTagValueNode = new VarTagValueNode($fullyQualifiedIdentifierTypeNode, '$' . $variableName, '');
$phpDocInfo->addTagValueNode($varTagValueNode);
$phpDocInfo->makeSingleLined();
}
/**
* @api
Expand All @@ -59,15 +35,4 @@ public function decorateNodeWithType(Node $node, Type $staticType) : void
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
$this->phpDocTypeChanger->changeVarType($phpDocInfo, $staticType);
}
private function resolvePhpDocInfo(Node $node) : PhpDocInfo
{
$currentStmt = $this->betterNodeFinder->resolveCurrentStatement($node);
if ($currentStmt instanceof Expression) {
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($currentStmt);
} else {
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
}
$phpDocInfo->makeSingleLined();
return $phpDocInfo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public function __construct(UseImportNameMatcher $useImportNameMatcher, UseImpor
$this->useImportsResolver = $useImportsResolver;
$this->reflectionProvider = $reflectionProvider;
}
/**
* @api doctrine
*/
public function resolveTagToKnownFullyQualifiedName(string $tag, Property $property) : ?string
{
return $this->_resolveTagFullyQualifiedName($tag, $property, \true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function resolveAnnotationMethodCall(BetterTokenIterator $tokenIterator)
return $this->resolveAnnotationValues($tokenIterator);
}
/**
* @api tests
* @see https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1215-L1224
* @return CurlyListNode|string|array<mixed>|ConstExprNode|DoctrineAnnotationTagValueNode
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function printFormatPreserving(PhpDocInfo $phpDocInfo) : string
// hotfix of extra space with callable ()
return Strings::replace($phpDocString, self::CALLABLE_REGEX, 'callable(');
}
public function getCurrentPhpDocInfo() : PhpDocInfo
private function getCurrentPhpDocInfo() : PhpDocInfo
{
if ($this->phpDocInfo === null) {
throw new ShouldNotHappenException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,6 @@ public function printFromTo(int $from, int $to) : string
}
return $content;
}
public function print() : string
{
$content = '';
foreach ($this->getTokens() as $token) {
$content .= $token[0];
}
return $content;
}
public function nextTokenType() : ?int
{
$tokens = $this->getTokens();
// does next token exist?
$nextIndex = $this->currentPosition() + 1;
if (!isset($tokens[$nextIndex])) {
return null;
}
$this->pushSavePoint();
$this->next();
$nextTokenType = $this->currentTokenType();
$this->rollback();
return $nextTokenType;
}
public function currentPosition() : int
{
return $this->privatesAccessor->getPrivateProperty($this, self::INDEX);
Expand Down Expand Up @@ -133,4 +111,18 @@ public function containsTokenType(int $type) : bool
}
return \false;
}
private function nextTokenType() : ?int
{
$tokens = $this->getTokens();
// does next token exist?
$nextIndex = $this->currentPosition() + 1;
if (!isset($tokens[$nextIndex])) {
return null;
}
$this->pushSavePoint();
$this->next();
$nextTokenType = $this->currentTokenType();
$this->rollback();
return $nextTokenType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public function __construct(array $values = [], ?string $originalContent = null,
$this->originalContent = $originalContent;
$this->silentKey = $silentKey;
}
/**
* @api
*/
public function removeValue(string $desiredKey) : void
{
foreach ($this->values as $key => $value) {
Expand Down
7 changes: 0 additions & 7 deletions packages/BetterPhpDocParser/ValueObject/StartAndEnd.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,4 @@ public function getEnd() : int
{
return $this->end;
}
public function contains(int $position) : bool
{
if ($position < $this->start) {
return \false;
}
return $position < $this->end;
}
}
3 changes: 3 additions & 0 deletions packages/Caching/CacheFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public function __construct(ParameterProvider $parameterProvider, Filesystem $fi
$this->parameterProvider = $parameterProvider;
$this->fileSystem = $fileSystem;
}
/**
* @api config factory
*/
public function create() : \Rector\Caching\Cache
{
$cacheDirectory = $this->parameterProvider->provideStringParameter(Option::CACHE_DIR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ public function getRectorClass() : string
{
return $this->rectorClass;
}
public function getLine() : int
{
return $this->line;
}
/**
* @param array<string, mixed> $json
* @return $this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*/
final class FluentChainMethodCallNodeAnalyzer
{
/**
* @api doctrine
*/
public function resolveRootMethodCall(MethodCall $methodCall) : ?MethodCall
{
$callerNode = $methodCall->var;
Expand Down
39 changes: 0 additions & 39 deletions packages/Defluent/NodeAnalyzer/SameClassMethodCallAnalyzer.php

This file was deleted.

5 changes: 4 additions & 1 deletion packages/FamilyTree/NodeAnalyzer/ClassChildAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public function hasAbstractParentClassMethod(ClassReflection $classReflection, s
}
return \false;
}
/**
* @api downgrade
*/
public function resolveParentClassMethodReturnType(ClassReflection $classReflection, string $methodName) : Type
{
$parentClassMethods = $this->resolveParentClassMethods($classReflection, $methodName);
Expand All @@ -76,7 +79,7 @@ public function resolveParentClassMethodReturnType(ClassReflection $classReflect
/**
* @return PhpMethodReflection[]
*/
public function resolveParentClassMethods(ClassReflection $classReflection, string $methodName) : array
private function resolveParentClassMethods(ClassReflection $classReflection, string $methodName) : array
{
$parentClassMethods = [];
$parents = \array_merge($classReflection->getParents(), $classReflection->getInterfaces());
Expand Down
1 change: 1 addition & 0 deletions packages/FileSystemRector/Parser/FileInfoParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function __construct(NodeScopeAndMetadataDecorator $nodeScopeAndMetadataD
$this->rectorParser = $rectorParser;
}
/**
* @api tests only
* @return Stmt[]
*/
public function parseFileInfoToNodesAndDecorate(string $filePath) : array
Expand Down
Loading

0 comments on commit 727b9f4

Please sign in to comment.