From c1e1053d1c83a2fa1cd88fe9ee7690e34971f320 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Sun, 19 Jul 2020 21:32:18 +0200 Subject: [PATCH] correct names manually back to desired state --- .../ClassMethodParamVendorLockResolver.php | 6 +++--- .../ClassMethodReturnVendorLockResolver.php | 6 +++--- .../SplitGroupedConstantsAndPropertiesRector.php | 16 ++++++++-------- ...erRegistryGetManagerToEntityManagerRector.php | 10 +++++----- .../MethodCall/ChangeSetIdToUuidValueRector.php | 8 ++++---- .../PrivatizeLocalClassConstantRector.php | 12 ++++++------ .../MultipleClassFileToPsr4ClassesRectorTest.php | 4 ++-- .../PHPUnitStaticToKernelTestCaseGetRector.php | 6 +++--- .../src/UniqueObjectFactoryFactory.php | 4 ++-- .../MultiParentingToAbstractDependencyRector.php | 6 +++--- .../EventListenerToEventSubscriberRector.php | 10 +++++----- .../FormTypeInstanceToClassConstRector.php | 8 ++++---- .../ReadOnlyOptionToAttributeRector.php | 8 ++++---- .../SimplifyWebTestCaseAssertionsRector.php | 4 ++-- 14 files changed, 54 insertions(+), 54 deletions(-) diff --git a/packages/vendor-locker/src/NodeVendorLocker/ClassMethodParamVendorLockResolver.php b/packages/vendor-locker/src/NodeVendorLocker/ClassMethodParamVendorLockResolver.php index 27f7dd360fc..0c4b33e0eb9 100644 --- a/packages/vendor-locker/src/NodeVendorLocker/ClassMethodParamVendorLockResolver.php +++ b/packages/vendor-locker/src/NodeVendorLocker/ClassMethodParamVendorLockResolver.php @@ -45,9 +45,9 @@ final class ClassMethodParamVendorLockResolver extends AbstractNodeVendorLockRes private function isParentClassVendorLocking(int $paramPosition, string $parentClassName, string $methodName): ?bool { - $class = $this->parsedNodeCollector->findClass($parentClassName); - if ($class !== null) { - $parentClassMethod = $class->getMethod($methodName); + $parentClass = $this->parsedNodeCollector->findClass($parentClassName); + if ($parentClass !== null) { + $parentClassMethod = $parentClass->getMethod($methodName); // parent class method in local scope → it's ok if ($parentClassMethod !== null) { // parent method has no type → we cannot change it here diff --git a/packages/vendor-locker/src/NodeVendorLocker/ClassMethodReturnVendorLockResolver.php b/packages/vendor-locker/src/NodeVendorLocker/ClassMethodReturnVendorLockResolver.php index 198e59cfec8..c4848fb325f 100644 --- a/packages/vendor-locker/src/NodeVendorLocker/ClassMethodReturnVendorLockResolver.php +++ b/packages/vendor-locker/src/NodeVendorLocker/ClassMethodReturnVendorLockResolver.php @@ -41,9 +41,9 @@ final class ClassMethodReturnVendorLockResolver extends AbstractNodeVendorLockRe private function isVendorLockedByParentClass(string $parentClassName, string $methodName): bool { - $class = $this->parsedNodeCollector->findClass($parentClassName); - if ($class !== null) { - $parentClassMethod = $class->getMethod($methodName); + $parentClass = $this->parsedNodeCollector->findClass($parentClassName); + if ($parentClass !== null) { + $parentClassMethod = $parentClass->getMethod($methodName); // validate type is conflicting // parent class method in local scope → it's ok if ($parentClassMethod !== null) { diff --git a/rules/coding-style/src/Rector/ClassConst/SplitGroupedConstantsAndPropertiesRector.php b/rules/coding-style/src/Rector/ClassConst/SplitGroupedConstantsAndPropertiesRector.php index 768b3631d8e..d37d416a119 100644 --- a/rules/coding-style/src/Rector/ClassConst/SplitGroupedConstantsAndPropertiesRector.php +++ b/rules/coding-style/src/Rector/ClassConst/SplitGroupedConstantsAndPropertiesRector.php @@ -73,13 +73,13 @@ PHP return null; } - $allConstants = $node->consts; + $allConsts = $node->consts; - /** @var Const_ $const */ - $const = array_shift($allConstants); - $node->consts = [$const]; + /** @var Const_ $firstConst */ + $firstConst = array_shift($allConsts); + $node->consts = [$firstConst]; - foreach ($allConstants as $anotherConstant) { + foreach ($allConsts as $anotherConstant) { $nextClassConst = new ClassConst([$anotherConstant], $node->flags, $node->getAttributes()); $this->addNodeAfterNode($nextClassConst, $node); } @@ -92,9 +92,9 @@ PHP } $allProperties = $node->props; - /** @var PropertyProperty $propertyProperty */ - $propertyProperty = array_shift($allProperties); - $node->props = [$propertyProperty]; + /** @var PropertyProperty $firstPropertyProperty */ + $firstPropertyProperty = array_shift($allProperties); + $node->props = [$firstPropertyProperty]; foreach ($allProperties as $anotherProperty) { $nextProperty = new Property($node->flags, [$anotherProperty], $node->getAttributes()); diff --git a/rules/doctrine/src/Rector/Class_/ManagerRegistryGetManagerToEntityManagerRector.php b/rules/doctrine/src/Rector/Class_/ManagerRegistryGetManagerToEntityManagerRector.php index 126776332a4..67147c28c7d 100644 --- a/rules/doctrine/src/Rector/Class_/ManagerRegistryGetManagerToEntityManagerRector.php +++ b/rules/doctrine/src/Rector/Class_/ManagerRegistryGetManagerToEntityManagerRector.php @@ -102,8 +102,8 @@ PHP */ public function refactor(Node $node): ?Node { - $classMethod = $node->getMethod('__construct'); - if ($classMethod === null) { + $constructorClassMethod = $node->getMethod('__construct'); + if ($constructorClassMethod === null) { return null; } @@ -113,7 +113,7 @@ PHP return null; } - $managerRegistryParam = $this->resolveManagerRegistryParam($classMethod); + $managerRegistryParam = $this->resolveManagerRegistryParam($constructorClassMethod); // no registry manager in the constructor if ($managerRegistryParam === null) { @@ -122,7 +122,7 @@ PHP if ($registryCalledMethods === [self::GET_MANAGER]) { // the manager registry is needed only get entity manager → we don't need it now - $this->removeManagerRegistryDependency($node, $classMethod, $managerRegistryParam); + $this->removeManagerRegistryDependency($node, $constructorClassMethod, $managerRegistryParam); } $this->replaceEntityRegistryVariableWithEntityManagerProperty($node); @@ -131,7 +131,7 @@ PHP // add entity manager via constructor $this->addConstructorDependencyWithProperty( $node, - $classMethod, + $constructorClassMethod, self::ENTITY_MANAGER, new FullyQualifiedObjectType('Doctrine\ORM\EntityManagerInterface') ); diff --git a/rules/doctrine/src/Rector/MethodCall/ChangeSetIdToUuidValueRector.php b/rules/doctrine/src/Rector/MethodCall/ChangeSetIdToUuidValueRector.php index 752b8d3bb77..35a3d4d92e2 100644 --- a/rules/doctrine/src/Rector/MethodCall/ChangeSetIdToUuidValueRector.php +++ b/rules/doctrine/src/Rector/MethodCall/ChangeSetIdToUuidValueRector.php @@ -104,10 +104,10 @@ PHP } // A. try find "setUuid()" call on the same object later - $methodCall = $this->getSetUuidMethodCallOnSameVariable($node); - if ($methodCall !== null) { - $node->args = $methodCall->args; - $this->removeNode($methodCall); + $setUuidMethodCall = $this->getSetUuidMethodCallOnSameVariable($node); + if ($setUuidMethodCall !== null) { + $node->args = $setUuidMethodCall->args; + $this->removeNode($setUuidMethodCall); return $node; } diff --git a/rules/privatization/src/Rector/ClassConst/PrivatizeLocalClassConstantRector.php b/rules/privatization/src/Rector/ClassConst/PrivatizeLocalClassConstantRector.php index d1ffba410e7..63da80421fc 100644 --- a/rules/privatization/src/Rector/ClassConst/PrivatizeLocalClassConstantRector.php +++ b/rules/privatization/src/Rector/ClassConst/PrivatizeLocalClassConstantRector.php @@ -158,16 +158,16 @@ PHP private function findParentClassConstantAndRefactorIfPossible(string $class, string $constant): ?ConstantVisibility { - $classConst = $this->parentClassConstantNodeFinder->find($class, $constant); + $parentClassConst = $this->parentClassConstantNodeFinder->find($class, $constant); - if ($classConst !== null) { + if ($parentClassConst !== null) { // Make sure the parent's constant has been refactored - $this->refactor($classConst); + $this->refactor($parentClassConst); return new ConstantVisibility( - $classConst->isPublic(), - $classConst->isProtected(), - $classConst->isPrivate() + $parentClassConst->isPublic(), + $parentClassConst->isProtected(), + $parentClassConst->isPrivate() ); // If the constant isn't declared in the parent, it might be declared in the parent's parent } diff --git a/rules/psr4/tests/Rector/MultipleClassFileToPsr4ClassesRector/MultipleClassFileToPsr4ClassesRectorTest.php b/rules/psr4/tests/Rector/MultipleClassFileToPsr4ClassesRector/MultipleClassFileToPsr4ClassesRectorTest.php index 3600399bf82..d07c895497a 100644 --- a/rules/psr4/tests/Rector/MultipleClassFileToPsr4ClassesRector/MultipleClassFileToPsr4ClassesRectorTest.php +++ b/rules/psr4/tests/Rector/MultipleClassFileToPsr4ClassesRector/MultipleClassFileToPsr4ClassesRectorTest.php @@ -104,12 +104,12 @@ final class MultipleClassFileToPsr4ClassesRectorTest extends AbstractFileSystemR */ public function testSkip(SmartFileInfo $originalFile): void { - $contents = $originalFile->getContents(); + $originalContents = $originalFile->getContents(); $this->doTestFileInfo($originalFile); $this->assertFileExists($originalFile->getRealPath()); - $this->assertStringEqualsFile($originalFile->getRealPath(), $contents); + $this->assertStringEqualsFile($originalFile->getRealPath(), $originalContents); } public function provideDataForSkip(): Iterator diff --git a/rules/removing-static/src/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector.php b/rules/removing-static/src/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector.php index 2c6b60c42ad..f1880e565c7 100644 --- a/rules/removing-static/src/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector.php +++ b/rules/removing-static/src/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector.php @@ -208,7 +208,7 @@ PHP // add all properties to class $class = $this->addNewPropertiesToClass($class, $newProperties); - $expression = $this->createParentSetUpStaticCall(); + $parentSetUpStaticCallExpression = $this->createParentSetUpStaticCall(); foreach ($newProperties as $type) { // container fetch assign $assign = $this->createContainerGetTypeToPropertyAssign($type); @@ -217,9 +217,9 @@ PHP // get setup or create a setup add add it there if ($setupClassMethod !== null) { - $this->updateSetUpMethod($setupClassMethod, $expression, $assign); + $this->updateSetUpMethod($setupClassMethod, $parentSetUpStaticCallExpression, $assign); } else { - $setUpMethod = $this->createSetUpMethod($expression, $assign); + $setUpMethod = $this->createSetUpMethod($parentSetUpStaticCallExpression, $assign); $this->classInsertManipulator->addAsFirstMethod($class, $setUpMethod); } } diff --git a/rules/removing-static/src/UniqueObjectFactoryFactory.php b/rules/removing-static/src/UniqueObjectFactoryFactory.php index 7dc07c8a650..6ec10a2cd6a 100644 --- a/rules/removing-static/src/UniqueObjectFactoryFactory.php +++ b/rules/removing-static/src/UniqueObjectFactoryFactory.php @@ -80,8 +80,8 @@ final class UniqueObjectFactoryFactory $factoryClassBuilder->addStmts($properties); // constructor - $classMethod = $this->createConstructMethod($objectType); - $factoryClassBuilder->addStmt($classMethod); + $constructorClassMethod = $this->createConstructMethod($objectType); + $factoryClassBuilder->addStmt($constructorClassMethod); // create $createMethod = $this->createCreateMethod($class, $className, $properties); diff --git a/rules/solid/src/Rector/Class_/MultiParentingToAbstractDependencyRector.php b/rules/solid/src/Rector/Class_/MultiParentingToAbstractDependencyRector.php index f561939fa9e..d66d97d3d73 100644 --- a/rules/solid/src/Rector/Class_/MultiParentingToAbstractDependencyRector.php +++ b/rules/solid/src/Rector/Class_/MultiParentingToAbstractDependencyRector.php @@ -200,13 +200,13 @@ PHP */ private function resolveConstructorParamClassTypes(Class_ $class): array { - $classMethod = $class->getMethod(self::CONSTRUCTOR_METHOD_NAME); - if ($classMethod === null) { + $constructorClassMethod = $class->getMethod(self::CONSTRUCTOR_METHOD_NAME); + if ($constructorClassMethod === null) { return []; } $objectTypes = []; - foreach ($classMethod->getParams() as $param) { + foreach ($constructorClassMethod->getParams() as $param) { $paramType = $this->getObjectType($param); $paramType = $this->popFirstObjectTypeFromUnionType($paramType); diff --git a/rules/symfony-code-quality/src/Rector/Class_/EventListenerToEventSubscriberRector.php b/rules/symfony-code-quality/src/Rector/Class_/EventListenerToEventSubscriberRector.php index 31fa05dc059..a9881b8240a 100644 --- a/rules/symfony-code-quality/src/Rector/Class_/EventListenerToEventSubscriberRector.php +++ b/rules/symfony-code-quality/src/Rector/Class_/EventListenerToEventSubscriberRector.php @@ -240,11 +240,11 @@ PHP */ private function createGetSubscribedEventsClassMethod(array $eventsToMethods): ClassMethod { - $classMethod = $this->nodeFactory->createPublicMethod('getSubscribedEvents'); + $getSubscribersClassMethod = $this->nodeFactory->createPublicMethod('getSubscribedEvents'); $eventsToMethodsArray = new Array_(); - $this->makeStatic($classMethod); + $this->makeStatic($getSubscribersClassMethod); foreach ($eventsToMethods as $eventName => $methodNamesWithPriorities) { $eventNameExpr = $this->createEventName($eventName); @@ -261,10 +261,10 @@ PHP } } - $classMethod->stmts[] = new Return_($eventsToMethodsArray); - $this->decorateClassMethodWithReturnType($classMethod); + $getSubscribersClassMethod->stmts[] = new Return_($eventsToMethodsArray); + $this->decorateClassMethodWithReturnType($getSubscribersClassMethod); - return $classMethod; + return $getSubscribersClassMethod; } /** diff --git a/rules/symfony/src/Rector/MethodCall/FormTypeInstanceToClassConstRector.php b/rules/symfony/src/Rector/MethodCall/FormTypeInstanceToClassConstRector.php index b09d0228c50..11eff46933f 100644 --- a/rules/symfony/src/Rector/MethodCall/FormTypeInstanceToClassConstRector.php +++ b/rules/symfony/src/Rector/MethodCall/FormTypeInstanceToClassConstRector.php @@ -185,18 +185,18 @@ PHP return null; } - $classMethod = $formTypeClass->getMethod('__construct'); + $constructorClassMethod = $formTypeClass->getMethod('__construct'); // nothing we can do, out of scope - if ($classMethod === null) { + if ($constructorClassMethod === null) { return null; } - $this->addBuildFormMethod($formTypeClass, $classMethod); + $this->addBuildFormMethod($formTypeClass, $constructorClassMethod); $this->addConfigureOptionsMethod($formTypeClass, $namesToArgs); // remove ctor - $this->removeNode($classMethod); + $this->removeNode($constructorClassMethod); return $methodCall; } diff --git a/rules/symfony/src/Rector/MethodCall/ReadOnlyOptionToAttributeRector.php b/rules/symfony/src/Rector/MethodCall/ReadOnlyOptionToAttributeRector.php index 7701a2a0fb8..39b1203578b 100644 --- a/rules/symfony/src/Rector/MethodCall/ReadOnlyOptionToAttributeRector.php +++ b/rules/symfony/src/Rector/MethodCall/ReadOnlyOptionToAttributeRector.php @@ -77,15 +77,15 @@ PHP return null; } - $arrayItem = $this->arrayManipulator->findItemInInArrayByKeyAndUnset($optionsArray, 'read_only'); - if ($arrayItem === null) { + $readOnlyArrayItem = $this->arrayManipulator->findItemInInArrayByKeyAndUnset($optionsArray, 'read_only'); + if ($readOnlyArrayItem === null) { return null; } // rename string - $arrayItem->key = new String_('readonly'); + $readOnlyArrayItem->key = new String_('readonly'); - $this->arrayManipulator->addItemToArrayUnderKey($optionsArray, $arrayItem, 'attr'); + $this->arrayManipulator->addItemToArrayUnderKey($optionsArray, $readOnlyArrayItem, 'attr'); return $node; } diff --git a/rules/symfony/src/Rector/MethodCall/SimplifyWebTestCaseAssertionsRector.php b/rules/symfony/src/Rector/MethodCall/SimplifyWebTestCaseAssertionsRector.php index bb50b9e11ca..bca1da19bf7 100644 --- a/rules/symfony/src/Rector/MethodCall/SimplifyWebTestCaseAssertionsRector.php +++ b/rules/symfony/src/Rector/MethodCall/SimplifyWebTestCaseAssertionsRector.php @@ -98,8 +98,8 @@ PHP */ public function refactor(Node $node): ?Node { - $methodCall = $this->createMethodCall('client', 'getResponse'); - $this->getStatusCodeMethodCall = $this->createMethodCall($methodCall, 'getStatusCode'); + $clientGetResponseMethodCall = $this->createMethodCall('client', 'getResponse'); + $this->getStatusCodeMethodCall = $this->createMethodCall($clientGetResponseMethodCall, 'getStatusCode'); if (! $this->isInWebTestCase($node)) { return null;