From c8f532c366b2edfb57f95bb60b10e55308b5f9a8 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Fri, 19 Mar 2021 23:43:37 +0100 Subject: [PATCH] remove unused class --- .../ClassMethodReturnVendorLockResolver.php | 10 +-------- .../PropertyTypeVendorLockResolver.php | 10 +-------- .../ClassReflectionAncestorAnalyzer.php | 15 ------------- .../skip_already_set_return_type.php.inc | 21 +++++++++++++++++++ ...veOutMethodCallInsideIfConditionRector.php | 7 ++++--- 5 files changed, 27 insertions(+), 36 deletions(-) delete mode 100644 packages/VendorLocker/Reflection/ClassReflectionAncestorAnalyzer.php create mode 100644 rules-tests/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector/Fixture/skip_already_set_return_type.php.inc diff --git a/packages/VendorLocker/NodeVendorLocker/ClassMethodReturnVendorLockResolver.php b/packages/VendorLocker/NodeVendorLocker/ClassMethodReturnVendorLockResolver.php index bc1e38b51e5a..4662ae9fedce 100644 --- a/packages/VendorLocker/NodeVendorLocker/ClassMethodReturnVendorLockResolver.php +++ b/packages/VendorLocker/NodeVendorLocker/ClassMethodReturnVendorLockResolver.php @@ -11,16 +11,10 @@ use PHPStan\Type\MixedType; use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\Node\AttributeKey; -use Rector\VendorLocker\Reflection\ClassReflectionAncestorAnalyzer; use Rector\VendorLocker\Reflection\MethodReflectionContractAnalyzer; final class ClassMethodReturnVendorLockResolver { - /** - * @var ClassReflectionAncestorAnalyzer - */ - private $classReflectionAncestorAnalyzer; - /** * @var MethodReflectionContractAnalyzer */ @@ -32,11 +26,9 @@ final class ClassMethodReturnVendorLockResolver private $nodeNameResolver; public function __construct( - ClassReflectionAncestorAnalyzer $classReflectionAncestorAnalyzer, MethodReflectionContractAnalyzer $methodReflectionContractAnalyzer, NodeNameResolver $nodeNameResolver ) { - $this->classReflectionAncestorAnalyzer = $classReflectionAncestorAnalyzer; $this->methodReflectionContractAnalyzer = $methodReflectionContractAnalyzer; $this->nodeNameResolver = $nodeNameResolver; } @@ -53,7 +45,7 @@ public function isVendorLocked(ClassMethod $classMethod): bool return false; } - if (! $this->classReflectionAncestorAnalyzer->hasAncestors($classReflection)) { + if ($classReflection->getAncestors() === [$classReflection]) { return false; } diff --git a/packages/VendorLocker/NodeVendorLocker/PropertyTypeVendorLockResolver.php b/packages/VendorLocker/NodeVendorLocker/PropertyTypeVendorLockResolver.php index ab8bcf384a57..57ce76f81e3c 100644 --- a/packages/VendorLocker/NodeVendorLocker/PropertyTypeVendorLockResolver.php +++ b/packages/VendorLocker/NodeVendorLocker/PropertyTypeVendorLockResolver.php @@ -10,15 +10,9 @@ use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer; use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\Node\AttributeKey; -use Rector\VendorLocker\Reflection\ClassReflectionAncestorAnalyzer; final class PropertyTypeVendorLockResolver { - /** - * @var ClassReflectionAncestorAnalyzer - */ - private $classReflectionAncestorAnalyzer; - /** * @var NodeNameResolver */ @@ -30,11 +24,9 @@ final class PropertyTypeVendorLockResolver private $familyRelationsAnalyzer; public function __construct( - ClassReflectionAncestorAnalyzer $classReflectionAncestorAnalyzer, NodeNameResolver $nodeNameResolver, FamilyRelationsAnalyzer $familyRelationsAnalyzer ) { - $this->classReflectionAncestorAnalyzer = $classReflectionAncestorAnalyzer; $this->nodeNameResolver = $nodeNameResolver; $this->familyRelationsAnalyzer = $familyRelationsAnalyzer; } @@ -49,7 +41,7 @@ public function isVendorLocked(Property $property): bool return false; } - if (! $this->classReflectionAncestorAnalyzer->hasAncestors($classReflection)) { + if ($classReflection->getAncestors() === [$classReflection]) { return false; } diff --git a/packages/VendorLocker/Reflection/ClassReflectionAncestorAnalyzer.php b/packages/VendorLocker/Reflection/ClassReflectionAncestorAnalyzer.php deleted file mode 100644 index 50440b7db471..000000000000 --- a/packages/VendorLocker/Reflection/ClassReflectionAncestorAnalyzer.php +++ /dev/null @@ -1,15 +0,0 @@ -getAncestors() !== [$classReflection]; - } -} diff --git a/rules-tests/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector/Fixture/skip_already_set_return_type.php.inc b/rules-tests/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector/Fixture/skip_already_set_return_type.php.inc new file mode 100644 index 000000000000..585c6195aa95 --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector/Fixture/skip_already_set_return_type.php.inc @@ -0,0 +1,21 @@ +getAttribute(AttributeKey::SCOPE); + if (! $scope instanceof Scope) { + return false; + } - return $scope->hasVariableType($variableName) - ->yes(); + return $scope->hasVariableType($variableName)->yes(); } }