From ddba23034c95b1f9b0094a8a601782250faa7d29 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 22 Sep 2019 13:39:33 +0200 Subject: [PATCH 1/4] [Refactoring] Add MoveAndRenameClassRector --- composer.json | 2 + config/services.yaml | 2 +- .../MoveServicesBySuffixToDirectoryRector.php | 4 +- .../src/Rector/AbstractFileSystemRector.php | 5 ++ packages/PSR4/src/FileRelocationResolver.php | 68 +++++++++++++++- .../PSR4/tests/FileRelocationResolverTest.php | 54 +++++++++++++ packages/PSR4/tests/Source/SomeFile.php | 8 ++ .../FileSystem/MoveAndRenameClassRector.php | 78 +++++++++++++++++++ phpstan.neon | 1 + rector.yaml | 5 +- .../RemovedAndAddedFilesCollector.php | 23 ++++++ .../RemovedAndAddedFilesProcessor.php | 29 +++++++ src/PhpParser/Node/BetterNodeFinder.php | 18 +++++ src/Rector/AbstractRector.php | 5 -- src/ValueObject/MovedClassValueObject.php | 43 ++++++++++ 15 files changed, 332 insertions(+), 13 deletions(-) create mode 100644 packages/PSR4/tests/FileRelocationResolverTest.php create mode 100644 packages/PSR4/tests/Source/SomeFile.php create mode 100644 packages/Refactoring/src/Rector/FileSystem/MoveAndRenameClassRector.php create mode 100644 src/ValueObject/MovedClassValueObject.php diff --git a/composer.json b/composer.json index 60a6901fda5d..7292a57c7a1b 100644 --- a/composer.json +++ b/composer.json @@ -74,6 +74,7 @@ "Rector\\Php\\": "packages/Php/src", "Rector\\RemovingStatic\\": "packages/RemovingStatic/src", "Rector\\Restoration\\": "packages/Restoration/src", + "Rector\\Refactoring\\": "packages/Refactoring/src", "Rector\\SOLID\\": "packages/SOLID/src", "Rector\\Sensio\\": "packages/Sensio/src", "Rector\\Shopware\\": "packages/Shopware/src", @@ -115,6 +116,7 @@ "Rector\\PHPStan\\Tests\\": "packages/PHPStan/tests", "Rector\\PHPUnitSymfony\\Tests\\": "packages/PHPUnitSymfony/tests", "Rector\\PHPUnit\\Tests\\": "packages/PHPUnit/tests", + "Rector\\PSR4\\Tests\\": "packages/PSR4/tests", "Rector\\PhpSpecToPHPUnit\\Tests\\": "packages/PhpSpecToPHPUnit/tests", "Rector\\Php\\Tests\\": "packages/Php/tests", "Rector\\RemovingStatic\\Tests\\": "packages/RemovingStatic/tests", diff --git a/config/services.yaml b/config/services.yaml index d47c1ebe7d48..ece1936cf098 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -5,7 +5,7 @@ services: Rector\: resource: '../src' - exclude: '../src/{Node/Attribute.php,Rector/**/*Rector.php,Reporting/FileDiff.php,Testing/PHPUnit,RectorDefinition,PhpParser/Node/*Info.php,Exception/*,DependencyInjection/CompilerPass/*,DependencyInjection/Loader/*,Application/Error.php,HttpKernel/RectorKernel.php}' + exclude: '../src/{Node/Attribute.php,Rector/**/*Rector.php,Reporting/FileDiff.php,Testing/PHPUnit,RectorDefinition,PhpParser/Node/*Info.php,Exception/*,DependencyInjection/CompilerPass/*,DependencyInjection/Loader/*,Application/Error.php,HttpKernel/RectorKernel.php,ValueObject/*}' # extra services Rector\Symfony\Rector\Form\Helper\FormTypeStringToTypeProvider: ~ diff --git a/packages/Autodiscovery/src/Rector/FileSystem/MoveServicesBySuffixToDirectoryRector.php b/packages/Autodiscovery/src/Rector/FileSystem/MoveServicesBySuffixToDirectoryRector.php index f4857a15057f..44971e520312 100644 --- a/packages/Autodiscovery/src/Rector/FileSystem/MoveServicesBySuffixToDirectoryRector.php +++ b/packages/Autodiscovery/src/Rector/FileSystem/MoveServicesBySuffixToDirectoryRector.php @@ -97,7 +97,7 @@ private function processGroupNamesBySuffix( continue; } - $this->moveFile($smartFileInfo, $nodes, $groupName); + $this->moveFileToGroupName($smartFileInfo, $nodes, $groupName); return; } } @@ -105,7 +105,7 @@ private function processGroupNamesBySuffix( /** * @param Node[] $nodes */ - private function moveFile(SmartFileInfo $smartFileInfo, array $nodes, string $desiredGroupName): void + private function moveFileToGroupName(SmartFileInfo $smartFileInfo, array $nodes, string $desiredGroupName): void { $nodesWithFileDestination = $this->fileMover->createMovedNodesAndFilePath( $smartFileInfo, diff --git a/packages/FileSystemRector/src/Rector/AbstractFileSystemRector.php b/packages/FileSystemRector/src/Rector/AbstractFileSystemRector.php index cb5d1fe76074..c667c639fc8a 100644 --- a/packages/FileSystemRector/src/Rector/AbstractFileSystemRector.php +++ b/packages/FileSystemRector/src/Rector/AbstractFileSystemRector.php @@ -164,6 +164,11 @@ protected function printNodesWithFileDestination( ); } + protected function moveFile(SmartFileInfo $oldFileInfo, string $newFileLocation, string $fileContent): void + { + $this->removedAndAddedFilesCollector->addMovedFile($oldFileInfo, $newFileLocation, $fileContent); + } + protected function removeFile(SmartFileInfo $smartFileInfo): void { $this->removedAndAddedFilesCollector->removeFile($smartFileInfo); diff --git a/packages/PSR4/src/FileRelocationResolver.php b/packages/PSR4/src/FileRelocationResolver.php index 9d74f3c426e9..b5d2952ba0ba 100644 --- a/packages/PSR4/src/FileRelocationResolver.php +++ b/packages/PSR4/src/FileRelocationResolver.php @@ -2,15 +2,18 @@ namespace Rector\PSR4; +use Nette\Utils\Strings; use PhpParser\Node\Name; use PhpParser\Node\Stmt\Namespace_; use Symplify\PackageBuilder\FileSystem\SmartFileInfo; -/** - * Will be used later - */ final class FileRelocationResolver { + /** + * @var string + */ + private const NAMESPACE_SEPARATOR = '\\'; + /** * @param string[] $groupNames */ @@ -33,7 +36,39 @@ public function resolveNewNamespaceName(Namespace_ $namespace, string $suffixNam $name = $namespace->name; $currentNamespaceParts = $name->parts; - return $this->resolveNearestRootWithCategory($currentNamespaceParts, $suffixName, '\\', $groupNames); + return $this->resolveNearestRootWithCategory( + $currentNamespaceParts, + $suffixName, + self::NAMESPACE_SEPARATOR, + $groupNames + ); + } + + public function resolveNewFileLocationFromOldClassToNewClass( + SmartFileInfo $oldSmartFileInfo, + string $oldClass, + string $newClass + ): string { + $beforeToAfterPart = $this->resolveBeforeToAfterPartBetweenClassNames($oldClass, $newClass); + + // A. first "dir has changed" dummy detection + $relativeFilePathParts = Strings::split( + $oldSmartFileInfo->getRelativeFilePath(), + '#' . DIRECTORY_SEPARATOR . '#' + ); + + foreach ($relativeFilePathParts as $key => $relativeFilePathPart) { + if (! isset($beforeToAfterPart[$relativeFilePathPart])) { + continue; + } + + $relativeFilePathParts[$key] = $beforeToAfterPart[$relativeFilePathPart]; + + // clear from further use + unset($beforeToAfterPart[$relativeFilePathPart]); + } + + return implode(DIRECTORY_SEPARATOR, $relativeFilePathParts); } /** @@ -92,4 +127,29 @@ private function resolveNearestRootWithCategory( return implode($separator, $rootNameParts); } + + /** + * @return string[] + */ + private function resolveBeforeToAfterPartBetweenClassNames(string $oldClass, string $newClass): array + { + $oldClassNameParts = explode(self::NAMESPACE_SEPARATOR, $oldClass); + $newClassNameParts = explode(self::NAMESPACE_SEPARATOR, $newClass); + + $beforeToAfterParts = []; + foreach ($oldClassNameParts as $key => $oldClassNamePart) { + if (! isset($newClassNameParts[$key])) { + continue; + } + + $newClassNamePart = $newClassNameParts[$key]; + if ($oldClassNamePart === $newClassNamePart) { + continue; + } + + $beforeToAfterParts[$oldClassNamePart] = $newClassNamePart; + } + + return $beforeToAfterParts; + } } diff --git a/packages/PSR4/tests/FileRelocationResolverTest.php b/packages/PSR4/tests/FileRelocationResolverTest.php new file mode 100644 index 000000000000..ac7b3d6e48a2 --- /dev/null +++ b/packages/PSR4/tests/FileRelocationResolverTest.php @@ -0,0 +1,54 @@ +bootKernel(RectorKernel::class); + + $this->fileRelocationResolver = self::$container->get(FileRelocationResolver::class); + } + + /** + * @dataProvider provideDataForTest() + */ + public function test(string $file, string $oldClass, string $newClass, string $expectedNewFileLocation): void + { + $smartFileInfo = new SmartFileInfo($file); + + $newFileLocation = $this->fileRelocationResolver->resolveNewFileLocationFromOldClassToNewClass( + $smartFileInfo, + $oldClass, + $newClass + ); + + $this->assertSame($expectedNewFileLocation, $newFileLocation); + } + + /** + * @return string[] + */ + public function provideDataForTest(): Iterator + { + yield [ + __DIR__ . '/Source/SomeFile.php', + SomeFile::class, + 'Rector\PSR10\Tests\Source\SomeFile', + 'packages/PSR10/tests/Source/SomeFile.php', + ]; + } +} diff --git a/packages/PSR4/tests/Source/SomeFile.php b/packages/PSR4/tests/Source/SomeFile.php new file mode 100644 index 000000000000..2db96953c69d --- /dev/null +++ b/packages/PSR4/tests/Source/SomeFile.php @@ -0,0 +1,8 @@ +fileRelocationResolver = $fileRelocationResolver; + $this->renamedClassesCollector = $renamedClassesCollector; + $this->oldClassToNewClass = $oldClassToNewClass; + } + + public function refactor(SmartFileInfo $smartFileInfo): void + { + $fileNodes = $this->parseFileInfoToNodes($smartFileInfo); + $fileContent = $smartFileInfo->getContents(); + + $class = $this->betterNodeFinder->findFirstClass($fileNodes); + if ($class === null) { + return; + } + + $className = $this->getName($class); + + /** @var string $oldClass */ + foreach ($this->oldClassToNewClass as $oldClass => $newClass) { + if ($className !== $oldClass) { + continue; + } + + $newFileLocation = $this->fileRelocationResolver->resolveNewFileLocationFromOldClassToNewClass( + $smartFileInfo, + $oldClass, + $newClass + ); + + // create helping rename class rector.yaml + class_alias autoload file + $this->renamedClassesCollector->addClassRename($oldClass, $newClass); + + $this->moveFile($smartFileInfo, $newFileLocation, $fileContent); + } + } + + public function getDefinition(): RectorDefinition + { + return new RectorDefinition( + 'Move class to respect new location with respect to PSR-4 + follow up with class rename' + ); + } +} diff --git a/phpstan.neon b/phpstan.neon index 9e761ab3e3bd..bb35367eb523 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -207,3 +207,4 @@ parameters: # bugs - '#In method "Rector\\FileSystemRector\\Rector\\AbstractFileSystemRector\:\:isDoctrineEntityClass", parameter \$class has no type\-hint and no @param annotation\. More info\: http\://bit\.ly/usetypehint#' - '#In method "Rector\\Rector\\AbstractRector\:\:isDoctrineEntityClass", parameter \$class has no type\-hint and no @param annotation\. More info\: http\://bit\.ly/usetypehint#' + - '#In method "Rector\\FileSystemRector\\Rector\\AbstractFileSystemRector\:\:moveFile", parameter \$nodes type is "array"\. Please provide a @param annotation to further specify the type of the array\. For instance\: @param int\[\] \$nodes\. More info\: http\://bit\.ly/typehintarray#' diff --git a/rector.yaml b/rector.yaml index e6372db50b5f..2cbd08589630 100644 --- a/rector.yaml +++ b/rector.yaml @@ -14,4 +14,7 @@ parameters: php_version_features: '7.1' services: - Rector\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector: ~ +# Rector\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector: ~ + Rector\Refactoring\Rector\FileSystem\MoveAndRenameClassRector: + $oldClassToNewClass: + Rector\Php\Rector\Assign\AssignArrayToStringRector: 'Rector\Php71\Rector\Assign\AssignArrayToStringRector' diff --git a/src/Application/FileSystem/RemovedAndAddedFilesCollector.php b/src/Application/FileSystem/RemovedAndAddedFilesCollector.php index 6e0f00b0931b..15e6a14c6acd 100644 --- a/src/Application/FileSystem/RemovedAndAddedFilesCollector.php +++ b/src/Application/FileSystem/RemovedAndAddedFilesCollector.php @@ -2,6 +2,7 @@ namespace Rector\Application\FileSystem; +use Rector\ValueObject\MovedClassValueObject; use Symplify\PackageBuilder\FileSystem\SmartFileInfo; final class RemovedAndAddedFilesCollector @@ -16,11 +17,25 @@ final class RemovedAndAddedFilesCollector */ private $addedFilesWithContent = []; + /** + * @var MovedClassValueObject[] + */ + private $movedFiles = []; + public function removeFile(SmartFileInfo $smartFileInfo): void { $this->removedFiles[$smartFileInfo->getRealPath()] = $smartFileInfo; } + public function addMovedFile(SmartFileInfo $oldFileInfo, string $newFileLocation, string $content): void + { + $this->movedFiles[] = new MovedClassValueObject( + $oldFileInfo->getRelativeFilePath(), + $newFileLocation, + $content + ); + } + /** * @return SmartFileInfo[] */ @@ -29,6 +44,14 @@ public function getRemovedFiles(): array return $this->removedFiles; } + /** + * @return MovedClassValueObject[] + */ + public function getMovedFiles(): array + { + return $this->movedFiles; + } + public function isFileRemoved(SmartFileInfo $smartFileInfo): bool { return isset($this->removedFiles[$smartFileInfo->getRealPath()]); diff --git a/src/Application/FileSystem/RemovedAndAddedFilesProcessor.php b/src/Application/FileSystem/RemovedAndAddedFilesProcessor.php index 7d2d322696bf..3e67990d72fa 100644 --- a/src/Application/FileSystem/RemovedAndAddedFilesProcessor.php +++ b/src/Application/FileSystem/RemovedAndAddedFilesProcessor.php @@ -3,6 +3,7 @@ namespace Rector\Application\FileSystem; use Rector\Configuration\Configuration; +use Rector\ValueObject\MovedClassValueObject; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Filesystem\Filesystem; @@ -47,6 +48,7 @@ public function run(): void { $this->processAddedFiles(); $this->processDeletedFiles(); + $this->processMovedFiles(); } private function processAddedFiles(): void @@ -74,4 +76,31 @@ private function processDeletedFiles(): void } } } + + private function processMovedFiles(): void + { + foreach ($this->removedAndAddedFilesCollector->getMovedFiles() as $movedClassValueObject) { + if ($this->configuration->isDryRun()) { + $this->printFileMoveWarning($movedClassValueObject, 'will be'); + } else { + $this->printFileMoveWarning($movedClassValueObject, 'was'); + + $this->filesystem->remove($movedClassValueObject->getOldPath()); + $this->filesystem->dumpFile( + $movedClassValueObject->getNewPath(), + $movedClassValueObject->getFileContent() + ); + } + } + } + + private function printFileMoveWarning(MovedClassValueObject $movedClassValueObject, string $verb): void + { + $this->symfonyStyle->warning(sprintf( + 'File "%s" %s moved to "%s"', + $movedClassValueObject->getOldPath(), + $verb, + $movedClassValueObject->getNewPath() + )); + } } diff --git a/src/PhpParser/Node/BetterNodeFinder.php b/src/PhpParser/Node/BetterNodeFinder.php index be9177de5b33..0621646a3bb4 100644 --- a/src/PhpParser/Node/BetterNodeFinder.php +++ b/src/PhpParser/Node/BetterNodeFinder.php @@ -179,6 +179,24 @@ public function findFirstPrevious(Node $node, callable $filter): ?Node return $this->findFirstPrevious($previousExpression, $filter); } + /** + * @param Node|Node[] $nodes + */ + public function findFirstClass($nodes): ?Class_ + { + /** @var Class_[] $classes */ + $classes = $this->findInstanceOf($nodes, Class_::class); + foreach ($classes as $class) { + if ($class->isAnonymous()) { + continue; + } + + return $class; + } + + return null; + } + /** * @param string[] $types */ diff --git a/src/Rector/AbstractRector.php b/src/Rector/AbstractRector.php index 021a91987e44..bc99b05c9bd7 100644 --- a/src/Rector/AbstractRector.php +++ b/src/Rector/AbstractRector.php @@ -142,11 +142,6 @@ protected function removeFile(SmartFileInfo $smartFileInfo): void $this->removedAndAddedFilesCollector->removeFile($smartFileInfo); } - protected function addFileWithContent(string $filePath, string $content): void - { - $this->removedAndAddedFilesCollector->addFileWithContent($filePath, $content); - } - protected function getNextExpression(Node $node): ?Node { $currentExpression = $node->getAttribute(AttributeKey::CURRENT_EXPRESSION); diff --git a/src/ValueObject/MovedClassValueObject.php b/src/ValueObject/MovedClassValueObject.php new file mode 100644 index 000000000000..d5cc29674934 --- /dev/null +++ b/src/ValueObject/MovedClassValueObject.php @@ -0,0 +1,43 @@ +oldPath = $oldPath; + $this->newPath = $newPath; + $this->fileContent = $fileContent; + } + + public function getOldPath(): string + { + return $this->oldPath; + } + + public function getNewPath(): string + { + return $this->newPath; + } + + public function getFileContent(): string + { + return $this->fileContent; + } +} From 3299c552297a8cb12323635b59743a306d2463f3 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 22 Sep 2019 20:48:53 +0200 Subject: [PATCH 2/4] prepare config --- config/set/php/php71.yaml | 3 +- rector.yaml | 75 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/config/set/php/php71.yaml b/config/set/php/php71.yaml index 1e23a2282238..801e7d8330d7 100644 --- a/config/set/php/php71.yaml +++ b/config/set/php/php71.yaml @@ -1,7 +1,8 @@ services: Rector\Php\Rector\BinaryOp\IsIterableRector: ~ Rector\Php\Rector\Name\ReservedObjectRector: - Object: 'BaseObject' + $reservedKeywordsToReplacements: + Object: 'BaseObject' Rector\Php\Rector\TryCatch\MultiExceptionCatchRector: ~ Rector\Php\Rector\Assign\AssignArrayToStringRector: ~ diff --git a/rector.yaml b/rector.yaml index 2cbd08589630..0d4868a31274 100644 --- a/rector.yaml +++ b/rector.yaml @@ -17,4 +17,79 @@ services: # Rector\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector: ~ Rector\Refactoring\Rector\FileSystem\MoveAndRenameClassRector: $oldClassToNewClass: + Rector\Php\Rector\Property\VarToPublicPropertyRector: 'Rector\Php52\Rector\Property\VarToPublicPropertyRector' + Rector\Php\Rector\Switch_\ContinueToBreakInSwitchRector: 'Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector' + + Rector\CodeQuality\Rector\Ternary\TernaryToElvisRector: 'Rector\Php53\Rector\Ternary\TernaryToElvisRector' + + Rector\Php\Rector\FuncCall\RemoveReferenceFromCallRector: 'Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector' + + Rector\Php\Rector\String_\StringClassNameToClassConstantRector: 'Rector\Php55\Rector\String_\StringClassNameToClassConstantRector' + + Rector\Php\Rector\FuncCall\PowToExpRector: 'Rector\Php56\Rector\FuncCall\PowToExpRector' + Rector\Php\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector: 'Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector' + + Rector\Php\Rector\FunctionLike\Php4ConstructorRector: 'Rector\Php70\Rector\FunctionLike\Php4ConstructorRector' + Rector\Php\Rector\Ternary\TernaryToNullCoalescingRector: 'Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector' + Rector\Php\Rector\FuncCall\RandomFunctionRector: 'Rector\Php70\Rector\FuncCall\RandomFunctionRector' + Rector\Php\Rector\FunctionLike\ExceptionHandlerTypehintRector: 'Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector' + Rector\Php\Rector\FuncCall\MultiDirnameRector: 'Rector\Php70\Rector\FuncCall\MultiDirnameRector' + Rector\Php\Rector\List_\ListSplitStringRector: 'Rector\Php70\Rector\List_\ListSplitStringRector' + Rector\Php\Rector\List_\EmptyListRector: 'Rector\Php70\Rector\List_\EmptyListRector' + + # be careful, run this just once, since it can keep swapping order back and forth + Rector\Php\Rector\List_\ListSwapArrayOrderRector: 'Rector\Php70\Rector\List_\ListSwapArrayOrderRector' + + Rector\Php\Rector\FuncCall\CallUserMethodRector: 'Rector\Php70\Rector\FuncCall\CallUserMethodRector' + Rector\Php\Rector\FuncCall\EregToPregMatchRector: 'Rector\Php70\Rector\FuncCall\EregToPregMatchRector' + Rector\Php\Rector\Switch_\ReduceMultipleDefaultSwitchRector: 'Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector' + Rector\Php\Rector\Ternary\TernaryToSpaceshipRector: 'Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector' + Rector\Php\Rector\If_\IfToSpaceshipRector: 'Rector\Php70\Rector\If_\IfToSpaceshipRector' + Rector\Php\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector: 'Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector' + Rector\Php\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector: 'Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector' + + Rector\Php\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector: 'Rector\Php70\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector' + Rector\Php\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector: 'Rector\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector' + + Rector\Php\Rector\BinaryOp\IsIterableRector: 'Rector\Php71\Rector\BinaryOp\IsIterableRector' + Rector\Php\Rector\TryCatch\MultiExceptionCatchRector: 'Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector' + Rector\Php\Rector\FuncCall\CountOnNullRector: 'Rector\Php71\Rector\FuncCall\CountOnNullRector' + Rector\Php\Rector\FuncCall\RemoveExtraParametersRector: 'Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector' + Rector\Php\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector: 'Rector\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector' Rector\Php\Rector\Assign\AssignArrayToStringRector: 'Rector\Php71\Rector\Assign\AssignArrayToStringRector' + + Rector\Php\Rector\Each\WhileEachToForeachRector: 'Rector\Php72\Rector\Each\WhileEachToForeachRector' + Rector\Php\Rector\Each\ListEachRector: 'Rector\Php72\Rector\Each\ListEachRector' + Rector\Php\Rector\Unset_\UnsetCastRector: 'Rector\Php72\Rector\Unset_\UnsetCastRector' + Rector\Php\Rector\ConstFetch\BarewordStringRector: 'Rector\Php72\Rector\ConstFetch\BarewordStringRector' + Rector\Php\Rector\FuncCall\GetClassOnNullRector: 'Rector\Php72\Rector\FuncCall\GetClassOnNullRector' + Rector\Php\Rector\FuncCall\IsObjectOnIncompleteClassRector: 'Rector\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector' + Rector\Php\Rector\FuncCall\ParseStrWithResultArgumentRector: 'Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector' + Rector\Php\Rector\FuncCall\StringsAssertNakedRector: 'Rector\Php72\Rector\FuncCall\StringsAssertNakedRector' + Rector\Php\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector: 'Rector\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector' + Rector\Php\Rector\FuncCall\StringifyDefineRector: 'Rector\Php72\Rector\FuncCall\StringifyDefineRector' + + Rector\Php\Rector\BinaryOp\IsCountableRector: 'Rector\Php73\Rector\BinaryOp\IsCountableRector' + Rector\Php\Rector\FuncCall\ArrayKeyFirstLastRector: 'Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector' + Rector\Php\Rector\FuncCall\SensitiveDefineRector: 'Rector\Php73\Rector\FuncCall\SensitiveDefineRector' + Rector\Php\Rector\ConstFetch\SensitiveConstantNameRector: 'Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector' + Rector\Php\Rector\String_\SensitiveHereNowDocRector: 'Rector\Php73\Rector\String_\SensitiveHereNowDocRector' + Rector\Php\Rector\FuncCall\StringifyStrNeedlesRector: 'Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector' + Rector\Php\Rector\FuncCall\JsonThrowOnErrorRector: 'Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector' + Rector\Php\Rector\FuncCall\RegexDashEscapeRector: 'Rector\Php73\Rector\FuncCall\RegexDashEscapeRector' + Rector\Php\Rector\FuncCall\RemoveMissingCompactVariableRector: 'Rector\Php73\Rector\FuncCall\RemoveMissingCompactVariableRector' + + Rector\Php\Rector\Property\TypedPropertyRector: 'Rector\Php74\Rector\Property\TypedPropertyRector' + Rector\Php\Rector\FuncCall\ArrayKeyExistsOnPropertyRector: 'Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector' + Rector\Php\Rector\FuncCall\FilterVarToAddSlashesRector: 'Rector\Php74\Rector\FuncCall\FilterVarToAddSlashesRector' + Rector\Php\Rector\StaticCall\ExportToReflectionFunctionRector: 'Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector' + Rector\Php\Rector\MagicConstClass\ClassConstantToSelfClassRector: 'Rector\Php74\Rector\MagicConstClass\ClassConstantToSelfClassRector' + Rector\Php\Rector\FuncCall\GetCalledClassToStaticClassRector: 'Rector\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector' + Rector\Php\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector: 'Rector\Php74\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector' + Rector\Php\Rector\Double\RealToFloatTypeCastRector: 'Rector\Php74\Rector\Double\RealToFloatTypeCastRector' + Rector\Php\Rector\Assign\NullCoalescingOperatorRector: 'Rector\Php74\Rector\Assign\NullCoalescingOperatorRector' + Rector\Php\Rector\Function_\ReservedFnFunctionRector: 'Rector\Php74\Rector\Function_\ReservedFnFunctionRector' + Rector\Php\Rector\Closure\ClosureToArrowFunctionRector: 'Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector' + Rector\Php\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector: 'Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector' + Rector\Php\Rector\LNumber\AddLiteralSeparatorToNumberRector: 'Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector' + From f5587336119772422b57c7c72478486c22a25089 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 22 Sep 2019 20:57:03 +0200 Subject: [PATCH 3/4] [PHP] Split huge package to php by version rules --- composer.json | 12 ++ config/set/php/php52.yaml | 4 +- config/set/php/php53.yaml | 2 +- config/set/php/php54.yaml | 3 +- config/set/php/php55.yaml | 2 +- config/set/php/php56.yaml | 4 +- config/set/php/php70.yaml | 34 ++-- config/set/php/php71.yaml | 13 +- config/set/php/php72.yaml | 20 +- config/set/php/php73.yaml | 18 +- config/set/php/php74.yaml | 26 +-- ecs.yaml | 8 +- .../SimplifyIfIssetToNullCoalescingRector.php | 1 - .../Fixture/fixture.php.inc | 4 + .../Fixture/fixture2.php.inc | 12 +- .../TernaryToElvisRectorTest.php | 2 +- .../RemoveOverriddenValuesRector.php | 2 - .../src/Rector/AbstractFileSystemRector.php | 15 +- .../src/NodeScopeAndMetadataDecorator.php | 15 +- .../ClassAndInterfaceTypeResolver.php | 6 +- .../NodeTypeResolver/src/StaticTypeMapper.php | 1 - packages/PSR4/src/FileRelocationResolver.php | 61 ++++-- .../Php/src/Exception/BreakScopeException.php | 9 - .../Assign/MysqlAssignToMysqliRector.php | 183 ------------------ .../Php/tests/EregToPcreTransformerTest.php | 4 +- .../AssignArrayToStringRectorTest.php | 4 +- .../Fixture/fixture.php.inc | 4 + .../Fixture/fixture6.php.inc | 4 + .../Fixture/fixture7.php.inc | 4 + .../{fixture9.php.inc => skip.php.inc} | 0 .../Fixture/fixture.php.inc | 4 + .../NullCoalescingOperatorRectorTest.php | 2 +- ...naryOpBetweenNumberAndStringRectorTest.php | 2 +- .../Fixture/fixture71.php.inc | 2 + .../Fixture/fixture73.php.inc | 6 +- .../Fixture/polyfill_function.php.inc | 4 +- .../IsCountableRectorTest.php | 2 +- .../IsCountableRector/PolyfillRectorTest.php | 2 +- .../IsIterableRector/IsIterableRectorTest.php | 2 +- .../IsIterableRector/PolyfillRectorTest.php | 2 +- ...eakNotInLoopOrSwitchToReturnRectorTest.php | 2 +- .../PublicConstantVisibilityRectorTest.php | 2 +- .../ClosureToArrowFunctionRectorTest.php | 2 +- .../BarewordStringRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 + .../SensitiveConstantNameRectorTest.php | 2 +- .../RealToFloatTypeCastRectorTest.php | 2 +- .../Php/tests/Rector/Each/EachRectorTest.php | 4 +- .../tests/Rector/Each/Fixture/fixture.php.inc | 4 + .../Rector/Each/Fixture/fixture2.php.inc | 4 + .../Rector/Each/Fixture/fixture3.php.inc | 4 + .../ArrayKeyExistsOnPropertyRectorTest.php | 2 +- .../ArrayKeyFirstLastRectorTest.php | 2 +- .../Fixture/array_key_first.php.inc | 4 + ...raySpreadInsteadOfArrayMergeRectorTest.php | 2 +- .../CallUserMethodRectorTest.php | 2 +- .../CountOnNullRectorTest.php | 2 +- .../CountOnNullRectorWithPHP73Test.php | 2 +- .../CountOnNullRector/Fixture/on_null.php.inc | 4 + ...eFunctionToAnonymousFunctionRectorTest.php | 2 +- .../EregToPregMatchRectorTest.php | 2 +- .../FilterVarToAddSlashesRectorTest.php | 2 +- .../GetCalledClassToStaticClassRectorTest.php | 2 +- .../GetClassOnNullRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 10 + .../IsObjectOnIncompleteClassRectorTest.php | 2 +- .../JsonThrowOnErrorRectorTest.php | 2 +- ...rposEncodingArgumentPositionRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 + .../Fixture/fixture2.php.inc | 4 + .../Fixture/fixture3.php.inc | 4 + .../MultiDirnameRectorTest.php | 2 +- .../ParseStrWithResultArgumentRectorTest.php | 2 +- .../PowToExpRector/Fixture/fixture.php.inc | 4 + .../PowToExpRector/PowToExpRectorTest.php | 2 +- .../RandomFunctionRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 + .../RegexDashEscapeRectorTest.php | 2 +- .../Fixture/external_scope.php.inc | 2 + .../Fixture/fixture.php.inc | 20 +- ...equired_and_one_optional_parameter.php.inc | 39 ++++ ...r_class_method_call_extra_argument.php.inc | 4 - .../RemoveExtraParametersRectorTest.php | 4 +- .../RemoveExtraParametersRector/config.yaml | 2 - ...RemoveMissingCompactVariableRectorTest.php | 2 +- .../RemoveReferenceFromCallRectorTest.php | 2 +- ...enameMktimeWithoutArgsToTimeRectorTest.php | 2 +- .../SensitiveDefineRectorTest.php | 2 +- .../StringifyDefineRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 + .../StringifyStrNeedlesRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 + .../StringsAssertNakedRectorTest.php | 2 +- ...ultValueForUndefinedVariableRectorTest.php | 2 +- .../ExceptionHandlerTypehintRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 6 +- .../Fixture/fixture_nullable.php.inc | 6 +- .../IfToSpaceshipRectorTest.php | 2 +- .../AddLiteralSeparatorToNumberRectorTest.php | 2 +- .../EmptyListRector/EmptyListRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 + .../ListSplitStringRectorTest.php | 2 +- .../ListSwapArrayOrderRectorTest.php | 2 +- .../ClassConstantToSelfClassRectorTest.php | 2 +- ...llOnStaticMethodToStaticCallRectorTest.php | 2 +- .../CompleteVarDocTypePropertyRectorTest.php | 2 +- .../Fixture/symfony_console_command.php.inc | 4 +- .../Fixture/typed_array.php.inc | 4 +- .../Fixture/typed_array_nested.php.inc | 4 +- .../TypedPropertyRectorTest.php | 2 +- .../VarToPublicPropertyRectorTest.php | 2 +- .../ExportToReflectionFunctionRectorTest.php | 2 +- ...allOnNonStaticToInstanceCallRectorTest.php | 2 +- .../SensitiveHereNowDocRectorTest.php | 2 +- ...ringClassNameToClassConstantRectorTest.php | 2 +- .../ContinueToBreakInSwitchRectorTest.php | 2 +- .../ReduceMultipleDefaultSwitchRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 + .../Fixture/fixture2.php.inc | 4 + .../Fixture/fixture3.php.inc | 4 + .../Fixture/fixture4.php.inc | 4 + .../TernaryToNullCoalescingRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 + .../TernaryToSpaceshipRectorTest.php | 2 +- .../MultiExceptionCatchRectorTest.php | 2 +- .../UnsetCastRector/Fixture/fixture.php.inc | 4 + .../UnsetCastRector/UnsetCastRectorTest.php | 2 +- .../Property/VarToPublicPropertyRector.php | 2 +- .../Switch_/ContinueToBreakInSwitchRector.php | 2 +- .../Rector/Ternary/TernaryToElvisRector.php | 2 +- .../RemoveReferenceFromCallRector.php | 2 +- .../StringClassNameToClassConstantRector.php | 2 +- .../src/Rector/FuncCall/PowToExpRector.php | 2 +- ...DefaultValueForUndefinedVariableRector.php | 2 +- .../BreakNotInLoopOrSwitchToReturnRector.php | 2 +- .../Rector/FuncCall/CallUserMethodRector.php | 2 +- .../Rector/FuncCall/EregToPregMatchRector.php | 2 +- .../Rector/FuncCall/MultiDirnameRector.php | 2 +- .../Rector/FuncCall/RandomFunctionRector.php | 2 +- .../RenameMktimeWithoutArgsToTimeRector.php | 2 +- .../ExceptionHandlerTypehintRector.php | 5 +- .../FunctionLike/Php4ConstructorRector.php | 2 +- .../src/Rector/If_/IfToSpaceshipRector.php | 2 +- .../src/Rector/List_/EmptyListRector.php | 2 +- .../Rector/List_/ListSplitStringRector.php | 2 +- .../Rector/List_/ListSwapArrayOrderRector.php | 2 +- ...isCallOnStaticMethodToStaticCallRector.php | 2 +- ...ticCallOnNonStaticToInstanceCallRector.php | 2 +- .../ReduceMultipleDefaultSwitchRector.php | 2 +- .../Ternary/TernaryToNullCoalescingRector.php | 2 +- .../Ternary/TernaryToSpaceshipRector.php | 2 +- .../Fixture/delegating.php.inc | 0 .../Fixture/delegating_2.php.inc | 0 .../Fixture/fixture.php.inc | 0 .../Fixture/fixture5.php.inc | 0 .../Fixture/in_namespace.php.inc | 2 +- .../Fixture/non_expression.php.inc | 0 .../Php4ConstructorRectorTest.php | 4 +- .../Assign/AssignArrayToStringRector.php | 11 +- .../BinaryOpBetweenNumberAndStringRector.php | 2 +- .../src/Rector/BinaryOp/IsIterableRector.php | 2 +- .../PublicConstantVisibilityRector.php | 4 +- .../src/Rector/FuncCall/CountOnNullRector.php | 2 +- .../FuncCall/RemoveExtraParametersRector.php | 2 +- .../TryCatch/MultiExceptionCatchRector.php | 2 +- .../ConstFetch/BarewordStringRector.php | 2 +- .../src/Rector/Each/ListEachRector.php | 2 +- .../Rector/Each/WhileEachToForeachRector.php | 2 +- ...reateFunctionToAnonymousFunctionRector.php | 2 +- .../Rector/FuncCall/GetClassOnNullRector.php | 2 +- .../IsObjectOnIncompleteClassRector.php | 2 +- .../ParseStrWithResultArgumentRector.php | 2 +- .../Rector/FuncCall/StringifyDefineRector.php | 2 +- .../FuncCall/StringsAssertNakedRector.php | 2 +- .../src/Rector/Unset_/UnsetCastRector.php | 2 +- .../src/Rector/BinaryOp/IsCountableRector.php | 2 +- .../SensitiveConstantNameRector.php | 2 +- .../FuncCall/ArrayKeyFirstLastRector.php | 2 +- .../FuncCall/JsonThrowOnErrorRector.php | 2 +- .../Rector/FuncCall/RegexDashEscapeRector.php | 2 +- .../RemoveMissingCompactVariableRector.php | 2 +- .../Rector/FuncCall/SensitiveDefineRector.php | 2 +- .../FuncCall/StringifyStrNeedlesRector.php | 2 +- .../String_/SensitiveHereNowDocRector.php | 2 +- .../Assign/NullCoalescingOperatorRector.php | 2 +- .../Closure/ClosureToArrowFunctionRector.php | 2 +- .../Double/RealToFloatTypeCastRector.php | 4 +- .../ArrayKeyExistsOnPropertyRector.php | 2 +- .../ArraySpreadInsteadOfArrayMergeRector.php | 2 +- .../FuncCall/FilterVarToAddSlashesRector.php | 2 +- .../GetCalledClassToStaticClassRector.php | 2 +- ...bStrrposEncodingArgumentPositionRector.php | 2 +- .../Function_/ReservedFnFunctionRector.php | 2 +- .../AddLiteralSeparatorToNumberRector.php | 2 +- .../ClassConstantToSelfClassRector.php | 2 +- .../Rector/Property/TypedPropertyRector.php | 2 +- .../ExportToReflectionFunctionRector.php | 2 +- .../Fixture/fixture.php.inc | 0 .../ReservedFnFunctionRectorTest.php | 4 +- .../MoveAndRenameNamespaceRector.php | 89 +++++++++ packages/SymfonyPHPUnit/config/config.yaml | 1 + .../AbstractTypeDeclarationRector.php | 1 - .../CompleteVarDocTypePropertyRector.php | 2 +- .../Fixture/dunglas/Foo.php.inc | 45 ----- .../ParamTypeDeclarationRectorTest.php | 1 - rector.yaml | 154 +++++++-------- .../RemovedAndAddedFilesCollector.php | 5 +- src/Configuration/Configuration.php | 20 ++ src/Console/Command/ProcessCommand.php | 9 + src/Exception/ShouldNotHappenException.php | 4 +- src/Guard/RectorGuard.php | 2 +- src/Naming/NamespaceMatcher.php | 26 +++ .../NodeTraverser/RectorNodeTraverser.php | 10 +- src/Rector/AbstractRector.php | 3 + src/Rector/Class_/RenameClassRector.php | 4 +- .../Namespace_/RenameNamespaceRector.php | 71 +++---- .../RenamedNamespaceValueObject.php | 43 ++++ .../Fixture/fixture3.php.inc | 11 -- .../GetAndSetToMethodCallRectorTest.php | 5 - .../Fixture/fixture.php.inc | 10 +- .../Fixture/fixture2.php.inc | 41 ---- .../Fixture/fixture3.php.inc | 29 --- .../Fixture/skip.php.inc | 18 ++ .../ReturnThisRemoveRectorTest.php | 7 +- 224 files changed, 814 insertions(+), 751 deletions(-) delete mode 100644 packages/Php/src/Exception/BreakScopeException.php delete mode 100644 packages/Php/src/Rector/Assign/MysqlAssignToMysqliRector.php rename packages/Php/tests/Rector/Assign/AssignArrayToStringRector/Fixture/{fixture9.php.inc => skip.php.inc} (100%) create mode 100644 packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/function_with_one_required_and_one_optional_parameter.php.inc delete mode 100644 packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/config.yaml rename packages/{Php => Php52}/src/Rector/Property/VarToPublicPropertyRector.php (96%) rename packages/{Php => Php52}/src/Rector/Switch_/ContinueToBreakInSwitchRector.php (97%) rename packages/{CodeQuality => Php53}/src/Rector/Ternary/TernaryToElvisRector.php (96%) rename packages/{Php => Php54}/src/Rector/FuncCall/RemoveReferenceFromCallRector.php (96%) rename packages/{Php => Php55}/src/Rector/String_/StringClassNameToClassConstantRector.php (98%) rename packages/{Php => Php56}/src/Rector/FuncCall/PowToExpRector.php (96%) rename packages/{Php => Php56}/src/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector.php (99%) rename packages/{Php => Php70}/src/Rector/Break_/BreakNotInLoopOrSwitchToReturnRector.php (98%) rename packages/{Php => Php70}/src/Rector/FuncCall/CallUserMethodRector.php (97%) rename packages/{Php => Php70}/src/Rector/FuncCall/EregToPregMatchRector.php (99%) rename packages/{Php => Php70}/src/Rector/FuncCall/MultiDirnameRector.php (98%) rename packages/{Php => Php70}/src/Rector/FuncCall/RandomFunctionRector.php (97%) rename packages/{Php => Php70}/src/Rector/FuncCall/RenameMktimeWithoutArgsToTimeRector.php (97%) rename packages/{Php => Php70}/src/Rector/FunctionLike/ExceptionHandlerTypehintRector.php (95%) rename packages/{Php => Php70}/src/Rector/FunctionLike/Php4ConstructorRector.php (99%) rename packages/{Php => Php70}/src/Rector/If_/IfToSpaceshipRector.php (99%) rename packages/{Php => Php70}/src/Rector/List_/EmptyListRector.php (97%) rename packages/{Php => Php70}/src/Rector/List_/ListSplitStringRector.php (97%) rename packages/{Php => Php70}/src/Rector/List_/ListSwapArrayOrderRector.php (98%) rename packages/{Php => Php70}/src/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector.php (98%) rename packages/{Php => Php70}/src/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php (98%) rename packages/{Php => Php70}/src/Rector/Switch_/ReduceMultipleDefaultSwitchRector.php (98%) rename packages/{Php => Php70}/src/Rector/Ternary/TernaryToNullCoalescingRector.php (98%) rename packages/{Php => Php70}/src/Rector/Ternary/TernaryToSpaceshipRector.php (98%) rename packages/{Php => Php70}/tests/Rector/FunctionLike/Php4ConstructorRector/Fixture/delegating.php.inc (100%) rename packages/{Php => Php70}/tests/Rector/FunctionLike/Php4ConstructorRector/Fixture/delegating_2.php.inc (100%) rename packages/{Php => Php70}/tests/Rector/FunctionLike/Php4ConstructorRector/Fixture/fixture.php.inc (100%) rename packages/{Php => Php70}/tests/Rector/FunctionLike/Php4ConstructorRector/Fixture/fixture5.php.inc (100%) rename packages/{Php => Php70}/tests/Rector/FunctionLike/Php4ConstructorRector/Fixture/in_namespace.php.inc (64%) rename packages/{Php => Php70}/tests/Rector/FunctionLike/Php4ConstructorRector/Fixture/non_expression.php.inc (100%) rename packages/{Php => Php70}/tests/Rector/FunctionLike/Php4ConstructorRector/Php4ConstructorRectorTest.php (88%) rename packages/{Php => Php71}/src/Rector/Assign/AssignArrayToStringRector.php (95%) rename packages/{Php => Php71}/src/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector.php (97%) rename packages/{Php => Php71}/src/Rector/BinaryOp/IsIterableRector.php (97%) rename packages/{Php => Php71}/src/Rector/ClassConst/PublicConstantVisibilityRector.php (92%) rename packages/{Php => Php71}/src/Rector/FuncCall/CountOnNullRector.php (98%) rename packages/{Php => Php71}/src/Rector/FuncCall/RemoveExtraParametersRector.php (99%) rename packages/{Php => Php71}/src/Rector/TryCatch/MultiExceptionCatchRector.php (98%) rename packages/{Php => Php72}/src/Rector/ConstFetch/BarewordStringRector.php (98%) rename packages/{Php => Php72}/src/Rector/Each/ListEachRector.php (99%) rename packages/{Php => Php72}/src/Rector/Each/WhileEachToForeachRector.php (98%) rename packages/{Php => Php72}/src/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector.php (99%) rename packages/{Php => Php72}/src/Rector/FuncCall/GetClassOnNullRector.php (99%) rename packages/{Php => Php72}/src/Rector/FuncCall/IsObjectOnIncompleteClassRector.php (98%) rename packages/{Php => Php72}/src/Rector/FuncCall/ParseStrWithResultArgumentRector.php (98%) rename packages/{Php => Php72}/src/Rector/FuncCall/StringifyDefineRector.php (97%) rename packages/{Php => Php72}/src/Rector/FuncCall/StringsAssertNakedRector.php (98%) rename packages/{Php => Php72}/src/Rector/Unset_/UnsetCastRector.php (96%) rename packages/{Php => Php73}/src/Rector/BinaryOp/IsCountableRector.php (97%) rename packages/{Php => Php73}/src/Rector/ConstFetch/SensitiveConstantNameRector.php (98%) rename packages/{Php => Php73}/src/Rector/FuncCall/ArrayKeyFirstLastRector.php (98%) rename packages/{Php => Php73}/src/Rector/FuncCall/JsonThrowOnErrorRector.php (98%) rename packages/{Php => Php73}/src/Rector/FuncCall/RegexDashEscapeRector.php (98%) rename packages/{Php => Php73}/src/Rector/FuncCall/RemoveMissingCompactVariableRector.php (97%) rename packages/{Php => Php73}/src/Rector/FuncCall/SensitiveDefineRector.php (96%) rename packages/{Php => Php73}/src/Rector/FuncCall/StringifyStrNeedlesRector.php (98%) rename packages/{Php => Php73}/src/Rector/String_/SensitiveHereNowDocRector.php (98%) rename packages/{Php => Php74}/src/Rector/Assign/NullCoalescingOperatorRector.php (97%) rename packages/{Php => Php74}/src/Rector/Closure/ClosureToArrowFunctionRector.php (98%) rename packages/{Php => Php74}/src/Rector/Double/RealToFloatTypeCastRector.php (95%) rename packages/{Php => Php74}/src/Rector/FuncCall/ArrayKeyExistsOnPropertyRector.php (97%) rename packages/{Php => Php74}/src/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php (99%) rename packages/{Php => Php74}/src/Rector/FuncCall/FilterVarToAddSlashesRector.php (97%) rename packages/{Php => Php74}/src/Rector/FuncCall/GetCalledClassToStaticClassRector.php (97%) rename packages/{Php => Php74}/src/Rector/FuncCall/MbStrrposEncodingArgumentPositionRector.php (97%) rename packages/{Php => Php74}/src/Rector/Function_/ReservedFnFunctionRector.php (97%) rename packages/{Php => Php74}/src/Rector/LNumber/AddLiteralSeparatorToNumberRector.php (98%) rename packages/{Php => Php74}/src/Rector/MagicConstClass/ClassConstantToSelfClassRector.php (96%) rename packages/{Php => Php74}/src/Rector/Property/TypedPropertyRector.php (98%) rename packages/{Php => Php74}/src/Rector/StaticCall/ExportToReflectionFunctionRector.php (97%) rename packages/{Php => Php74}/tests/Rector/Function_/ReservedFnFunctionRector/Fixture/fixture.php.inc (100%) rename packages/{Php => Php74}/tests/Rector/Function_/ReservedFnFunctionRector/ReservedFnFunctionRectorTest.php (84%) create mode 100644 packages/Refactoring/src/Rector/FileSystem/MoveAndRenameNamespaceRector.php rename packages/{Php => TypeDeclaration}/src/Rector/Property/CompleteVarDocTypePropertyRector.php (97%) delete mode 100644 packages/TypeDeclaration/tests/Rector/FunctionLike/ParamTypeDeclarationRector/Fixture/dunglas/Foo.php.inc create mode 100644 src/Naming/NamespaceMatcher.php create mode 100644 src/ValueObject/RenamedNamespaceValueObject.php delete mode 100644 tests/Rector/MagicDisclosure/GetAndSetToMethodCallRector/Fixture/fixture3.php.inc delete mode 100644 tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture/fixture2.php.inc delete mode 100644 tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture/fixture3.php.inc create mode 100644 tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture/skip.php.inc diff --git a/composer.json b/composer.json index 7292a57c7a1b..98661d695576 100644 --- a/composer.json +++ b/composer.json @@ -72,6 +72,16 @@ "Rector\\PSR4\\": "packages/PSR4/src", "Rector\\PhpSpecToPHPUnit\\": "packages/PhpSpecToPHPUnit/src", "Rector\\Php\\": "packages/Php/src", + "Rector\\Php52\\": "packages/Php52/src", + "Rector\\Php53\\": "packages/Php53/src", + "Rector\\Php54\\": "packages/Php54/src", + "Rector\\Php55\\": "packages/Php55/src", + "Rector\\Php56\\": "packages/Php56/src", + "Rector\\Php70\\": "packages/Php70/src", + "Rector\\Php71\\": "packages/Php71/src", + "Rector\\Php72\\": "packages/Php72/src", + "Rector\\Php73\\": "packages/Php73/src", + "Rector\\Php74\\": "packages/Php74/src", "Rector\\RemovingStatic\\": "packages/RemovingStatic/src", "Rector\\Restoration\\": "packages/Restoration/src", "Rector\\Refactoring\\": "packages/Refactoring/src", @@ -119,6 +129,8 @@ "Rector\\PSR4\\Tests\\": "packages/PSR4/tests", "Rector\\PhpSpecToPHPUnit\\Tests\\": "packages/PhpSpecToPHPUnit/tests", "Rector\\Php\\Tests\\": "packages/Php/tests", + "Rector\\Php70\\Tests\\": "packages/Php70/tests", + "Rector\\Php74\\Tests\\": "packages/Php74/tests", "Rector\\RemovingStatic\\Tests\\": "packages/RemovingStatic/tests", "Rector\\Restoration\\Tests\\": "packages/Restoration/tests", "Rector\\SOLID\\Tests\\": "packages/SOLID/tests", diff --git a/config/set/php/php52.yaml b/config/set/php/php52.yaml index 9372b6b2b2af..21c8c709243d 100644 --- a/config/set/php/php52.yaml +++ b/config/set/php/php52.yaml @@ -1,3 +1,3 @@ services: - Rector\Php\Rector\Property\VarToPublicPropertyRector: ~ - Rector\Php\Rector\Switch_\ContinueToBreakInSwitchRector: ~ + Rector\Php52\Rector\Property\VarToPublicPropertyRector: ~ + Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector: ~ diff --git a/config/set/php/php53.yaml b/config/set/php/php53.yaml index 8383dffda1ae..a57e8942902f 100644 --- a/config/set/php/php53.yaml +++ b/config/set/php/php53.yaml @@ -1,2 +1,2 @@ services: - Rector\CodeQuality\Rector\Ternary\TernaryToElvisRector: ~ + Rector\Php53\Rector\Ternary\TernaryToElvisRector: ~ diff --git a/config/set/php/php54.yaml b/config/set/php/php54.yaml index 46e39fbd925d..bd34a5875523 100644 --- a/config/set/php/php54.yaml +++ b/config/set/php/php54.yaml @@ -1,4 +1,5 @@ services: Rector\Rector\Function_\RenameFunctionRector: mysqli_param_count: 'mysqli_stmt_param_count' - Rector\Php\Rector\FuncCall\RemoveReferenceFromCallRector: ~ + + Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector: ~ diff --git a/config/set/php/php55.yaml b/config/set/php/php55.yaml index 7f5e79d18220..fd57921cf8d3 100644 --- a/config/set/php/php55.yaml +++ b/config/set/php/php55.yaml @@ -1,2 +1,2 @@ services: - Rector\Php\Rector\String_\StringClassNameToClassConstantRector: ~ + Rector\Php55\Rector\String_\StringClassNameToClassConstantRector: ~ diff --git a/config/set/php/php56.yaml b/config/set/php/php56.yaml index b1cc88198921..614e8beb42be 100644 --- a/config/set/php/php56.yaml +++ b/config/set/php/php56.yaml @@ -1,5 +1,5 @@ services: - Rector\Php\Rector\FuncCall\PowToExpRector: ~ + Rector\Php56\Rector\FuncCall\PowToExpRector: ~ Rector\Rector\Function_\RenameFunctionRector: mcrypt_generic_end: 'mcrypt_generic_deinit' @@ -39,4 +39,4 @@ services: ocistatementtype: 'oci_statement_type' # inspired by level in psalm - https://github.com/vimeo/psalm/blob/82e0bcafac723fdf5007a31a7ae74af1736c9f6f/tests/FileManipulationTest.php#L1063 - Rector\Php\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector: ~ + Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector: ~ diff --git a/config/set/php/php70.yaml b/config/set/php/php70.yaml index 7de8949bdcf0..64871442688f 100644 --- a/config/set/php/php70.yaml +++ b/config/set/php/php70.yaml @@ -2,24 +2,24 @@ imports: - { resource: "../database-migration/mysql-to-mysqli.yaml" } services: - Rector\Php\Rector\FunctionLike\Php4ConstructorRector: ~ - Rector\Php\Rector\Ternary\TernaryToNullCoalescingRector: ~ - Rector\Php\Rector\FuncCall\RandomFunctionRector: ~ - Rector\Php\Rector\FunctionLike\ExceptionHandlerTypehintRector: ~ - Rector\Php\Rector\FuncCall\MultiDirnameRector: ~ - Rector\Php\Rector\List_\ListSplitStringRector: ~ - Rector\Php\Rector\List_\EmptyListRector: ~ + Rector\Php70\Rector\FunctionLike\Php4ConstructorRector: ~ + Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector: ~ + Rector\Php70\Rector\FuncCall\RandomFunctionRector: ~ + Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector: ~ + Rector\Php70\Rector\FuncCall\MultiDirnameRector: ~ + Rector\Php70\Rector\List_\ListSplitStringRector: ~ + Rector\Php70\Rector\List_\EmptyListRector: ~ # be careful, run this just once, since it can keep swapping order back and forth - Rector\Php\Rector\List_\ListSwapArrayOrderRector: ~ + Rector\Php70\Rector\List_\ListSwapArrayOrderRector: ~ - Rector\Php\Rector\FuncCall\CallUserMethodRector : ~ - Rector\Php\Rector\FuncCall\EregToPregMatchRector: ~ - Rector\Php\Rector\Switch_\ReduceMultipleDefaultSwitchRector: ~ - Rector\Php\Rector\Ternary\TernaryToSpaceshipRector: ~ - Rector\Php\Rector\If_\IfToSpaceshipRector: ~ - Rector\Php\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector: ~ - Rector\Php\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector: ~ + Rector\Php70\Rector\FuncCall\CallUserMethodRector : ~ + Rector\Php70\Rector\FuncCall\EregToPregMatchRector: ~ + Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector: ~ + Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector: ~ + Rector\Php70\Rector\If_\IfToSpaceshipRector: ~ + Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector: ~ + Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector: ~ - Rector\Php\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector: ~ - Rector\Php\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector: ~ + Rector\Php70\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector: ~ + Rector\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector: ~ diff --git a/config/set/php/php71.yaml b/config/set/php/php71.yaml index 801e7d8330d7..811d4cb7a341 100644 --- a/config/set/php/php71.yaml +++ b/config/set/php/php71.yaml @@ -1,11 +1,12 @@ services: - Rector\Php\Rector\BinaryOp\IsIterableRector: ~ + Rector\Php71\Rector\BinaryOp\IsIterableRector: ~ + Rector\Php\Rector\Name\ReservedObjectRector: $reservedKeywordsToReplacements: Object: 'BaseObject' - Rector\Php\Rector\TryCatch\MultiExceptionCatchRector: ~ - Rector\Php\Rector\Assign\AssignArrayToStringRector: ~ - Rector\Php\Rector\FuncCall\CountOnNullRector: ~ - Rector\Php\Rector\FuncCall\RemoveExtraParametersRector: ~ - Rector\Php\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector: ~ + Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector: ~ + Rector\Php71\Rector\Assign\AssignArrayToStringRector: ~ + Rector\Php71\Rector\FuncCall\CountOnNullRector: ~ + Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector: ~ + Rector\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector: ~ diff --git a/config/set/php/php72.yaml b/config/set/php/php72.yaml index 19d640427867..4994686c3c5d 100644 --- a/config/set/php/php72.yaml +++ b/config/set/php/php72.yaml @@ -3,10 +3,10 @@ parameters: enable_object_type: true services: - Rector\Php\Rector\Each\WhileEachToForeachRector: ~ - Rector\Php\Rector\Each\ListEachRector: ~ - Rector\Php\Rector\Unset_\UnsetCastRector: ~ - Rector\Php\Rector\ConstFetch\BarewordStringRector: ~ + Rector\Php72\Rector\Each\WhileEachToForeachRector: ~ + Rector\Php72\Rector\Each\ListEachRector: ~ + Rector\Php72\Rector\Unset_\UnsetCastRector: ~ + Rector\Php72\Rector\ConstFetch\BarewordStringRector: ~ Rector\Rector\Function_\RenameFunctionRector: jpeg2wbmp: 'imagecreatefromjpeg' # and imagewbmp @@ -15,9 +15,9 @@ services: gmp_random: 'gmp_random_bits' # or gmp_random_range read_exif_data: 'exif_read_data' - Rector\Php\Rector\FuncCall\GetClassOnNullRector: ~ - Rector\Php\Rector\FuncCall\IsObjectOnIncompleteClassRector: ~ - Rector\Php\Rector\FuncCall\ParseStrWithResultArgumentRector: ~ - Rector\Php\Rector\FuncCall\StringsAssertNakedRector: ~ - Rector\Php\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector: ~ - Rector\Php\Rector\FuncCall\StringifyDefineRector: ~ + Rector\Php72\Rector\FuncCall\GetClassOnNullRector: ~ + Rector\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector: ~ + Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector: ~ + Rector\Php72\Rector\FuncCall\StringsAssertNakedRector: ~ + Rector\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector: ~ + Rector\Php72\Rector\FuncCall\StringifyDefineRector: ~ diff --git a/config/set/php/php73.yaml b/config/set/php/php73.yaml index 25783f28f3e4..b72207b5bfaa 100644 --- a/config/set/php/php73.yaml +++ b/config/set/php/php73.yaml @@ -1,9 +1,9 @@ services: - Rector\Php\Rector\BinaryOp\IsCountableRector: ~ - Rector\Php\Rector\FuncCall\ArrayKeyFirstLastRector: ~ - Rector\Php\Rector\FuncCall\SensitiveDefineRector: ~ - Rector\Php\Rector\ConstFetch\SensitiveConstantNameRector: ~ - Rector\Php\Rector\String_\SensitiveHereNowDocRector: ~ + Rector\Php73\Rector\BinaryOp\IsCountableRector: ~ + Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector: ~ + Rector\Php73\Rector\FuncCall\SensitiveDefineRector: ~ + Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector: ~ + Rector\Php73\Rector\String_\SensitiveHereNowDocRector: ~ # https://wiki.php.net/rfc/deprecations_php_7_3 Rector\Rector\Function_\RenameFunctionRector: @@ -22,7 +22,7 @@ services: mbereg_search_getregs: 'mb_ereg_search_getregs' mbereg_search_getpos: 'mb_ereg_search_getpos' - Rector\Php\Rector\FuncCall\StringifyStrNeedlesRector: ~ - Rector\Php\Rector\FuncCall\JsonThrowOnErrorRector: ~ - Rector\Php\Rector\FuncCall\RegexDashEscapeRector: ~ - Rector\Php\Rector\FuncCall\RemoveMissingCompactVariableRector: ~ + Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector: ~ + Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector: ~ + Rector\Php73\Rector\FuncCall\RegexDashEscapeRector: ~ + Rector\Php73\Rector\FuncCall\RemoveMissingCompactVariableRector: ~ diff --git a/config/set/php/php74.yaml b/config/set/php/php74.yaml index cb39f9b98eed..d97fa7548ff4 100644 --- a/config/set/php/php74.yaml +++ b/config/set/php/php74.yaml @@ -1,5 +1,5 @@ services: - Rector\Php\Rector\Property\TypedPropertyRector: ~ + Rector\Php74\Rector\Property\TypedPropertyRector: ~ Rector\Rector\Function_\RenameFunctionRector: # https://wiki.php.net/rfc/deprecations_php_7_4#the_real_type @@ -7,15 +7,15 @@ services: # https://wiki.php.net/rfc/deprecations_php_7_4#apache_request_headers_function apache_request_headers: 'getallheaders' hebrevc: ['nl2br', 'hebrev'] - Rector\Php\Rector\FuncCall\ArrayKeyExistsOnPropertyRector: ~ - Rector\Php\Rector\FuncCall\FilterVarToAddSlashesRector: ~ - Rector\Php\Rector\StaticCall\ExportToReflectionFunctionRector: ~ - Rector\Php\Rector\MagicConstClass\ClassConstantToSelfClassRector: ~ - Rector\Php\Rector\FuncCall\GetCalledClassToStaticClassRector: ~ - Rector\Php\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector: ~ - Rector\Php\Rector\Double\RealToFloatTypeCastRector: ~ - Rector\Php\Rector\Assign\NullCoalescingOperatorRector: ~ - Rector\Php\Rector\Function_\ReservedFnFunctionRector: ~ - Rector\Php\Rector\Closure\ClosureToArrowFunctionRector: ~ - Rector\Php\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector: ~ - Rector\Php\Rector\LNumber\AddLiteralSeparatorToNumberRector: ~ + Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector: ~ + Rector\Php74\Rector\FuncCall\FilterVarToAddSlashesRector: ~ + Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector: ~ + Rector\Php74\Rector\MagicConstClass\ClassConstantToSelfClassRector: ~ + Rector\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector: ~ + Rector\Php74\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector: ~ + Rector\Php74\Rector\Double\RealToFloatTypeCastRector: ~ + Rector\Php74\Rector\Assign\NullCoalescingOperatorRector: ~ + Rector\Php74\Rector\Function_\ReservedFnFunctionRector: ~ + Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector: ~ + Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector: ~ + Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector: ~ diff --git a/ecs.yaml b/ecs.yaml index 153f5b8e34dd..4c5b70105b86 100644 --- a/ecs.yaml +++ b/ecs.yaml @@ -76,7 +76,7 @@ parameters: Symplify\CodingStandard\Fixer\Order\PrivateMethodOrderByUseFixer: ~ PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer: - - 'packages/Php/src/Rector/Double/RealToFloatTypeCastRector.php' + - 'packages/Php74/src/Rector/Double/RealToFloatTypeCastRector.php' Symplify\CodingStandard\Sniffs\CleanCode\ForbiddenReferenceSniff: ~ @@ -119,7 +119,7 @@ parameters: - 'packages/TypeDeclaration/src/TypeInferer/ReturnTypeInferer/ReturnedNodesReturnTypeInferer.php' - 'packages/NodeTypeResolver/src/NodeTypeResolver.php' - 'packages/NodeTypeResolver/src/PerNodeTypeResolver/VariableTypeResolver.php' - - 'packages/Php/src/Rector/FuncCall/RemoveExtraParametersRector.php' + - 'packages/Php71/src/Rector/FuncCall/RemoveExtraParametersRector.php' - 'packages/SOLID/src/Analyzer/ClassConstantFetchAnalyzer.php' # tough logic - 'packages/PHPUnit/src/Rector/Class_/ArrayArgumentInTestToDataProviderRector.php' @@ -153,7 +153,7 @@ parameters: - 'packages/Php/src/EregToPcreTransformer.php' # dev - 'packages/TypeDeclaration/src/Rector/FunctionLike/*TypeDeclarationRector.php' - - 'packages/Php/src/Rector/If_/IfToSpaceshipRector.php' + - 'packages/Php70/src/Rector/If_/IfToSpaceshipRector.php' Symplify\CodingStandard\Sniffs\ControlStructure\SprintfOverContactSniff: # respects inherited pattern for better comparing @@ -173,7 +173,7 @@ parameters: Symplify\CodingStandard\Sniffs\Debug\CommentedOutCodeSniff.Found: # notes - - 'packages/Php/src/Rector/Each/ListEachRector.php' + - 'packages/Php72/src/Rector/Each/ListEachRector.php' - 'packages/DeadCode/src/Rector/ClassMethod/RemoveOverriddenValuesRector.php' - 'packages/PhpSpecToPHPUnit/src/Rector/MethodCall/PhpSpecPromisesToPHPUnitAssertRector.php' diff --git a/packages/CodeQuality/src/Rector/If_/SimplifyIfIssetToNullCoalescingRector.php b/packages/CodeQuality/src/Rector/If_/SimplifyIfIssetToNullCoalescingRector.php index 309845ee5b45..41bf9d572f22 100644 --- a/packages/CodeQuality/src/Rector/If_/SimplifyIfIssetToNullCoalescingRector.php +++ b/packages/CodeQuality/src/Rector/If_/SimplifyIfIssetToNullCoalescingRector.php @@ -76,7 +76,6 @@ public function refactor(Node $node): ?Node $valueNode = $issetNode->vars[0]; // various scenarios - /** @var Assign $firstAssign */ $firstAssign = $node->stmts[0]->expr; /** @var Assign $secondAssign */ diff --git a/packages/CodeQuality/tests/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector/Fixture/fixture.php.inc b/packages/CodeQuality/tests/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector/Fixture/fixture.php.inc index abd8fe16da90..d70c9a162f1c 100644 --- a/packages/CodeQuality/tests/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector/Fixture/fixture.php.inc +++ b/packages/CodeQuality/tests/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector/Fixture/fixture.php.inc @@ -1,5 +1,7 @@ 0; $invalid2 = isset($this->events[$event]) && !empty($this->events[$event]); - $completelyInvalid = !$value instanceof Foo && !$value instanceof Bar; + $completelyInvalid = !$value instanceof \Foo && !$value instanceof \Bar; if (empty($this->orders) && empty($this->unionOrders)) { - throw new RuntimeException('You must specify an orderBy clause when using this function.'); + throw new \RuntimeException('You must specify an orderBy clause when using this function.'); } echo is_array($objects) && is_array($objects); @@ -18,15 +20,17 @@ function simplifyEmptyCheck() ----- 0; $invalid2 = isset($this->events[$event]) && !empty($this->events[$event]); - $completelyInvalid = !$value instanceof Foo && !$value instanceof Bar; + $completelyInvalid = !$value instanceof \Foo && !$value instanceof \Bar; if (empty($this->orders) && empty($this->unionOrders)) { - throw new RuntimeException('You must specify an orderBy clause when using this function.'); + throw new \RuntimeException('You must specify an orderBy clause when using this function.'); } echo is_array($objects) && is_array($objects); diff --git a/packages/CodeQuality/tests/Rector/Ternary/TernaryToElvisRector/TernaryToElvisRectorTest.php b/packages/CodeQuality/tests/Rector/Ternary/TernaryToElvisRector/TernaryToElvisRectorTest.php index 69ca3b5e44dc..afd6e13f6603 100644 --- a/packages/CodeQuality/tests/Rector/Ternary/TernaryToElvisRector/TernaryToElvisRectorTest.php +++ b/packages/CodeQuality/tests/Rector/Ternary/TernaryToElvisRector/TernaryToElvisRectorTest.php @@ -2,7 +2,7 @@ namespace Rector\CodeQuality\Tests\Rector\Ternary\TernaryToElvisRector; -use Rector\CodeQuality\Rector\Ternary\TernaryToElvisRector; +use Rector\Php53\Rector\Ternary\TernaryToElvisRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; final class TernaryToElvisRectorTest extends AbstractRectorTestCase diff --git a/packages/DeadCode/src/Rector/ClassMethod/RemoveOverriddenValuesRector.php b/packages/DeadCode/src/Rector/ClassMethod/RemoveOverriddenValuesRector.php index 3dac77194150..35905da7f4f5 100644 --- a/packages/DeadCode/src/Rector/ClassMethod/RemoveOverriddenValuesRector.php +++ b/packages/DeadCode/src/Rector/ClassMethod/RemoveOverriddenValuesRector.php @@ -191,7 +191,6 @@ private function collectNodesByTypeAndPosition( // not in different scope, than previous one - e.g. if/while/else... // get nesting level to $classMethodNode - /** @var Assign $assignNode */ $assignNode = $assignedVariable->getAttribute(AttributeKey::PARENT_NODE); $nestingHash = $this->flowOfControlLocator->resolveNestingHashFromFunctionLike($functionLike, $assignNode); @@ -286,7 +285,6 @@ private function shouldRemoveAssignNode( // check previous node doesn't contain the node on the right, e.g. // $someNode = 1; // $someNode = $someNode ?: 1; - /** @var Assign $assignNode */ $assignNode = $nodeByTypeAndPosition->getParentNode(); diff --git a/packages/FileSystemRector/src/Rector/AbstractFileSystemRector.php b/packages/FileSystemRector/src/Rector/AbstractFileSystemRector.php index c667c639fc8a..8964d393a942 100644 --- a/packages/FileSystemRector/src/Rector/AbstractFileSystemRector.php +++ b/packages/FileSystemRector/src/Rector/AbstractFileSystemRector.php @@ -65,7 +65,7 @@ abstract class AbstractFileSystemRector implements FileSystemRectorInterface /** * @required */ - public function setAbstractFileSystemRectorDependencies( + public function autowireAbstractFileSystemRector( Parser $parser, ParserFactory $parserFactory, Lexer $lexer, @@ -100,6 +100,17 @@ protected function parseFileInfoToNodes(SmartFileInfo $smartFileInfo): array ); } + /** + * @return Node[] + */ + protected function parseFileInfoToNodesWithoutScope(SmartFileInfo $smartFileInfo): array + { + $oldStmts = $this->parser->parseFile($smartFileInfo->getRealPath()); + $this->oldStmts = $oldStmts; + + return $oldStmts; + } + /** * @param Node[] $nodes */ @@ -164,7 +175,7 @@ protected function printNodesWithFileDestination( ); } - protected function moveFile(SmartFileInfo $oldFileInfo, string $newFileLocation, string $fileContent): void + protected function moveFile(SmartFileInfo $oldFileInfo, string $newFileLocation, ?string $fileContent = null): void { $this->removedAndAddedFilesCollector->addMovedFile($oldFileInfo, $newFileLocation, $fileContent); } diff --git a/packages/NodeTypeResolver/src/NodeScopeAndMetadataDecorator.php b/packages/NodeTypeResolver/src/NodeScopeAndMetadataDecorator.php index d880ce6366bf..e53bf5d58c20 100644 --- a/packages/NodeTypeResolver/src/NodeScopeAndMetadataDecorator.php +++ b/packages/NodeTypeResolver/src/NodeScopeAndMetadataDecorator.php @@ -6,6 +6,7 @@ use PhpParser\NodeTraverser; use PhpParser\NodeVisitor\CloningVisitor; use PhpParser\NodeVisitor\NameResolver; +use Rector\Configuration\Configuration; use Rector\NodeTypeResolver\NodeVisitor\ClassAndMethodNodeVisitor; use Rector\NodeTypeResolver\NodeVisitor\ExpressionNodeVisitor; use Rector\NodeTypeResolver\NodeVisitor\FileInfoNodeVisitor; @@ -56,6 +57,11 @@ final class NodeScopeAndMetadataDecorator */ private $nodeCollectorNodeVisitor; + /** + * @var Configuration + */ + private $configuration; + public function __construct( NodeScopeResolver $nodeScopeResolver, ParentAndNextNodeVisitor $parentAndNextNodeVisitor, @@ -64,7 +70,8 @@ public function __construct( NamespaceNodeVisitor $namespaceNodeVisitor, ExpressionNodeVisitor $expressionNodeVisitor, FileInfoNodeVisitor $fileInfoNodeVisitor, - NodeCollectorNodeVisitor $nodeCollectorNodeVisitor + NodeCollectorNodeVisitor $nodeCollectorNodeVisitor, + Configuration $configuration ) { $this->nodeScopeResolver = $nodeScopeResolver; $this->parentAndNextNodeVisitor = $parentAndNextNodeVisitor; @@ -74,6 +81,7 @@ public function __construct( $this->expressionNodeVisitor = $expressionNodeVisitor; $this->fileInfoNodeVisitor = $fileInfoNodeVisitor; $this->nodeCollectorNodeVisitor = $nodeCollectorNodeVisitor; + $this->configuration = $configuration; } /** @@ -89,7 +97,10 @@ public function decorateNodesFromFile(array $nodes, string $filePath): array ])); $nodes = $nodeTraverser->traverse($nodes); - $nodes = $this->nodeScopeResolver->processNodes($nodes, $filePath); + // node scoping is needed only for Scope + if ($this->configuration->areAnyPhpRectorsLoaded()) { + $nodes = $this->nodeScopeResolver->processNodes($nodes, $filePath); + } $nodeTraverser = new NodeTraverser(); $nodeTraverser->addVisitor(new NameResolver(null, [ diff --git a/packages/NodeTypeResolver/src/PerNodeTypeResolver/ClassAndInterfaceTypeResolver.php b/packages/NodeTypeResolver/src/PerNodeTypeResolver/ClassAndInterfaceTypeResolver.php index 0e3a7b7bf852..3fc62f199a92 100644 --- a/packages/NodeTypeResolver/src/PerNodeTypeResolver/ClassAndInterfaceTypeResolver.php +++ b/packages/NodeTypeResolver/src/PerNodeTypeResolver/ClassAndInterfaceTypeResolver.php @@ -8,6 +8,7 @@ use PHPStan\Analyser\Scope; use PHPStan\Reflection\ClassReflection; use PHPStan\Type\Type; +use Rector\Exception\ShouldNotHappenException; use Rector\NodeTypeResolver\Contract\PerNodeTypeResolver\PerNodeTypeResolverInterface; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory; @@ -44,8 +45,11 @@ public function getNodeClasses(): array */ public function resolve(Node $node): Type { - /** @var Scope $nodeScope */ + /** @var Scope|null $nodeScope */ $nodeScope = $node->getAttribute(AttributeKey::SCOPE); + if ($nodeScope === null) { + throw new ShouldNotHappenException(); + } /** @var ClassReflection $classReflection */ $classReflection = $nodeScope->getClassReflection(); diff --git a/packages/NodeTypeResolver/src/StaticTypeMapper.php b/packages/NodeTypeResolver/src/StaticTypeMapper.php index de7364aa6a81..dc2c32c30cf2 100644 --- a/packages/NodeTypeResolver/src/StaticTypeMapper.php +++ b/packages/NodeTypeResolver/src/StaticTypeMapper.php @@ -689,7 +689,6 @@ private function matchTypeForUnionedObjectTypes(UnionType $unionType): ?Node } // @todo the type should be compatible with all other types, check with is_a()? - /** @var TypeWithClassName $firstObjectType */ $firstObjectType = $unionType->getTypes()[0]; diff --git a/packages/PSR4/src/FileRelocationResolver.php b/packages/PSR4/src/FileRelocationResolver.php index b5d2952ba0ba..812df321ea16 100644 --- a/packages/PSR4/src/FileRelocationResolver.php +++ b/packages/PSR4/src/FileRelocationResolver.php @@ -5,6 +5,7 @@ use Nette\Utils\Strings; use PhpParser\Node\Name; use PhpParser\Node\Stmt\Namespace_; +use Rector\ValueObject\RenamedNamespaceValueObject; use Symplify\PackageBuilder\FileSystem\SmartFileInfo; final class FileRelocationResolver @@ -44,31 +45,26 @@ public function resolveNewNamespaceName(Namespace_ $namespace, string $suffixNam ); } + public function resolveNewFileLocationFromRenamedNamespace( + SmartFileInfo $smartFileInfo, + RenamedNamespaceValueObject $renamedNamespaceValueObject + ): string { + $beforeToAfterPart = $this->resolveBeforeToAfterPartBetweenClassNames( + $renamedNamespaceValueObject->getOldNamespace(), + $renamedNamespaceValueObject->getNewNamespace() + ); + + return $this->replaceRalativeFilePathsWithBeforeAfter($smartFileInfo, $beforeToAfterPart); + } + public function resolveNewFileLocationFromOldClassToNewClass( - SmartFileInfo $oldSmartFileInfo, + SmartFileInfo $smartFileInfo, string $oldClass, string $newClass ): string { $beforeToAfterPart = $this->resolveBeforeToAfterPartBetweenClassNames($oldClass, $newClass); - // A. first "dir has changed" dummy detection - $relativeFilePathParts = Strings::split( - $oldSmartFileInfo->getRelativeFilePath(), - '#' . DIRECTORY_SEPARATOR . '#' - ); - - foreach ($relativeFilePathParts as $key => $relativeFilePathPart) { - if (! isset($beforeToAfterPart[$relativeFilePathPart])) { - continue; - } - - $relativeFilePathParts[$key] = $beforeToAfterPart[$relativeFilePathPart]; - - // clear from further use - unset($beforeToAfterPart[$relativeFilePathPart]); - } - - return implode(DIRECTORY_SEPARATOR, $relativeFilePathParts); + return $this->replaceRalativeFilePathsWithBeforeAfter($smartFileInfo, $beforeToAfterPart); } /** @@ -152,4 +148,31 @@ private function resolveBeforeToAfterPartBetweenClassNames(string $oldClass, str return $beforeToAfterParts; } + + /** + * @param string[] $beforeToAfterPart + */ + private function replaceRalativeFilePathsWithBeforeAfter( + SmartFileInfo $oldSmartFileInfo, + array $beforeToAfterPart + ): string { + // A. first "dir has changed" dummy detection + $relativeFilePathParts = Strings::split( + $oldSmartFileInfo->getRelativeFilePath(), + '#' . DIRECTORY_SEPARATOR . '#' + ); + + foreach ($relativeFilePathParts as $key => $relativeFilePathPart) { + if (! isset($beforeToAfterPart[$relativeFilePathPart])) { + continue; + } + + $relativeFilePathParts[$key] = $beforeToAfterPart[$relativeFilePathPart]; + + // clear from further use + unset($beforeToAfterPart[$relativeFilePathPart]); + } + + return implode(DIRECTORY_SEPARATOR, $relativeFilePathParts); + } } diff --git a/packages/Php/src/Exception/BreakScopeException.php b/packages/Php/src/Exception/BreakScopeException.php deleted file mode 100644 index 784da09f12de..000000000000 --- a/packages/Php/src/Exception/BreakScopeException.php +++ /dev/null @@ -1,9 +0,0 @@ - 'length', - 'mysql_field_name' => 'name', - 'mysql_field_table' => 'table', - ]; - - public function getDefinition(): RectorDefinition - { - return new RectorDefinition( - 'Converts more complex mysql functions to mysqli', - [ - new CodeSample( - <<<'PHP' -$data = mysql_db_name($result, $row); -PHP - , - <<<'PHP' -mysqli_data_seek($result, $row); -$fetch = mysql_fetch_row($result); -$data = $fetch[0]; -PHP - ), - ] - ); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [Assign::class]; - } - - /** - * @param Assign $node - */ - public function refactor(Node $node): ?Node - { - if (! $node->expr instanceof FuncCall) { - return null; - } - - /** @var FuncCall $funcCallNode */ - $funcCallNode = $node->expr; - - if ($this->isName($funcCallNode, 'mysql_tablename')) { - return $this->processMysqlTableName($node, $funcCallNode); - } - - if ($this->isName($funcCallNode, 'mysql_db_name')) { - return $this->processMysqlDbName($node, $funcCallNode); - } - - if ($this->isName($funcCallNode, 'mysql_db_query')) { - return $this->processMysqliSelectDb($node, $funcCallNode); - } - - if ($this->isName($funcCallNode, 'mysql_fetch_field')) { - return $this->processMysqlFetchField($node, $funcCallNode); - } - - return $this->processFieldToFieldDirect($node, $funcCallNode); - } - - private function processMysqlTableName(Assign $assign, FuncCall $funcCall): FuncCall - { - $funcCall->name = new Name('mysqli_data_seek'); - - $newFuncCall = new FuncCall(new Name('mysql_fetch_array'), [$funcCall->args[0]]); - $newAssignNode = new Assign($assign->var, new ArrayDimFetch($newFuncCall, new LNumber(0))); - - $this->addNodeAfterNode($newAssignNode, $assign); - - return $funcCall; - } - - private function processMysqlDbName(Assign $assign, FuncCall $funcCall): FuncCall - { - $funcCall->name = new Name('mysqli_data_seek'); - - $mysqlFetchRowFuncCall = new FuncCall(new Name('mysql_fetch_row'), [$funcCall->args[0]]); - $fetchVariable = new Variable('fetch'); - $newAssignNode = new Assign($fetchVariable, $mysqlFetchRowFuncCall); - $this->addNodeAfterNode($newAssignNode, $assign); - - $newAssignNode = new Assign($assign->var, new ArrayDimFetch($fetchVariable, new LNumber(0))); - $this->addNodeAfterNode($newAssignNode, $assign); - - return $funcCall; - } - - private function processMysqliSelectDb(Assign $assign, FuncCall $funcCall): FuncCall - { - $funcCall->name = new Name('mysqli_select_db'); - - $newAssignNode = new Assign($assign->var, new FuncCall(new Name('mysqli_query'), [$funcCall->args[1]])); - $this->addNodeAfterNode($newAssignNode, $assign); - - unset($funcCall->args[1]); - - return $funcCall; - } - - private function processMysqlFetchField(Assign $assign, FuncCall $funcCall): Assign - { - $funcCall->name = new Name('mysqli_fetch_field'); - - if (! isset($funcCall->args[1])) { - return $assign; - } - - unset($funcCall->args[1]); - - // add for - $xVar = new Variable('x'); - $forNode = new For_([ - 'init' => [new Assign($xVar, new LNumber(0))], - 'cond' => [new Smaller($xVar, new LNumber(5))], - 'loop' => [new PostInc($xVar)], - 'stmts' => [new Expression($funcCall)], - ]); - - $previousExpression = $assign->getAttribute(AttributeKey::PREVIOUS_EXPRESSION); - if ($previousExpression === null) { - throw new ShouldNotHappenException(); - } - - $this->addNodeAfterNode($forNode, $previousExpression); - - return $assign; - } - - private function processFieldToFieldDirect(Assign $assign, FuncCall $funcCall): ?Assign - { - foreach ($this->fieldToFieldDirect as $funcName => $property) { - if ($this->isName($funcCall, $funcName)) { - $parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE); - if ($parentNode instanceof PropertyFetch) { - continue; - } - - $funcCall->name = new Name('mysqli_fetch_field_direct'); - $assign->expr = new PropertyFetch($funcCall, $property); - - return $assign; - } - } - - return null; - } -} diff --git a/packages/Php/tests/EregToPcreTransformerTest.php b/packages/Php/tests/EregToPcreTransformerTest.php index 94b73d11510f..c5c2a48e8f99 100644 --- a/packages/Php/tests/EregToPcreTransformerTest.php +++ b/packages/Php/tests/EregToPcreTransformerTest.php @@ -19,7 +19,7 @@ protected function setUp(): void } /** - * @dataProvider provideDataDroping() + * @dataProvider provideDataDropping() * @dataProvider provideDataCaseSensitive() */ public function testCaseSensitive(string $ereg, string $expectedPcre): void @@ -47,7 +47,7 @@ public function provideDataCaseInsensitive(): Iterator yield ['hi', '#hi#mi']; } - public function provideDataDroping(): Iterator + public function provideDataDropping(): Iterator { yield ['mearie\.org', '#mearie\.org#m']; yield ['mearie[.,]org', '#mearie[\.,]org#m']; diff --git a/packages/Php/tests/Rector/Assign/AssignArrayToStringRector/AssignArrayToStringRectorTest.php b/packages/Php/tests/Rector/Assign/AssignArrayToStringRector/AssignArrayToStringRectorTest.php index f5d808f63229..8a23acc93784 100644 --- a/packages/Php/tests/Rector/Assign/AssignArrayToStringRector/AssignArrayToStringRectorTest.php +++ b/packages/Php/tests/Rector/Assign/AssignArrayToStringRector/AssignArrayToStringRectorTest.php @@ -2,7 +2,7 @@ namespace Rector\Php\Tests\Rector\Assign\AssignArrayToStringRector; -use Rector\Php\Rector\Assign\AssignArrayToStringRector; +use Rector\Php71\Rector\Assign\AssignArrayToStringRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; final class AssignArrayToStringRectorTest extends AbstractRectorTestCase @@ -28,7 +28,7 @@ public function provideDataForTest(): iterable yield [__DIR__ . '/Fixture/fixture6.php.inc']; yield [__DIR__ . '/Fixture/fixture7.php.inc']; yield [__DIR__ . '/Fixture/fixture8.php.inc']; - yield [__DIR__ . '/Fixture/fixture9.php.inc']; + yield [__DIR__ . '/Fixture/skip.php.inc']; } protected function getRectorClass(): string diff --git a/packages/Php/tests/Rector/Assign/AssignArrayToStringRector/Fixture/fixture.php.inc b/packages/Php/tests/Rector/Assign/AssignArrayToStringRector/Fixture/fixture.php.inc index 995797b2986e..242ed41e4f4f 100644 --- a/packages/Php/tests/Rector/Assign/AssignArrayToStringRector/Fixture/fixture.php.inc +++ b/packages/Php/tests/Rector/Assign/AssignArrayToStringRector/Fixture/fixture.php.inc @@ -1,5 +1,7 @@ ----- theFunction(1); + $this->theFunction(1, 2); + $this->theFunction(1, 2, 3); + } + + private function theFunction($a, $b = 5) + { + } +} + +?> +----- +theFunction(1); + $this->theFunction(1, 2); + $this->theFunction(1, 2); + } + + private function theFunction($a, $b = 5) + { + } +} + +?> diff --git a/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/remove_another_class_method_call_extra_argument.php.inc b/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/remove_another_class_method_call_extra_argument.php.inc index 9d1a451f203b..ce8a4160b69a 100644 --- a/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/remove_another_class_method_call_extra_argument.php.inc +++ b/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/remove_another_class_method_call_extra_argument.php.inc @@ -2,8 +2,6 @@ namespace Rector\Php\Tests\Rector\FuncCall\RemoveExtraParametersRector\Fixture; -use Rector\Php\Tests\Rector\FuncCall\RemoveExtraParametersRector\Source\MethodWithFuncGetArgs; - final class RemoveAnotherClassMethodCallExtraArgument { public function run() @@ -27,8 +25,6 @@ function better_func_get_args() { namespace Rector\Php\Tests\Rector\FuncCall\RemoveExtraParametersRector\Fixture; -use Rector\Php\Tests\Rector\FuncCall\RemoveExtraParametersRector\Source\MethodWithFuncGetArgs; - final class RemoveAnotherClassMethodCallExtraArgument { public function run() diff --git a/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/RemoveExtraParametersRectorTest.php b/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/RemoveExtraParametersRectorTest.php index f4264e3fb6ca..4a4571467bf8 100644 --- a/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/RemoveExtraParametersRectorTest.php +++ b/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/RemoveExtraParametersRectorTest.php @@ -2,7 +2,7 @@ namespace Rector\Php\Tests\Rector\FuncCall\RemoveExtraParametersRector; -use Rector\Php\Rector\FuncCall\RemoveExtraParametersRector; +use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; final class RemoveExtraParametersRectorTest extends AbstractRectorTestCase @@ -25,9 +25,11 @@ public function provideDataForTest(): iterable yield [__DIR__ . '/Fixture/methods.php.inc']; yield [__DIR__ . '/Fixture/static_calls.php.inc']; yield [__DIR__ . '/Fixture/fixture.php.inc']; + yield [__DIR__ . '/Fixture/function_with_one_required_and_one_optional_parameter.php.inc']; yield [__DIR__ . '/Fixture/func_get_all.php.inc']; yield [__DIR__ . '/Fixture/external_scope.php.inc']; yield [__DIR__ . '/Fixture/static_call_parent.php.inc']; + // skip yield [__DIR__ . '/Fixture/skip_commented_param_func_get_args.php.inc']; yield [__DIR__ . '/Fixture/skip_call_user_func_array.php.inc']; yield [__DIR__ . '/Fixture/skip_invoke.php.inc']; diff --git a/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/config.yaml b/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/config.yaml deleted file mode 100644 index 8c334276770a..000000000000 --- a/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/config.yaml +++ /dev/null @@ -1,2 +0,0 @@ -services: - Rector\Php\Rector\FuncCall\RemoveExtraParametersRector: ~ diff --git a/packages/Php/tests/Rector/FuncCall/RemoveMissingCompactVariableRector/RemoveMissingCompactVariableRectorTest.php b/packages/Php/tests/Rector/FuncCall/RemoveMissingCompactVariableRector/RemoveMissingCompactVariableRectorTest.php index 2c244df9c2ad..622a154691ee 100644 --- a/packages/Php/tests/Rector/FuncCall/RemoveMissingCompactVariableRector/RemoveMissingCompactVariableRectorTest.php +++ b/packages/Php/tests/Rector/FuncCall/RemoveMissingCompactVariableRector/RemoveMissingCompactVariableRectorTest.php @@ -2,7 +2,7 @@ namespace Rector\Php\Tests\Rector\FuncCall\RemoveMissingCompactVariableRector; -use Rector\Php\Rector\FuncCall\RemoveMissingCompactVariableRector; +use Rector\Php73\Rector\FuncCall\RemoveMissingCompactVariableRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; final class RemoveMissingCompactVariableRectorTest extends AbstractRectorTestCase diff --git a/packages/Php/tests/Rector/FuncCall/RemoveReferenceFromCallRector/RemoveReferenceFromCallRectorTest.php b/packages/Php/tests/Rector/FuncCall/RemoveReferenceFromCallRector/RemoveReferenceFromCallRectorTest.php index 16e412d1833d..01fa0cae0daa 100644 --- a/packages/Php/tests/Rector/FuncCall/RemoveReferenceFromCallRector/RemoveReferenceFromCallRectorTest.php +++ b/packages/Php/tests/Rector/FuncCall/RemoveReferenceFromCallRector/RemoveReferenceFromCallRectorTest.php @@ -2,7 +2,7 @@ namespace Rector\Php\Tests\Rector\FuncCall\RemoveReferenceFromCallRector; -use Rector\Php\Rector\FuncCall\RemoveReferenceFromCallRector; +use Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; final class RemoveReferenceFromCallRectorTest extends AbstractRectorTestCase diff --git a/packages/Php/tests/Rector/FuncCall/RenameMktimeWithoutArgsToTimeRector/RenameMktimeWithoutArgsToTimeRectorTest.php b/packages/Php/tests/Rector/FuncCall/RenameMktimeWithoutArgsToTimeRector/RenameMktimeWithoutArgsToTimeRectorTest.php index 43f40384b8fc..34c326b9f569 100644 --- a/packages/Php/tests/Rector/FuncCall/RenameMktimeWithoutArgsToTimeRector/RenameMktimeWithoutArgsToTimeRectorTest.php +++ b/packages/Php/tests/Rector/FuncCall/RenameMktimeWithoutArgsToTimeRector/RenameMktimeWithoutArgsToTimeRectorTest.php @@ -2,7 +2,7 @@ namespace Rector\Php\Tests\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector; -use Rector\Php\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector; +use Rector\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; final class RenameMktimeWithoutArgsToTimeRectorTest extends AbstractRectorTestCase diff --git a/packages/Php/tests/Rector/FuncCall/SensitiveDefineRector/SensitiveDefineRectorTest.php b/packages/Php/tests/Rector/FuncCall/SensitiveDefineRector/SensitiveDefineRectorTest.php index 9706fea2d7fb..157a65c13c9e 100644 --- a/packages/Php/tests/Rector/FuncCall/SensitiveDefineRector/SensitiveDefineRectorTest.php +++ b/packages/Php/tests/Rector/FuncCall/SensitiveDefineRector/SensitiveDefineRectorTest.php @@ -2,7 +2,7 @@ namespace Rector\Php\Tests\Rector\FuncCall\SensitiveDefineRector; -use Rector\Php\Rector\FuncCall\SensitiveDefineRector; +use Rector\Php73\Rector\FuncCall\SensitiveDefineRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; final class SensitiveDefineRectorTest extends AbstractRectorTestCase diff --git a/packages/Php/tests/Rector/FuncCall/StringifyDefineRector/StringifyDefineRectorTest.php b/packages/Php/tests/Rector/FuncCall/StringifyDefineRector/StringifyDefineRectorTest.php index f38bcd1fc90e..f72b51eb6474 100644 --- a/packages/Php/tests/Rector/FuncCall/StringifyDefineRector/StringifyDefineRectorTest.php +++ b/packages/Php/tests/Rector/FuncCall/StringifyDefineRector/StringifyDefineRectorTest.php @@ -2,7 +2,7 @@ namespace Rector\Php\Tests\Rector\FuncCall\StringifyDefineRector; -use Rector\Php\Rector\FuncCall\StringifyDefineRector; +use Rector\Php72\Rector\FuncCall\StringifyDefineRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; final class StringifyDefineRectorTest extends AbstractRectorTestCase diff --git a/packages/Php/tests/Rector/FuncCall/StringifyStrNeedlesRector/Fixture/fixture.php.inc b/packages/Php/tests/Rector/FuncCall/StringifyStrNeedlesRector/Fixture/fixture.php.inc index e954f31256e7..c7ccbc0eca12 100644 --- a/packages/Php/tests/Rector/FuncCall/StringifyStrNeedlesRector/Fixture/fixture.php.inc +++ b/packages/Php/tests/Rector/FuncCall/StringifyStrNeedlesRector/Fixture/fixture.php.inc @@ -1,5 +1,7 @@ ---- +----- $b) ? 1 : 0); @@ -10,6 +12,8 @@ function order_func($a, $b) { ----- $b; diff --git a/packages/Php/tests/Rector/Ternary/TernaryToSpaceshipRector/TernaryToSpaceshipRectorTest.php b/packages/Php/tests/Rector/Ternary/TernaryToSpaceshipRector/TernaryToSpaceshipRectorTest.php index f412bcbfbbb0..c4fb3baf20b3 100644 --- a/packages/Php/tests/Rector/Ternary/TernaryToSpaceshipRector/TernaryToSpaceshipRectorTest.php +++ b/packages/Php/tests/Rector/Ternary/TernaryToSpaceshipRector/TernaryToSpaceshipRectorTest.php @@ -2,7 +2,7 @@ namespace Rector\Php\Tests\Rector\Ternary\TernaryToSpaceshipRector; -use Rector\Php\Rector\Ternary\TernaryToSpaceshipRector; +use Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; final class TernaryToSpaceshipRectorTest extends AbstractRectorTestCase diff --git a/packages/Php/tests/Rector/TryCatch/MultiExceptionCatchRector/MultiExceptionCatchRectorTest.php b/packages/Php/tests/Rector/TryCatch/MultiExceptionCatchRector/MultiExceptionCatchRectorTest.php index 9040cc2803b7..06dbfa7bea8e 100644 --- a/packages/Php/tests/Rector/TryCatch/MultiExceptionCatchRector/MultiExceptionCatchRectorTest.php +++ b/packages/Php/tests/Rector/TryCatch/MultiExceptionCatchRector/MultiExceptionCatchRectorTest.php @@ -2,7 +2,7 @@ namespace Rector\Php\Tests\Rector\TryCatch\MultiExceptionCatchRector; -use Rector\Php\Rector\TryCatch\MultiExceptionCatchRector; +use Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; final class MultiExceptionCatchRectorTest extends AbstractRectorTestCase diff --git a/packages/Php/tests/Rector/Unset_/UnsetCastRector/Fixture/fixture.php.inc b/packages/Php/tests/Rector/Unset_/UnsetCastRector/Fixture/fixture.php.inc index 076e877151af..7746ddb516cc 100644 --- a/packages/Php/tests/Rector/Unset_/UnsetCastRector/Fixture/fixture.php.inc +++ b/packages/Php/tests/Rector/Unset_/UnsetCastRector/Fixture/fixture.php.inc @@ -1,5 +1,7 @@ getStaticType($expr); - - if ($this->shouldSkipVariable($variableStaticType)) { + if ($this->shouldSkipVariable($expr)) { return true; } @@ -164,8 +161,9 @@ private function isEmptyStringNode(Node $node): bool return $node instanceof String_ && $node->value === ''; } - private function shouldSkipVariable(?Type $staticType): bool + private function shouldSkipVariable(Expr $expr): bool { + $staticType = $this->getStaticType($expr); if ($staticType instanceof ErrorType) { return false; } @@ -174,6 +172,7 @@ private function shouldSkipVariable(?Type $staticType): bool return ! ($staticType->isSuperTypeOf(new ArrayType(new MixedType(), new MixedType()))->yes() && $staticType->isSuperTypeOf(new ConstantStringType(''))->yes()); } + return ! $staticType instanceof StringType; } } diff --git a/packages/Php/src/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector.php b/packages/Php71/src/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector.php similarity index 97% rename from packages/Php/src/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector.php rename to packages/Php71/src/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector.php index 59b49eac6e0c..ddf759b3d42e 100644 --- a/packages/Php/src/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector.php +++ b/packages/Php71/src/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector.php @@ -1,6 +1,6 @@ fileRelocationResolver = $fileRelocationResolver; + $this->oldToNewNamespace = $oldToNewNamespace; + $this->namespaceMatcher = $namespaceMatcher; + } + + public function refactor(SmartFileInfo $smartFileInfo): void + { + $namespaceName = $this->resolveNamespaceName($smartFileInfo); + if ($namespaceName === null) { + return; + } + + $renamedNamespaceValueObject = $this->namespaceMatcher->matchRenamedNamespace( + $namespaceName, + $this->oldToNewNamespace + ); + + if ($renamedNamespaceValueObject === null) { + return; + } + + $newFileLocation = $this->fileRelocationResolver->resolveNewFileLocationFromRenamedNamespace( + $smartFileInfo, + $renamedNamespaceValueObject + ); + + // @todo + // create helping rename class rector.yaml + class_alias autoload file + // $this->renamedClassesCollector->addClassRename($oldClass, $newClass); + + $this->moveFile($smartFileInfo, $newFileLocation); + } + + public function getDefinition(): RectorDefinition + { + return new RectorDefinition( + 'Move namespace to new location with respect to PSR-4 + follow up with files in the namespace move' + ); + } + + private function resolveNamespaceName(SmartFileInfo $smartFileInfo): ?string + { + $nodes = $this->parseFileInfoToNodesWithoutScope($smartFileInfo); + + /** @var Namespace_|null $namespace */ + $namespace = $this->betterNodeFinder->findFirstInstanceOf($nodes, Namespace_::class); + if ($namespace === null) { + return null; + } + + return $this->getName($namespace); + } +} diff --git a/packages/SymfonyPHPUnit/config/config.yaml b/packages/SymfonyPHPUnit/config/config.yaml index a52e8816fe98..9f10a8158059 100644 --- a/packages/SymfonyPHPUnit/config/config.yaml +++ b/packages/SymfonyPHPUnit/config/config.yaml @@ -5,3 +5,4 @@ services: Rector\SymfonyPHPUnit\: resource: '../src/' + exclude: '../src/{Rector/**/*Rector.php}' diff --git a/packages/TypeDeclaration/src/Rector/FunctionLike/AbstractTypeDeclarationRector.php b/packages/TypeDeclaration/src/Rector/FunctionLike/AbstractTypeDeclarationRector.php index 4a8a9774fad7..d8c009301791 100644 --- a/packages/TypeDeclaration/src/Rector/FunctionLike/AbstractTypeDeclarationRector.php +++ b/packages/TypeDeclaration/src/Rector/FunctionLike/AbstractTypeDeclarationRector.php @@ -73,7 +73,6 @@ protected function isChangeVendorLockedIn(ClassMethod $classMethod, int $paramPo $methodName = $this->getName($classMethod); // @todo extract to some "inherited parent method" service - /** @var string|null $parentClassName */ $parentClassName = $classMethod->getAttribute(AttributeKey::PARENT_CLASS_NAME); diff --git a/packages/Php/src/Rector/Property/CompleteVarDocTypePropertyRector.php b/packages/TypeDeclaration/src/Rector/Property/CompleteVarDocTypePropertyRector.php similarity index 97% rename from packages/Php/src/Rector/Property/CompleteVarDocTypePropertyRector.php rename to packages/TypeDeclaration/src/Rector/Property/CompleteVarDocTypePropertyRector.php index be55b711be15..c62a8eeeafa0 100644 --- a/packages/Php/src/Rector/Property/CompleteVarDocTypePropertyRector.php +++ b/packages/TypeDeclaration/src/Rector/Property/CompleteVarDocTypePropertyRector.php @@ -1,6 +1,6 @@ ------ - diff --git a/packages/TypeDeclaration/tests/Rector/FunctionLike/ParamTypeDeclarationRector/ParamTypeDeclarationRectorTest.php b/packages/TypeDeclaration/tests/Rector/FunctionLike/ParamTypeDeclarationRector/ParamTypeDeclarationRectorTest.php index 8c0a5fc83325..f2256f7bd346 100644 --- a/packages/TypeDeclaration/tests/Rector/FunctionLike/ParamTypeDeclarationRector/ParamTypeDeclarationRectorTest.php +++ b/packages/TypeDeclaration/tests/Rector/FunctionLike/ParamTypeDeclarationRector/ParamTypeDeclarationRectorTest.php @@ -76,7 +76,6 @@ public function provideDataForTest(): iterable yield [__DIR__ . '/Fixture/dunglas/BazTrait.php.inc']; yield [__DIR__ . '/Fixture/dunglas/by_reference.php.inc']; yield [__DIR__ . '/Fixture/dunglas/Child.php.inc']; - yield [__DIR__ . '/Fixture/dunglas/Foo.php.inc']; yield [__DIR__ . '/Fixture/dunglas/functions.php.inc']; yield [__DIR__ . '/Fixture/dunglas/functions2.php.inc']; diff --git a/rector.yaml b/rector.yaml index 0d4868a31274..aa5710cea3f4 100644 --- a/rector.yaml +++ b/rector.yaml @@ -1,95 +1,85 @@ parameters: exclude_paths: - - "/Fixture/" - - "/Fixtures/" +# - "/Fixture/" +# - "/Fixtures/" - "/Expected/" - "/Source/" - "packages/Symfony/src/Bridge/DefaultAnalyzedSymfonyApplicationContainer.php" - "src/Testing/PHPUnit/AbstractRectorTestCase.php" # autoload-buggy cases - - "*.php.inc" +# - "*.php.inc" # so Rector code is still PHP 7.1 compatible php_version_features: '7.1' -services: -# Rector\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector: ~ - Rector\Refactoring\Rector\FileSystem\MoveAndRenameClassRector: - $oldClassToNewClass: - Rector\Php\Rector\Property\VarToPublicPropertyRector: 'Rector\Php52\Rector\Property\VarToPublicPropertyRector' - Rector\Php\Rector\Switch_\ContinueToBreakInSwitchRector: 'Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector' - - Rector\CodeQuality\Rector\Ternary\TernaryToElvisRector: 'Rector\Php53\Rector\Ternary\TernaryToElvisRector' - - Rector\Php\Rector\FuncCall\RemoveReferenceFromCallRector: 'Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector' - - Rector\Php\Rector\String_\StringClassNameToClassConstantRector: 'Rector\Php55\Rector\String_\StringClassNameToClassConstantRector' - - Rector\Php\Rector\FuncCall\PowToExpRector: 'Rector\Php56\Rector\FuncCall\PowToExpRector' - Rector\Php\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector: 'Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector' - - Rector\Php\Rector\FunctionLike\Php4ConstructorRector: 'Rector\Php70\Rector\FunctionLike\Php4ConstructorRector' - Rector\Php\Rector\Ternary\TernaryToNullCoalescingRector: 'Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector' - Rector\Php\Rector\FuncCall\RandomFunctionRector: 'Rector\Php70\Rector\FuncCall\RandomFunctionRector' - Rector\Php\Rector\FunctionLike\ExceptionHandlerTypehintRector: 'Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector' - Rector\Php\Rector\FuncCall\MultiDirnameRector: 'Rector\Php70\Rector\FuncCall\MultiDirnameRector' - Rector\Php\Rector\List_\ListSplitStringRector: 'Rector\Php70\Rector\List_\ListSplitStringRector' - Rector\Php\Rector\List_\EmptyListRector: 'Rector\Php70\Rector\List_\EmptyListRector' - - # be careful, run this just once, since it can keep swapping order back and forth - Rector\Php\Rector\List_\ListSwapArrayOrderRector: 'Rector\Php70\Rector\List_\ListSwapArrayOrderRector' - - Rector\Php\Rector\FuncCall\CallUserMethodRector: 'Rector\Php70\Rector\FuncCall\CallUserMethodRector' - Rector\Php\Rector\FuncCall\EregToPregMatchRector: 'Rector\Php70\Rector\FuncCall\EregToPregMatchRector' - Rector\Php\Rector\Switch_\ReduceMultipleDefaultSwitchRector: 'Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector' - Rector\Php\Rector\Ternary\TernaryToSpaceshipRector: 'Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector' - Rector\Php\Rector\If_\IfToSpaceshipRector: 'Rector\Php70\Rector\If_\IfToSpaceshipRector' - Rector\Php\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector: 'Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector' - Rector\Php\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector: 'Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector' - - Rector\Php\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector: 'Rector\Php70\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector' - Rector\Php\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector: 'Rector\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector' - - Rector\Php\Rector\BinaryOp\IsIterableRector: 'Rector\Php71\Rector\BinaryOp\IsIterableRector' - Rector\Php\Rector\TryCatch\MultiExceptionCatchRector: 'Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector' - Rector\Php\Rector\FuncCall\CountOnNullRector: 'Rector\Php71\Rector\FuncCall\CountOnNullRector' - Rector\Php\Rector\FuncCall\RemoveExtraParametersRector: 'Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector' - Rector\Php\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector: 'Rector\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector' - Rector\Php\Rector\Assign\AssignArrayToStringRector: 'Rector\Php71\Rector\Assign\AssignArrayToStringRector' - - Rector\Php\Rector\Each\WhileEachToForeachRector: 'Rector\Php72\Rector\Each\WhileEachToForeachRector' - Rector\Php\Rector\Each\ListEachRector: 'Rector\Php72\Rector\Each\ListEachRector' - Rector\Php\Rector\Unset_\UnsetCastRector: 'Rector\Php72\Rector\Unset_\UnsetCastRector' - Rector\Php\Rector\ConstFetch\BarewordStringRector: 'Rector\Php72\Rector\ConstFetch\BarewordStringRector' - Rector\Php\Rector\FuncCall\GetClassOnNullRector: 'Rector\Php72\Rector\FuncCall\GetClassOnNullRector' - Rector\Php\Rector\FuncCall\IsObjectOnIncompleteClassRector: 'Rector\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector' - Rector\Php\Rector\FuncCall\ParseStrWithResultArgumentRector: 'Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector' - Rector\Php\Rector\FuncCall\StringsAssertNakedRector: 'Rector\Php72\Rector\FuncCall\StringsAssertNakedRector' - Rector\Php\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector: 'Rector\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector' - Rector\Php\Rector\FuncCall\StringifyDefineRector: 'Rector\Php72\Rector\FuncCall\StringifyDefineRector' - - Rector\Php\Rector\BinaryOp\IsCountableRector: 'Rector\Php73\Rector\BinaryOp\IsCountableRector' - Rector\Php\Rector\FuncCall\ArrayKeyFirstLastRector: 'Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector' - Rector\Php\Rector\FuncCall\SensitiveDefineRector: 'Rector\Php73\Rector\FuncCall\SensitiveDefineRector' - Rector\Php\Rector\ConstFetch\SensitiveConstantNameRector: 'Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector' - Rector\Php\Rector\String_\SensitiveHereNowDocRector: 'Rector\Php73\Rector\String_\SensitiveHereNowDocRector' - Rector\Php\Rector\FuncCall\StringifyStrNeedlesRector: 'Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector' - Rector\Php\Rector\FuncCall\JsonThrowOnErrorRector: 'Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector' - Rector\Php\Rector\FuncCall\RegexDashEscapeRector: 'Rector\Php73\Rector\FuncCall\RegexDashEscapeRector' - Rector\Php\Rector\FuncCall\RemoveMissingCompactVariableRector: 'Rector\Php73\Rector\FuncCall\RemoveMissingCompactVariableRector' - - Rector\Php\Rector\Property\TypedPropertyRector: 'Rector\Php74\Rector\Property\TypedPropertyRector' - Rector\Php\Rector\FuncCall\ArrayKeyExistsOnPropertyRector: 'Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector' - Rector\Php\Rector\FuncCall\FilterVarToAddSlashesRector: 'Rector\Php74\Rector\FuncCall\FilterVarToAddSlashesRector' - Rector\Php\Rector\StaticCall\ExportToReflectionFunctionRector: 'Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector' - Rector\Php\Rector\MagicConstClass\ClassConstantToSelfClassRector: 'Rector\Php74\Rector\MagicConstClass\ClassConstantToSelfClassRector' - Rector\Php\Rector\FuncCall\GetCalledClassToStaticClassRector: 'Rector\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector' - Rector\Php\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector: 'Rector\Php74\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector' - Rector\Php\Rector\Double\RealToFloatTypeCastRector: 'Rector\Php74\Rector\Double\RealToFloatTypeCastRector' - Rector\Php\Rector\Assign\NullCoalescingOperatorRector: 'Rector\Php74\Rector\Assign\NullCoalescingOperatorRector' - Rector\Php\Rector\Function_\ReservedFnFunctionRector: 'Rector\Php74\Rector\Function_\ReservedFnFunctionRector' - Rector\Php\Rector\Closure\ClosureToArrowFunctionRector: 'Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector' - Rector\Php\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector: 'Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector' - Rector\Php\Rector\LNumber\AddLiteralSeparatorToNumberRector: 'Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector' + file_extensions: + - 'php' + - 'php.inc' +services: + Rector\Refactoring\Rector\FileSystem\MoveAndRenameNamespaceRector: + $oldToNewNamespace: + Rector\Php\Tests\Rector\Property\VarToPublicPropertyRector: Rector\Php52\Tests\Rector\Property\VarToPublicPropertyRector + Rector\Php\Tests\Rector\Switch_\ContinueToBreakInSwitchRector: Rector\Php52\Tests\Rector\Switch_\ContinueToBreakInSwitchRector + Rector\Php\Tests\Rector\Ternary\TernaryToElvisRector: Rector\Php53\Tests\Rector\Ternary\TernaryToElvisRector + Rector\Php\Tests\Rector\FuncCall\RemoveReferenceFromCallRector: Rector\Php54\Tests\Rector\FuncCall\RemoveReferenceFromCallRector + Rector\Php\Tests\Rector\String_\StringClassNameToClassConstantRector: Rector\Php55\Tests\Rector\String_\StringClassNameToClassConstantRector + Rector\Php\Tests\Rector\FuncCall\PowToExpRector: Rector\Php56\Tests\Rector\FuncCall\PowToExpRector + Rector\Php\Tests\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector: Rector\Php56\Tests\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector + Rector\Php\Tests\Rector\FunctionLike\Php4ConstructorRector: Rector\Php70\Tests\Rector\FunctionLike\Php4ConstructorRector + Rector\Php\Tests\Rector\Ternary\TernaryToNullCoalescingRector: Rector\Php70\Tests\Rector\Ternary\TernaryToNullCoalescingRector + Rector\Php\Tests\Rector\FuncCall\RandomFunctionRector: Rector\Php70\Tests\Rector\FuncCall\RandomFunctionRector + Rector\Php\Tests\Rector\FunctionLike\ExceptionHandlerTypehintRector: Rector\Php70\Tests\Rector\FunctionLike\ExceptionHandlerTypehintRector + Rector\Php\Tests\Rector\FuncCall\MultiDirnameRector: Rector\Php70\Tests\Rector\FuncCall\MultiDirnameRector + Rector\Php\Tests\Rector\List_\ListSplitStringRector: Rector\Php70\Tests\Rector\List_\ListSplitStringRector + Rector\Php\Tests\Rector\List_\EmptyListRector: Rector\Php70\Tests\Rector\List_\EmptyListRector + Rector\Php\Tests\Rector\List_\ListSwapArrayOrderRector: Rector\Php70\Tests\Rector\List_\ListSwapArrayOrderRector + Rector\Php\Tests\Rector\FuncCall\CallUserMethodRector : Rector\Php70\Tests\Rector\FuncCall\CallUserMethodRector + Rector\Php\Tests\Rector\FuncCall\EregToPregMatchRector: Rector\Php70\Tests\Rector\FuncCall\EregToPregMatchRector + Rector\Php\Tests\Rector\Switch_\ReduceMultipleDefaultSwitchRector: Rector\Php70\Tests\Rector\Switch_\ReduceMultipleDefaultSwitchRector + Rector\Php\Tests\Rector\Ternary\TernaryToSpaceshipRector: Rector\Php70\Tests\Rector\Ternary\TernaryToSpaceshipRector + Rector\Php\Tests\Rector\If_\IfToSpaceshipRector: Rector\Php70\Tests\Rector\If_\IfToSpaceshipRector + Rector\Php\Tests\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector: Rector\Php70\Tests\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector + Rector\Php\Tests\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector: Rector\Php70\Tests\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector + Rector\Php\Tests\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector: Rector\Php70\Tests\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector + Rector\Php\Tests\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector: Rector\Php70\Tests\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector + Rector\Php\Tests\Rector\BinaryOp\IsIterableRector: Rector\Php71\Tests\Rector\BinaryOp\IsIterableRector + Rector\Php\Tests\Rector\TryCatch\MultiExceptionCatchRector: Rector\Php71\Tests\Rector\TryCatch\MultiExceptionCatchRector + Rector\Php\Tests\Rector\Assign\AssignArrayToStringRector: Rector\Php71\Tests\Rector\Assign\AssignArrayToStringRector + Rector\Php\Tests\Rector\FuncCall\CountOnNullRector: Rector\Php71\Tests\Rector\FuncCall\CountOnNullRector + Rector\Php\Tests\Rector\FuncCall\RemoveExtraParametersRector: Rector\Php71\Tests\Rector\FuncCall\RemoveExtraParametersRector + Rector\Php\Tests\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector: Rector\Php71\Tests\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector + Rector\Php\Tests\Rector\Each\WhileEachToForeachRector: Rector\Php72\Tests\Rector\Each\WhileEachToForeachRector + Rector\Php\Tests\Rector\Each\ListEachRector: Rector\Php72\Tests\Rector\Each\ListEachRector + Rector\Php\Tests\Rector\Unset_\UnsetCastRector: Rector\Php72\Tests\Rector\Unset_\UnsetCastRector + Rector\Php\Tests\Rector\ConstFetch\BarewordStringRector: Rector\Php72\Tests\Rector\ConstFetch\BarewordStringRector + Rector\Php\Tests\Rector\FuncCall\GetClassOnNullRector: Rector\Php72\Tests\Rector\FuncCall\GetClassOnNullRector + Rector\Php\Tests\Rector\FuncCall\IsObjectOnIncompleteClassRector: Rector\Php72\Tests\Rector\FuncCall\IsObjectOnIncompleteClassRector + Rector\Php\Tests\Rector\FuncCall\ParseStrWithResultArgumentRector: Rector\Php72\Tests\Rector\FuncCall\ParseStrWithResultArgumentRector + Rector\Php\Tests\Rector\FuncCall\StringsAssertNakedRector: Rector\Php72\Tests\Rector\FuncCall\StringsAssertNakedRector + Rector\Php\Tests\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector: Rector\Php72\Tests\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector + Rector\Php\Tests\Rector\FuncCall\StringifyDefineRector: Rector\Php72\Tests\Rector\FuncCall\StringifyDefineRector + Rector\Php\Tests\Rector\BinaryOp\IsCountableRector: Rector\Php73\Tests\Rector\BinaryOp\IsCountableRector + Rector\Php\Tests\Rector\FuncCall\ArrayKeyFirstLastRector: Rector\Php73\Tests\Rector\FuncCall\ArrayKeyFirstLastRector + Rector\Php\Tests\Rector\FuncCall\SensitiveDefineRector: Rector\Php73\Tests\Rector\FuncCall\SensitiveDefineRector + Rector\Php\Tests\Rector\ConstFetch\SensitiveConstantNameRector: Rector\Php73\Tests\Rector\ConstFetch\SensitiveConstantNameRector + Rector\Php\Tests\Rector\String_\SensitiveHereNowDocRector: Rector\Php73\Tests\Rector\String_\SensitiveHereNowDocRector + Rector\Php\Tests\Rector\FuncCall\StringifyStrNeedlesRector: Rector\Php73\Tests\Rector\FuncCall\StringifyStrNeedlesRector + Rector\Php\Tests\Rector\FuncCall\JsonThrowOnErrorRector: Rector\Php73\Tests\Rector\FuncCall\JsonThrowOnErrorRector + Rector\Php\Tests\Rector\FuncCall\RegexDashEscapeRector: Rector\Php73\Tests\Rector\FuncCall\RegexDashEscapeRector + Rector\Php\Tests\Rector\FuncCall\RemoveMissingCompactVariableRector: Rector\Php73\Tests\Rector\FuncCall\RemoveMissingCompactVariableRector + Rector\Php\Tests\Rector\Property\TypedPropertyRector: Rector\Php74\Tests\Rector\Property\TypedPropertyRector + Rector\Php\Tests\Rector\FuncCall\ArrayKeyExistsOnPropertyRector: Rector\Php74\Tests\Rector\FuncCall\ArrayKeyExistsOnPropertyRector + Rector\Php\Tests\Rector\FuncCall\FilterVarToAddSlashesRector: Rector\Php74\Tests\Rector\FuncCall\FilterVarToAddSlashesRector + Rector\Php\Tests\Rector\StaticCall\ExportToReflectionFunctionRector: Rector\Php74\Tests\Rector\StaticCall\ExportToReflectionFunctionRector + Rector\Php\Tests\Rector\MagicConstClass\ClassConstantToSelfClassRector: Rector\Php74\Tests\Rector\MagicConstClass\ClassConstantToSelfClassRector + Rector\Php\Tests\Rector\FuncCall\GetCalledClassToStaticClassRector: Rector\Php74\Tests\Rector\FuncCall\GetCalledClassToStaticClassRector + Rector\Php\Tests\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector: Rector\Php74\Tests\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector + Rector\Php\Tests\Rector\Double\RealToFloatTypeCastRector: Rector\Php74\Tests\Rector\Double\RealToFloatTypeCastRector + Rector\Php\Tests\Rector\Assign\NullCoalescingOperatorRector: Rector\Php74\Tests\Rector\Assign\NullCoalescingOperatorRector + Rector\Php\Tests\Rector\Function_\ReservedFnFunctionRector: Rector\Php74\Tests\Rector\Function_\ReservedFnFunctionRector + Rector\Php\Tests\Rector\Closure\ClosureToArrowFunctionRector: Rector\Php74\Tests\Rector\Closure\ClosureToArrowFunctionRector + Rector\Php\Tests\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector: Rector\Php74\Tests\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector + Rector\Php\Tests\Rector\LNumber\AddLiteralSeparatorToNumberRector: Rector\Php74\Tests\Rector\LNumber\AddLiteralSeparatorToNumberRector + Rector\Php\Tests\Rector\Property\CompleteVarDocTypePropertyRector: 'Rector\TypeDeclaration\Tetss\Rector\Property\CompleteVarDocTypePropertyRector' diff --git a/src/Application/FileSystem/RemovedAndAddedFilesCollector.php b/src/Application/FileSystem/RemovedAndAddedFilesCollector.php index 15e6a14c6acd..f26d4ed7868b 100644 --- a/src/Application/FileSystem/RemovedAndAddedFilesCollector.php +++ b/src/Application/FileSystem/RemovedAndAddedFilesCollector.php @@ -27,8 +27,11 @@ public function removeFile(SmartFileInfo $smartFileInfo): void $this->removedFiles[$smartFileInfo->getRealPath()] = $smartFileInfo; } - public function addMovedFile(SmartFileInfo $oldFileInfo, string $newFileLocation, string $content): void + public function addMovedFile(SmartFileInfo $oldFileInfo, string $newFileLocation, ?string $content = null): void { + // keep original content if none provided + $content = $content ?: $oldFileInfo->getContents(); + $this->movedFiles[] = new MovedClassValueObject( $oldFileInfo->getRelativeFilePath(), $newFileLocation, diff --git a/src/Configuration/Configuration.php b/src/Configuration/Configuration.php index 8cb0571e160d..52f76d60af6f 100644 --- a/src/Configuration/Configuration.php +++ b/src/Configuration/Configuration.php @@ -7,6 +7,7 @@ use Rector\Console\Output\JsonOutputFormatter; use Rector\Exception\Rector\RectorNotFoundOrNotValidRectorClassException; use Rector\Rector\AbstractRector; +use Rector\Testing\PHPUnit\PHPUnitEnvironment; use Symfony\Component\Console\Input\InputInterface; use Symplify\PackageBuilder\Configuration\ConfigFileFinder; @@ -37,6 +38,11 @@ final class Configuration */ private $rule; + /** + * @var bool + */ + private $areAnyPhpRectorsLoaded = false; + /** * Needs to run in the start of the life cycle, since the rest of workflow uses it. */ @@ -104,6 +110,20 @@ public function getRule(): ?string return $this->rule; } + public function areAnyPhpRectorsLoaded(): bool + { + if (PHPUnitEnvironment::isPHPUnitRun()) { + return true; + } + + return $this->areAnyPhpRectorsLoaded; + } + + public function setAreAnyPhpRectorsLoaded(bool $areAnyPhpRectorsLoaded): void + { + $this->areAnyPhpRectorsLoaded = $areAnyPhpRectorsLoaded; + } + private function canShowProgressBar(InputInterface $input): bool { return $input->getOption(Option::OPTION_OUTPUT_FORMAT) !== JsonOutputFormatter::NAME; diff --git a/src/Console/Command/ProcessCommand.php b/src/Console/Command/ProcessCommand.php index e1f81ee71d5c..c4d4c3cc5d20 100644 --- a/src/Console/Command/ProcessCommand.php +++ b/src/Console/Command/ProcessCommand.php @@ -13,6 +13,7 @@ use Rector\Extension\ReportingExtensionRunner; use Rector\FileSystem\FilesFinder; use Rector\Guard\RectorGuard; +use Rector\PhpParser\NodeTraverser\RectorNodeTraverser; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -66,6 +67,11 @@ final class ProcessCommand extends AbstractCommand */ private $reportingExtensionRunner; + /** + * @var RectorNodeTraverser + */ + private $rectorNodeTraverser; + /** * @param string[] $fileExtensions */ @@ -78,6 +84,7 @@ public function __construct( RectorApplication $rectorApplication, OutputFormatterCollector $outputFormatterCollector, ReportingExtensionRunner $reportingExtensionRunner, + RectorNodeTraverser $rectorNodeTraverser, array $fileExtensions ) { $this->filesFinder = $phpFilesFinder; @@ -89,6 +96,7 @@ public function __construct( $this->fileExtensions = $fileExtensions; $this->outputFormatterCollector = $outputFormatterCollector; $this->reportingExtensionRunner = $reportingExtensionRunner; + $this->rectorNodeTraverser = $rectorNodeTraverser; parent::__construct(); } @@ -137,6 +145,7 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { $this->configuration->resolveFromInput($input); + $this->configuration->setAreAnyPhpRectorsLoaded((bool) $this->rectorNodeTraverser->getPhpRectorCount()); $this->rectorGuard->ensureSomeRectorsAreRegistered(); diff --git a/src/Exception/ShouldNotHappenException.php b/src/Exception/ShouldNotHappenException.php index 0e3fe42131c1..a85e3ebd6f7b 100644 --- a/src/Exception/ShouldNotHappenException.php +++ b/src/Exception/ShouldNotHappenException.php @@ -20,8 +20,8 @@ private function createDefaultMessageWithLocation(): string { $debugBacktrace = debug_backtrace(); - $class = $debugBacktrace[1]['class'] ?? null; - $function = $debugBacktrace[1]['function']; + $class = $debugBacktrace[2]['class'] ?? null; + $function = $debugBacktrace[2]['function']; $line = $debugBacktrace[1]['line']; $method = $class ? ($class . '::' . $function) : $function; diff --git a/src/Guard/RectorGuard.php b/src/Guard/RectorGuard.php index 80d45816a959..f2a759271e7e 100644 --- a/src/Guard/RectorGuard.php +++ b/src/Guard/RectorGuard.php @@ -28,7 +28,7 @@ public function __construct( public function ensureSomeRectorsAreRegistered(): void { - if ($this->rectorNodeTraverser->getRectorCount() > 0) { + if ($this->rectorNodeTraverser->getPhpRectorCount() > 0) { return; } diff --git a/src/Naming/NamespaceMatcher.php b/src/Naming/NamespaceMatcher.php new file mode 100644 index 000000000000..0b3a53dd4517 --- /dev/null +++ b/src/Naming/NamespaceMatcher.php @@ -0,0 +1,26 @@ + $newNamespace) { + if (Strings::startsWith($name, $oldNamespace)) { + return new RenamedNamespaceValueObject($name, $oldNamespace, $newNamespace); + } + } + + return null; + } +} diff --git a/src/PhpParser/NodeTraverser/RectorNodeTraverser.php b/src/PhpParser/NodeTraverser/RectorNodeTraverser.php index 51327e3ac32d..e0ae12fc0331 100644 --- a/src/PhpParser/NodeTraverser/RectorNodeTraverser.php +++ b/src/PhpParser/NodeTraverser/RectorNodeTraverser.php @@ -52,19 +52,11 @@ public function traverse(array $nodes): array return parent::traverse($nodes); } - public function getRectorCount(): int + public function getPhpRectorCount(): int { return count($this->visitors); } - /** - * @return PhpRectorInterface[] - */ - public function getRectors(): array - { - return $this->visitors; - } - /** * Mostly used for testing */ diff --git a/src/Rector/AbstractRector.php b/src/Rector/AbstractRector.php index bc99b05c9bd7..7ded9ae3d7d4 100644 --- a/src/Rector/AbstractRector.php +++ b/src/Rector/AbstractRector.php @@ -132,6 +132,9 @@ public function afterTraverse(array $nodes): array $nodes = $this->useAddingCommander->traverseNodes($nodes); } + // @todo name node importing + // @todo class like renaming + $this->tearDown(); return $nodes; diff --git a/src/Rector/Class_/RenameClassRector.php b/src/Rector/Class_/RenameClassRector.php index d9b8e0c2a970..a66a64725627 100644 --- a/src/Rector/Class_/RenameClassRector.php +++ b/src/Rector/Class_/RenameClassRector.php @@ -230,7 +230,9 @@ private function getClassOfNamespaceToRefactor(Namespace_ $namespace): ?ClassLik return false; } - return isset($this->oldToNewClasses[$this->getName($node)]); + $classLikeName = $this->getName($node); + + return isset($this->oldToNewClasses[$classLikeName]); }); return $foundClass instanceof ClassLike ? $foundClass : null; diff --git a/src/Rector/Namespace_/RenameNamespaceRector.php b/src/Rector/Namespace_/RenameNamespaceRector.php index ce8012c7430e..ead64fd587c0 100644 --- a/src/Rector/Namespace_/RenameNamespaceRector.php +++ b/src/Rector/Namespace_/RenameNamespaceRector.php @@ -9,10 +9,12 @@ use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt\Namespace_; use PhpParser\Node\Stmt\Use_; +use Rector\Naming\NamespaceMatcher; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Rector\AbstractRector; use Rector\RectorDefinition\ConfiguredCodeSample; use Rector\RectorDefinition\RectorDefinition; +use Rector\ValueObject\RenamedNamespaceValueObject; /** * @see \Rector\Tests\Rector\Namespace_\RenameNamespaceRector\RenameNamespaceRectorTest @@ -24,12 +26,18 @@ final class RenameNamespaceRector extends AbstractRector */ private $oldToNewNamespaces = []; + /** + * @var NamespaceMatcher + */ + private $namespaceMatcher; + /** * @param string[] $oldToNewNamespaces */ - public function __construct(array $oldToNewNamespaces = []) + public function __construct(NamespaceMatcher $namespaceMatcher, array $oldToNewNamespaces = []) { $this->oldToNewNamespaces = $oldToNewNamespaces; + $this->namespaceMatcher = $namespaceMatcher; } public function getDefinition(): RectorDefinition @@ -65,7 +73,8 @@ public function refactor(Node $node): ?Node return null; } - if (! $this->isNamespaceToChange($name)) { + $renamedNamespaceValueObject = $this->namespaceMatcher->matchRenamedNamespace($name, $this->oldToNewNamespaces); + if ($renamedNamespaceValueObject === null) { return null; } @@ -74,35 +83,28 @@ public function refactor(Node $node): ?Node } if ($node instanceof Namespace_) { - $newName = $this->resolveNewNameFromNode($name); + $newName = $renamedNamespaceValueObject->getNameInNewNamespace(); $node->name = new Name($newName); return $node; } if ($node instanceof Use_) { - $newName = $this->resolveNewNameFromNode($name); + $newName = $renamedNamespaceValueObject->getNameInNewNamespace(); $node->uses[0]->name = new Name($newName); return $node; } $newName = $this->isPartialNamespace($node) ? $this->resolvePartialNewName( - $node - ) : $this->resolveNewNameFromNode($name); - + $node, + $renamedNamespaceValueObject + ) : $renamedNamespaceValueObject->getNameInNewNamespace(); if ($newName === null) { return null; } - $node->parts = explode('\\', $newName); - - return $node; - } - - private function isNamespaceToChange(string $namespace): bool - { - return (bool) $this->getNewNamespaceForOldOne($namespace); + return new FullyQualified($newName); } /** @@ -128,13 +130,6 @@ private function isClassFullyQualifiedName(Node $node): bool return array_key_exists($newClassName, $this->oldToNewNamespaces); } - private function resolveNewNameFromNode(string $name): string - { - [$oldNamespace, $newNamespace] = $this->getNewNamespaceForOldOne($name); - - return str_replace($oldNamespace, $newNamespace, $name); - } - private function isPartialNamespace(Name $name): bool { $resolvedName = $name->getAttribute(AttributeKey::RESOLVED_NAME); @@ -149,42 +144,20 @@ private function isPartialNamespace(Name $name): bool return false; } - private function resolvePartialNewName(Name $name): ?string - { + private function resolvePartialNewName( + Name $name, + RenamedNamespaceValueObject $renamedNamespaceValueObject + ): ?string { $nodeName = $this->getName($name); if ($nodeName === null) { return null; } - $completeNewName = $this->resolveNewNameFromNode($nodeName); + $completeNewName = $renamedNamespaceValueObject->getNameInNewNamespace(); // first dummy implementation - improve $cutOffFromTheLeft = Strings::length($completeNewName) - Strings::length($name->toString()); return Strings::substring($completeNewName, $cutOffFromTheLeft); } - - /** - * @return string[] - */ - private function getNewNamespaceForOldOne(string $namespace): array - { - /** @var string $oldNamespace */ - foreach ($this->getOldToNewNamespaces() as $oldNamespace => $newNamespace) { - if (Strings::startsWith($namespace, $oldNamespace)) { - return [$oldNamespace, $newNamespace]; - } - } - - return []; - } - - /** - * @return string[] - */ - private function getOldToNewNamespaces(): array - { - krsort($this->oldToNewNamespaces); - return $this->oldToNewNamespaces; - } } diff --git a/src/ValueObject/RenamedNamespaceValueObject.php b/src/ValueObject/RenamedNamespaceValueObject.php new file mode 100644 index 000000000000..aa10dbc4146e --- /dev/null +++ b/src/ValueObject/RenamedNamespaceValueObject.php @@ -0,0 +1,43 @@ +currentName = $currentNamespaceName; + $this->oldNamespace = $oldNamespace; + $this->newNamespace = $newNamespace; + } + + public function getNameInNewNamespace(): string + { + return str_replace($this->oldNamespace, $this->newNamespace, $this->currentName); + } + + public function getOldNamespace(): string + { + return $this->oldNamespace; + } + + public function getNewNamespace(): string + { + return $this->newNamespace; + } +} diff --git a/tests/Rector/MagicDisclosure/GetAndSetToMethodCallRector/Fixture/fixture3.php.inc b/tests/Rector/MagicDisclosure/GetAndSetToMethodCallRector/Fixture/fixture3.php.inc deleted file mode 100644 index 4e107d8bdaf5..000000000000 --- a/tests/Rector/MagicDisclosure/GetAndSetToMethodCallRector/Fixture/fixture3.php.inc +++ /dev/null @@ -1,11 +0,0 @@ -engine = $engine; - } -} diff --git a/tests/Rector/MagicDisclosure/GetAndSetToMethodCallRector/GetAndSetToMethodCallRectorTest.php b/tests/Rector/MagicDisclosure/GetAndSetToMethodCallRector/GetAndSetToMethodCallRectorTest.php index ee7c10643cfb..32f56391a9c8 100644 --- a/tests/Rector/MagicDisclosure/GetAndSetToMethodCallRector/GetAndSetToMethodCallRectorTest.php +++ b/tests/Rector/MagicDisclosure/GetAndSetToMethodCallRector/GetAndSetToMethodCallRectorTest.php @@ -24,7 +24,6 @@ public function provideDataForTest(): iterable { yield [__DIR__ . '/Fixture/get.php.inc']; yield [__DIR__ . '/Fixture/fixture2.php.inc']; - yield [__DIR__ . '/Fixture/fixture3.php.inc']; yield [__DIR__ . '/Fixture/klarka.php.inc']; } @@ -40,10 +39,6 @@ protected function getRectorsWithConfiguration(): array 'get' => 'getService', 'set' => 'addService', ], - 'Enlight_View_Default' => [ - 'get' => 'getService', - 'set' => 'addService', - ], Klarka::class => [ 'get' => 'get', ], diff --git a/tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture/fixture.php.inc b/tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture/fixture.php.inc index ad03d527f550..2c521140aac3 100644 --- a/tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture/fixture.php.inc +++ b/tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture/fixture.php.inc @@ -1,15 +1,21 @@ ------ - diff --git a/tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture/fixture3.php.inc b/tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture/fixture3.php.inc deleted file mode 100644 index b504f550550f..000000000000 --- a/tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture/fixture3.php.inc +++ /dev/null @@ -1,29 +0,0 @@ - ------ - diff --git a/tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture/skip.php.inc b/tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture/skip.php.inc new file mode 100644 index 000000000000..b43e3e23ed9a --- /dev/null +++ b/tests/Rector/MethodBody/ReturnThisRemoveRector/Fixture/skip.php.inc @@ -0,0 +1,18 @@ + [ '$classesToDefluent' => [ - 'Rector\Tests\Rector\MethodBody\ReturnThisRemoveRector\SomeClass', - 'Rector\Tests\Rector\MethodBody\ReturnThisRemoveRector\SomeClassWithReturnAnnotations', + 'Rector\Tests\Rector\MethodBody\ReturnThisRemoveRector\Fixture\SomeClass', + 'Rector\Tests\Rector\MethodBody\ReturnThisRemoveRector\Fixture\SomeClassWithReturnAnnotations', ], ], ]; From 2858a9f7eaffaeb24fd5324aa385cf96fd46b31b Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 23 Sep 2019 13:43:13 +0200 Subject: [PATCH 4/4] [PHP] Move tests + fixture to split package by version --- composer.json | 10 ++++- config/set/celebrity/celebrity.yaml | 3 +- config/set/code-quality/code-quality.yaml | 2 +- config/set/coding-style/coding-style.yaml | 2 +- .../Fixture/skip.php.inc | 6 --- .../Fixture/array_countable_class.php.inc | 12 ------ .../Fixture/fixture.php.inc | 17 -------- .../Fixture/better_func_get_all.php.inc | 31 -------------- .../Fixture/external_scope.php.inc | 10 ----- .../Fixture/fixture.php.inc | 21 ---------- .../Fixture/class_property.php.inc | 31 -------------- .../Fixture/nullable_property.php.inc | 41 ------------------- .../Fixture/static_property.php.inc | 31 -------------- .../Source/AnotherClass.php | 8 ---- .../Fixture/fixture.php.inc | 35 ---------------- .../Fixture/pre_slash.php.inc | 27 ------------ .../Fixture/skip_sensitive.php.inc | 27 ------------ .../Fixture/skip_slashes.php.inc | 13 ------ .../Property/VarToPublicPropertyRector.php | 2 +- .../Switch_/ContinueToBreakInSwitchRector.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../VarToPublicPropertyRectorTest.php | 2 +- .../ContinueToBreakInSwitchRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/skip_nested.php.inc | 2 +- .../Rector/Ternary/TernaryToElvisRector.php | 2 +- .../Fixture/fixture.php.inc | 0 .../TernaryToElvisRector/Fixture/yolo.php.inc | 0 .../TernaryToElvisRectorTest.php | 2 +- .../RemoveReferenceFromCallRector.php | 2 +- .../Fixture/fixture.php.inc | 21 ++++++++++ .../RemoveReferenceFromCallRectorTest.php | 2 +- .../StringClassNameToClassConstantRector.php | 2 +- .../Fixture/fixture.php.inc | 37 +++++++++++++++++ .../Fixture/skip_error.php.inc | 2 +- .../Fixture/skip_sensitive.php.inc | 27 ++++++++++++ .../Source/AnotherClass.php | 8 ++++ ...ringClassNameToClassConstantRectorTest.php | 4 +- .../src/Rector/FuncCall/PowToExpRector.php | 2 +- ...DefaultValueForUndefinedVariableRector.php | 2 +- .../PowToExpRector/Fixture/fixture.php.inc | 4 +- .../PowToExpRector/PowToExpRectorTest.php | 2 +- ...ultValueForUndefinedVariableRectorTest.php | 2 +- .../Fixture/anonymous_function.php.inc | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/in_foreach.php.inc | 4 +- .../Fixture/keep_vimeo_unset.php.inc | 2 +- .../Fixture/skip_foreach_assign.php.inc | 2 +- .../Fixture/skip_list.php.inc | 2 +- .../Fixture/skip_reference_assign.php.inc | 2 +- .../Fixture/take_static_into_account.php.inc | 2 +- .../Fixture/vimeo_else.php.inc | 4 +- .../Fixture/vimeo_one.php.inc | 4 +- .../Fixture/vimeo_two.php.inc | 4 +- .../BreakNotInLoopOrSwitchToReturnRector.php | 2 +- .../Rector/FuncCall/CallUserMethodRector.php | 2 +- .../Rector/FuncCall/EregToPregMatchRector.php | 2 +- .../Rector/FuncCall/MultiDirnameRector.php | 2 +- .../Rector/FuncCall/RandomFunctionRector.php | 2 +- .../RenameMktimeWithoutArgsToTimeRector.php | 2 +- .../ExceptionHandlerTypehintRector.php | 2 +- .../FunctionLike/Php4ConstructorRector.php | 2 +- .../src/Rector/If_/IfToSpaceshipRector.php | 2 +- .../src/Rector/List_/EmptyListRector.php | 2 +- .../Rector/List_/ListSplitStringRector.php | 2 +- .../Rector/List_/ListSwapArrayOrderRector.php | 2 +- ...isCallOnStaticMethodToStaticCallRector.php | 2 +- ...ticCallOnNonStaticToInstanceCallRector.php | 2 +- .../ReduceMultipleDefaultSwitchRector.php | 2 +- .../Ternary/TernaryToNullCoalescingRector.php | 2 +- .../Ternary/TernaryToSpaceshipRector.php | 2 +- ...eakNotInLoopOrSwitchToReturnRectorTest.php | 2 +- .../Fixture/Keep.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/foreach_not.php.inc | 4 +- .../Fixture/return.php.inc | 4 +- .../CallUserMethodRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../EregToPregMatchRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/fixture2.php.inc | 4 +- .../Fixture/fixture3.php.inc | 4 +- .../Fixture/fixture4.php.inc | 4 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/fixture2.php.inc | 4 +- .../Fixture/fixture3.php.inc | 4 +- .../MultiDirnameRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../RandomFunctionRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- ...enameMktimeWithoutArgsToTimeRectorTest.php | 2 +- .../ExceptionHandlerTypehintRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/fixture_nullable.php.inc | 4 +- .../Fixture/complex.php.inc | 4 +- .../Fixture/fixture.php.inc | 4 +- .../IfToSpaceshipRector/Fixture/skip.php.inc | 2 +- .../IfToSpaceshipRectorTest.php | 2 +- .../EmptyListRector/EmptyListRectorTest.php | 2 +- .../EmptyListRector/Fixture/fixture.php.inc | 4 +- .../Fixture/fixture.php.inc | 4 +- .../ListSplitStringRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/skip.php.inc | 2 +- .../Fixture/skip_empty.php.inc | 4 +- .../ListSwapArrayOrderRectorTest.php | 2 +- .../Fixture/another_call.php.inc | 2 +- .../Fixture/fixture.php.inc | 4 +- ...llOnStaticMethodToStaticCallRectorTest.php | 2 +- .../Fixture/add_static_to_method.php.inc | 4 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/keep.php.inc | 2 +- .../Fixture/keep_annotated.php.inc | 2 +- .../Fixture/keep_parent_static.php.inc | 2 +- .../Fixture/with_constructor.php.inc | 2 +- .../Fixture/with_only_static_methods.php.inc | 4 +- .../Source/WithOnlyStaticMethods.php | 2 +- ...allOnNonStaticToInstanceCallRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/hidden_in_middle.php.inc | 4 +- .../ReduceMultipleDefaultSwitchRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/fixture2.php.inc | 4 +- .../Fixture/fixture3.php.inc | 4 +- .../Fixture/fixture4.php.inc | 4 +- .../TernaryToNullCoalescingRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../TernaryToSpaceshipRectorTest.php | 2 +- .../Assign/AssignArrayToStringRector.php | 2 +- .../BinaryOpBetweenNumberAndStringRector.php | 2 +- .../src/Rector/BinaryOp/IsIterableRector.php | 2 +- .../PublicConstantVisibilityRector.php | 2 +- .../src/Rector/FuncCall/CountOnNullRector.php | 2 +- .../FuncCall/RemoveExtraParametersRector.php | 2 +- .../TryCatch/MultiExceptionCatchRector.php | 2 +- .../AssignArrayToStringRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/fixture2.php.inc | 4 +- .../Fixture/fixture3.php.inc | 4 +- .../Fixture/fixture4.php.inc | 4 +- .../Fixture/fixture5.php.inc | 4 +- .../Fixture/fixture6.php.inc | 4 +- .../Fixture/fixture7.php.inc | 4 +- .../Fixture/fixture8.php.inc | 4 +- .../Fixture/skip.php.inc | 6 +++ ...naryOpBetweenNumberAndStringRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/ignore_concatenation_dot.php.inc | 2 +- .../IsIterableRector/Fixture/fixture.php.inc | 4 +- .../Fixture/polyfill_function.php.inc | 4 +- .../IsIterableRector/IsIterableRectorTest.php | 2 +- .../IsIterableRector/PolyfillRectorTest.php | 2 +- .../Fixture/SomeClass.php.inc | 4 +- .../PublicConstantVisibilityRectorTest.php | 2 +- .../CountOnNullRectorTest.php | 2 +- .../CountOnNullRectorWithPHP73Test.php | 2 +- .../Fixture/array_countable_class.php.inc | 12 ++++++ .../countable_annotated_params.php.inc | 2 +- .../Fixture/double_same_variable.php.inc | 2 +- .../Fixture/external_property.php.inc | 2 +- .../Fixture/false_true_class.php.inc | 4 +- .../Fixture/is_countable.php.inc | 4 +- .../Fixture/local_property.php.inc | 4 +- .../Fixture/nullable_array.php.inc | 4 +- .../CountOnNullRector/Fixture/on_null.php.inc | 4 +- .../Fixture/preg_match_array.php.inc | 2 +- .../Fixture/property_with_doc.php.inc | 4 +- .../Fixture/skip_array_merge.php.inc | 2 +- .../skip_countable_local_property.php.inc | 2 +- .../Source/CountableClass.php | 2 +- .../Fixture/better_func_get_all.php.inc | 31 ++++++++++++++ .../Fixture/external_scope.php.inc | 10 +++++ .../Fixture/fixture.php.inc | 4 +- .../Fixture/func_get_all.php.inc | 2 +- ...equired_and_one_optional_parameter.php.inc | 4 +- .../Fixture/methods.php.inc | 4 +- ...r_class_method_call_extra_argument.php.inc | 4 +- .../Fixture/skip_call_user_func_array.php.inc | 2 +- ...skip_commented_param_func_get_args.php.inc | 4 +- .../Fixture/skip_invoke.php.inc | 2 +- .../Fixture/static_call_parent.php.inc | 4 +- .../Fixture/static_calls.php.inc | 4 +- .../RemoveExtraParametersRectorTest.php | 2 +- .../Source/ChildOrmion.php | 2 +- .../RemoveExtraParametersRector/Source/Db.php | 2 +- .../Source/MagicEventDispatcher.php | 2 +- .../Source/MethodWithFuncGetArgs.php | 2 +- .../Source/Ormion.php | 4 +- .../Fixture/fixture.php.inc | 4 +- .../MultiExceptionCatchRectorTest.php | 2 +- .../ConstFetch/BarewordStringRector.php | 2 +- ...reateFunctionToAnonymousFunctionRector.php | 2 +- .../Rector/FuncCall/GetClassOnNullRector.php | 2 +- .../IsObjectOnIncompleteClassRector.php | 2 +- .../ParseStrWithResultArgumentRector.php | 2 +- .../Rector/FuncCall/StringifyDefineRector.php | 2 +- .../FuncCall/StringsAssertNakedRector.php | 2 +- .../src/Rector/Unset_/UnsetCastRector.php | 2 +- .../BarewordStringRectorTest.php | 2 +- .../Fixture/define.php.inc | 4 +- .../Fixture/fixture.php.inc | 4 +- .../tests/Rector/Each/EachRectorTest.php | 2 +- .../tests/Rector/Each/Fixture/fixture.php.inc | 4 +- .../Rector/Each/Fixture/fixture2.php.inc | 4 +- .../Rector/Each/Fixture/fixture3.php.inc | 4 +- ...eFunctionToAnonymousFunctionRectorTest.php | 2 +- .../Fixture/concat.php.inc | 4 +- .../Fixture/drupal.php.inc | 4 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/php_net.php.inc | 4 +- .../Fixture/reference.php.inc | 4 +- .../Fixture/stackoverflow.php.inc | 4 +- .../Fixture/wordpress.php.inc | 4 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/tricky_cases.php.inc | 4 +- .../GetClassOnNullRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../IsObjectOnIncompleteClassRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/skip_already_set.php.inc | 2 +- .../ParseStrWithResultArgumentRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../StringifyDefineRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../StringsAssertNakedRectorTest.php | 2 +- .../UnsetCastRector/Fixture/fixture.php.inc | 4 +- .../UnsetCastRector/UnsetCastRectorTest.php | 2 +- .../src/Rector/BinaryOp/IsCountableRector.php | 2 +- .../SensitiveConstantNameRector.php | 2 +- .../FuncCall/ArrayKeyFirstLastRector.php | 2 +- .../FuncCall/JsonThrowOnErrorRector.php | 2 +- .../Rector/FuncCall/RegexDashEscapeRector.php | 2 +- .../RemoveMissingCompactVariableRector.php | 2 +- .../Rector/FuncCall/SensitiveDefineRector.php | 2 +- .../FuncCall/StringifyStrNeedlesRector.php | 2 +- .../String_/SensitiveHereNowDocRector.php | 2 +- .../Fixture/fixture71.php.inc | 2 +- .../Fixture/fixture73.php.inc | 4 +- .../Fixture/polyfill_function.php.inc | 4 +- .../IsCountableRectorTest.php | 2 +- .../IsCountableRector/PolyfillRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../SensitiveConstantNameRectorTest.php | 2 +- .../ArrayKeyFirstLastRectorTest.php | 2 +- .../Fixture/array_key_first.php.inc | 4 +- .../Fixture/array_key_last.php.inc | 4 +- .../Fixture/both.php.inc | 4 +- .../Fixture/fixture.php.inc | 4 +- .../JsonThrowOnErrorRectorTest.php | 2 +- .../Fixture/const.php.inc | 4 +- .../Fixture/external_const.php.inc | 4 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/method_call.php.inc | 4 +- .../Fixture/multiple_variables.php.inc | 4 +- .../Fixture/variable.php.inc | 4 +- .../RegexDashEscapeRectorTest.php | 2 +- .../Fixture/empty_compact.php.inc | 4 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/skip_maybe_defined.inc | 2 +- ...RemoveMissingCompactVariableRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../SensitiveDefineRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/skip_twice.php.inc | 2 +- .../Fixture/trait.php.inc | 4 +- .../StringifyStrNeedlesRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../SensitiveHereNowDocRectorTest.php | 2 +- .../Assign/NullCoalescingOperatorRector.php | 2 +- .../Closure/ClosureToArrowFunctionRector.php | 2 +- .../Double/RealToFloatTypeCastRector.php | 2 +- .../ArrayKeyExistsOnPropertyRector.php | 2 +- .../ArraySpreadInsteadOfArrayMergeRector.php | 2 +- .../FuncCall/FilterVarToAddSlashesRector.php | 2 +- .../GetCalledClassToStaticClassRector.php | 2 +- ...bStrrposEncodingArgumentPositionRector.php | 2 +- .../Function_/ReservedFnFunctionRector.php | 2 +- .../AddLiteralSeparatorToNumberRector.php | 2 +- .../ClassConstantToSelfClassRector.php | 2 +- .../Rector/Property/TypedPropertyRector.php | 2 +- .../ExportToReflectionFunctionRector.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../NullCoalescingOperatorRectorTest.php | 2 +- .../ClosureToArrowFunctionRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/referenced_but_not_used.php.inc | 4 +- .../Fixture/skip_no_return.php.inc | 2 +- .../Fixture/skip_referenced_value.php.inc | 2 +- .../Fixture/fixture.php.inc | 4 +- .../RealToFloatTypeCastRectorTest.php | 2 +- .../ArrayKeyExistsOnPropertyRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- ...raySpreadInsteadOfArrayMergeRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/integer_keys.php.inc | 4 +- .../Fixture/iterator_to_array.php.inc | 4 +- .../Fixture/skip_simple_array_merge.php.inc | 2 +- .../Fixture/skip_string_keys.php.inc | 2 +- .../FilterVarToAddSlashesRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 17 ++++++++ .../Fixture/fixture.php.inc | 4 +- .../GetCalledClassToStaticClassRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- ...rposEncodingArgumentPositionRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../AddLiteralSeparatorToNumberRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/skip_hexadecimal.php.inc | 2 +- .../skip_non_dec_simple_float_numbers.php.inc | 2 +- .../ClassConstantToSelfClassRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../Fixture/bool_property.php.inc | 4 +- .../Fixture/class_property.php.inc | 31 ++++++++++++++ .../Fixture/default_values.php.inc | 4 +- ...ault_values_for_nullable_iterables.php.inc | 4 +- .../Fixture/match_types.php.inc | 4 +- .../Fixture/match_types_parent.php.inc | 4 +- .../Fixture/nullable_property.php.inc | 41 +++++++++++++++++++ .../Fixture/property.php.inc | 4 +- .../Fixture/skip_invalid_property.php.inc | 2 +- .../Fixture/static_analysis_based.php.inc | 4 +- .../Fixture/static_property.php.inc | 31 ++++++++++++++ .../TypedPropertyRectorTest.php | 2 +- .../ExportToReflectionFunctionRectorTest.php | 2 +- .../Fixture/fixture.php.inc | 4 +- .../CompleteVarDocTypePropertyRector.php | 2 +- .../CompleteVarDocTypePropertyRectorTest.php | 2 +- .../Fixture/assign_conflict.php.inc | 6 +-- .../Fixture/callable_type.php.inc | 4 +- .../Fixture/default_value.php.inc | 4 +- .../Fixture/property_assign.php.inc | 4 +- .../Fixture/symfony_console_command.php.inc | 4 +- .../Fixture/typed_array.php.inc | 4 +- .../Fixture/typed_array_nested.php.inc | 4 +- .../Source/EventDispatcher.php | 0 .../Source/AnotherClass.php | 8 ++++ rector.yaml | 13 +++--- renames-rector.yaml | 5 +++ 338 files changed, 741 insertions(+), 758 deletions(-) delete mode 100644 packages/Php/tests/Rector/Assign/AssignArrayToStringRector/Fixture/skip.php.inc delete mode 100644 packages/Php/tests/Rector/FuncCall/CountOnNullRector/Fixture/array_countable_class.php.inc delete mode 100644 packages/Php/tests/Rector/FuncCall/FilterVarToAddSlashesRector/Fixture/fixture.php.inc delete mode 100644 packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/better_func_get_all.php.inc delete mode 100644 packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/external_scope.php.inc delete mode 100644 packages/Php/tests/Rector/FuncCall/RemoveReferenceFromCallRector/Fixture/fixture.php.inc delete mode 100644 packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/class_property.php.inc delete mode 100644 packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/nullable_property.php.inc delete mode 100644 packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/static_property.php.inc delete mode 100644 packages/Php/tests/Rector/Property/TypedPropertyRector/Source/AnotherClass.php delete mode 100644 packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/fixture.php.inc delete mode 100644 packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/pre_slash.php.inc delete mode 100644 packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_sensitive.php.inc delete mode 100644 packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_slashes.php.inc rename packages/{Php => Php52}/tests/Rector/Property/VarToPublicPropertyRector/Fixture/fixture.php.inc (53%) rename packages/{Php => Php52}/tests/Rector/Property/VarToPublicPropertyRector/VarToPublicPropertyRectorTest.php (89%) rename packages/{Php => Php52}/tests/Rector/Switch_/ContinueToBreakInSwitchRector/ContinueToBreakInSwitchRectorTest.php (90%) rename packages/{Php => Php52}/tests/Rector/Switch_/ContinueToBreakInSwitchRector/Fixture/fixture.php.inc (69%) rename packages/{Php => Php52}/tests/Rector/Switch_/ContinueToBreakInSwitchRector/Fixture/skip_nested.php.inc (79%) rename packages/{CodeQuality => Php53}/tests/Rector/Ternary/TernaryToElvisRector/Fixture/fixture.php.inc (100%) rename packages/{CodeQuality => Php53}/tests/Rector/Ternary/TernaryToElvisRector/Fixture/yolo.php.inc (100%) rename packages/{CodeQuality => Php53}/tests/Rector/Ternary/TernaryToElvisRector/TernaryToElvisRectorTest.php (90%) create mode 100644 packages/Php54/tests/Rector/FuncCall/RemoveReferenceFromCallRector/Fixture/fixture.php.inc rename packages/{Php => Php54}/tests/Rector/FuncCall/RemoveReferenceFromCallRector/RemoveReferenceFromCallRectorTest.php (89%) create mode 100644 packages/Php55/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/fixture.php.inc rename packages/{Php => Php55}/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_error.php.inc (56%) create mode 100644 packages/Php55/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_sensitive.php.inc create mode 100644 packages/Php55/tests/Rector/String_/StringClassNameToClassConstantRector/Source/AnotherClass.php rename packages/{Php => Php55}/tests/Rector/String_/StringClassNameToClassConstantRector/StringClassNameToClassConstantRectorTest.php (80%) rename packages/{Php => Php56}/tests/Rector/FuncCall/PowToExpRector/Fixture/fixture.php.inc (82%) rename packages/{Php => Php56}/tests/Rector/FuncCall/PowToExpRector/PowToExpRectorTest.php (92%) rename packages/{Php => Php56}/tests/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector/AddDefaultValueForUndefinedVariableRectorTest.php (93%) rename packages/{Php => Php56}/tests/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector/Fixture/anonymous_function.php.inc (77%) rename packages/{Php => Php56}/tests/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector/Fixture/fixture.php.inc (60%) rename packages/{Php => Php56}/tests/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector/Fixture/in_foreach.php.inc (63%) rename packages/{Php => Php56}/tests/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector/Fixture/keep_vimeo_unset.php.inc (60%) rename packages/{Php => Php56}/tests/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector/Fixture/skip_foreach_assign.php.inc (74%) rename packages/{Php => Php56}/tests/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector/Fixture/skip_list.php.inc (61%) rename packages/{Php => Php56}/tests/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector/Fixture/skip_reference_assign.php.inc (68%) rename packages/{Php => Php56}/tests/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector/Fixture/take_static_into_account.php.inc (70%) rename packages/{Php => Php56}/tests/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector/Fixture/vimeo_else.php.inc (66%) rename packages/{Php => Php56}/tests/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector/Fixture/vimeo_one.php.inc (80%) rename packages/{Php => Php56}/tests/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector/Fixture/vimeo_two.php.inc (66%) rename packages/{Php => Php70}/tests/Rector/Break_/BreakNotInLoopOrSwitchToReturnRector/BreakNotInLoopOrSwitchToReturnRectorTest.php (91%) rename packages/{Php => Php70}/tests/Rector/Break_/BreakNotInLoopOrSwitchToReturnRector/Fixture/Keep.php (80%) rename packages/{Php => Php70}/tests/Rector/Break_/BreakNotInLoopOrSwitchToReturnRector/Fixture/fixture.php.inc (85%) rename packages/{Php => Php70}/tests/Rector/Break_/BreakNotInLoopOrSwitchToReturnRector/Fixture/foreach_not.php.inc (77%) rename packages/{Php => Php70}/tests/Rector/Break_/BreakNotInLoopOrSwitchToReturnRector/Fixture/return.php.inc (78%) rename packages/{Php => Php70}/tests/Rector/FuncCall/CallUserMethodRector/CallUserMethodRectorTest.php (91%) rename packages/{Php => Php70}/tests/Rector/FuncCall/CallUserMethodRector/Fixture/fixture.php.inc (73%) rename packages/{Php => Php70}/tests/Rector/FuncCall/EregToPregMatchRector/EregToPregMatchRectorTest.php (92%) rename packages/{Php => Php70}/tests/Rector/FuncCall/EregToPregMatchRector/Fixture/fixture.php.inc (72%) rename packages/{Php => Php70}/tests/Rector/FuncCall/EregToPregMatchRector/Fixture/fixture2.php.inc (65%) rename packages/{Php => Php70}/tests/Rector/FuncCall/EregToPregMatchRector/Fixture/fixture3.php.inc (68%) rename packages/{Php => Php70}/tests/Rector/FuncCall/EregToPregMatchRector/Fixture/fixture4.php.inc (74%) rename packages/{Php => Php70}/tests/Rector/FuncCall/MultiDirnameRector/Fixture/fixture.php.inc (78%) rename packages/{Php => Php70}/tests/Rector/FuncCall/MultiDirnameRector/Fixture/fixture2.php.inc (64%) rename packages/{Php => Php70}/tests/Rector/FuncCall/MultiDirnameRector/Fixture/fixture3.php.inc (62%) rename packages/{Php => Php70}/tests/Rector/FuncCall/MultiDirnameRector/MultiDirnameRectorTest.php (92%) rename packages/{Php => Php70}/tests/Rector/FuncCall/RandomFunctionRector/Fixture/fixture.php.inc (82%) rename packages/{Php => Php70}/tests/Rector/FuncCall/RandomFunctionRector/RandomFunctionRectorTest.php (91%) rename packages/{Php => Php70}/tests/Rector/FuncCall/RenameMktimeWithoutArgsToTimeRector/Fixture/fixture.php.inc (60%) rename packages/{Php => Php70}/tests/Rector/FuncCall/RenameMktimeWithoutArgsToTimeRector/RenameMktimeWithoutArgsToTimeRectorTest.php (89%) rename packages/{Php => Php70}/tests/Rector/FunctionLike/ExceptionHandlerTypehintRector/ExceptionHandlerTypehintRectorTest.php (89%) rename packages/{Php => Php70}/tests/Rector/FunctionLike/ExceptionHandlerTypehintRector/Fixture/fixture.php.inc (62%) rename packages/{Php => Php70}/tests/Rector/FunctionLike/ExceptionHandlerTypehintRector/Fixture/fixture_nullable.php.inc (63%) rename packages/{Php => Php70}/tests/Rector/If_/IfToSpaceshipRector/Fixture/complex.php.inc (84%) rename packages/{Php => Php70}/tests/Rector/If_/IfToSpaceshipRector/Fixture/fixture.php.inc (89%) rename packages/{Php => Php70}/tests/Rector/If_/IfToSpaceshipRector/Fixture/skip.php.inc (93%) rename packages/{Php => Php70}/tests/Rector/If_/IfToSpaceshipRector/IfToSpaceshipRectorTest.php (92%) rename packages/{Php => Php70}/tests/Rector/List_/EmptyListRector/EmptyListRectorTest.php (91%) rename packages/{Php => Php70}/tests/Rector/List_/EmptyListRector/Fixture/fixture.php.inc (70%) rename packages/{Php => Php70}/tests/Rector/List_/ListSplitStringRector/Fixture/fixture.php.inc (64%) rename packages/{Php => Php70}/tests/Rector/List_/ListSplitStringRector/ListSplitStringRectorTest.php (90%) rename packages/{Php => Php70}/tests/Rector/List_/ListSwapArrayOrderRector/Fixture/fixture.php.inc (61%) rename packages/{Php => Php70}/tests/Rector/List_/ListSwapArrayOrderRector/Fixture/skip.php.inc (68%) rename packages/{Php => Php70}/tests/Rector/List_/ListSwapArrayOrderRector/Fixture/skip_empty.php.inc (59%) rename packages/{Php => Php70}/tests/Rector/List_/ListSwapArrayOrderRector/ListSwapArrayOrderRectorTest.php (91%) rename packages/{Php => Php70}/tests/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector/Fixture/another_call.php.inc (73%) rename packages/{Php => Php70}/tests/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector/Fixture/fixture.php.inc (63%) rename packages/{Php => Php70}/tests/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector/ThisCallOnStaticMethodToStaticCallRectorTest.php (89%) rename packages/{Php => Php70}/tests/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector/Fixture/add_static_to_method.php.inc (83%) rename packages/{Php => Php70}/tests/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector/Fixture/fixture.php.inc (63%) rename packages/{Php => Php70}/tests/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector/Fixture/keep.php.inc (82%) rename packages/{Php => Php70}/tests/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector/Fixture/keep_annotated.php.inc (65%) rename packages/{Php => Php70}/tests/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector/Fixture/keep_parent_static.php.inc (69%) rename packages/{Php => Php70}/tests/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector/Fixture/with_constructor.php.inc (78%) rename packages/{Php => Php70}/tests/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector/Fixture/with_only_static_methods.php.inc (52%) rename packages/{Php => Php70}/tests/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector/Source/WithOnlyStaticMethods.php (70%) rename packages/{Php => Php70}/tests/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector/StaticCallOnNonStaticToInstanceCallRectorTest.php (92%) rename packages/{Php => Php70}/tests/Rector/Switch_/ReduceMultipleDefaultSwitchRector/Fixture/fixture.php.inc (84%) rename packages/{Php => Php70}/tests/Rector/Switch_/ReduceMultipleDefaultSwitchRector/Fixture/hidden_in_middle.php.inc (85%) rename packages/{Php => Php70}/tests/Rector/Switch_/ReduceMultipleDefaultSwitchRector/ReduceMultipleDefaultSwitchRectorTest.php (90%) rename packages/{Php => Php70}/tests/Rector/Ternary/TernaryToNullCoalescingRector/Fixture/fixture.php.inc (79%) rename packages/{Php => Php70}/tests/Rector/Ternary/TernaryToNullCoalescingRector/Fixture/fixture2.php.inc (67%) rename packages/{Php => Php70}/tests/Rector/Ternary/TernaryToNullCoalescingRector/Fixture/fixture3.php.inc (57%) rename packages/{Php => Php70}/tests/Rector/Ternary/TernaryToNullCoalescingRector/Fixture/fixture4.php.inc (89%) rename packages/{Php => Php70}/tests/Rector/Ternary/TernaryToNullCoalescingRector/TernaryToNullCoalescingRectorTest.php (93%) rename packages/{Php => Php70}/tests/Rector/Ternary/TernaryToSpaceshipRector/Fixture/fixture.php.inc (60%) rename packages/{Php => Php70}/tests/Rector/Ternary/TernaryToSpaceshipRector/TernaryToSpaceshipRectorTest.php (90%) rename packages/{Php => Php71}/tests/Rector/Assign/AssignArrayToStringRector/AssignArrayToStringRectorTest.php (93%) rename packages/{Php => Php71}/tests/Rector/Assign/AssignArrayToStringRector/Fixture/fixture.php.inc (76%) rename packages/{Php => Php71}/tests/Rector/Assign/AssignArrayToStringRector/Fixture/fixture2.php.inc (75%) rename packages/{Php => Php71}/tests/Rector/Assign/AssignArrayToStringRector/Fixture/fixture3.php.inc (73%) rename packages/{Php => Php71}/tests/Rector/Assign/AssignArrayToStringRector/Fixture/fixture4.php.inc (81%) rename packages/{Php => Php71}/tests/Rector/Assign/AssignArrayToStringRector/Fixture/fixture5.php.inc (70%) rename packages/{Php => Php71}/tests/Rector/Assign/AssignArrayToStringRector/Fixture/fixture6.php.inc (68%) rename packages/{Php => Php71}/tests/Rector/Assign/AssignArrayToStringRector/Fixture/fixture7.php.inc (67%) rename packages/{Php => Php71}/tests/Rector/Assign/AssignArrayToStringRector/Fixture/fixture8.php.inc (74%) create mode 100644 packages/Php71/tests/Rector/Assign/AssignArrayToStringRector/Fixture/skip.php.inc rename packages/{Php => Php71}/tests/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector/BinaryOpBetweenNumberAndStringRectorTest.php (89%) rename packages/{Php => Php71}/tests/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector/Fixture/fixture.php.inc (73%) rename packages/{Php => Php71}/tests/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector/Fixture/ignore_concatenation_dot.php.inc (70%) rename packages/{Php => Php71}/tests/Rector/BinaryOp/IsIterableRector/Fixture/fixture.php.inc (77%) rename packages/{Php => Php71}/tests/Rector/BinaryOp/IsIterableRector/Fixture/polyfill_function.php.inc (78%) rename packages/{Php => Php71}/tests/Rector/BinaryOp/IsIterableRector/IsIterableRectorTest.php (90%) rename packages/{Php => Php71}/tests/Rector/BinaryOp/IsIterableRector/PolyfillRectorTest.php (92%) rename packages/{Php => Php71}/tests/Rector/ClassConst/PublicConstantVisibilityRector/Fixture/SomeClass.php.inc (61%) rename packages/{Php => Php71}/tests/Rector/ClassConst/PublicConstantVisibilityRector/PublicConstantVisibilityRectorTest.php (89%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/CountOnNullRectorTest.php (95%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/CountOnNullRectorWithPHP73Test.php (91%) create mode 100644 packages/Php71/tests/Rector/FuncCall/CountOnNullRector/Fixture/array_countable_class.php.inc rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/Fixture/countable_annotated_params.php.inc (81%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/Fixture/double_same_variable.php.inc (83%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/Fixture/external_property.php.inc (66%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/Fixture/false_true_class.php.inc (80%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/Fixture/is_countable.php.inc (65%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/Fixture/local_property.php.inc (86%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/Fixture/nullable_array.php.inc (66%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/Fixture/on_null.php.inc (80%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/Fixture/preg_match_array.php.inc (84%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/Fixture/property_with_doc.php.inc (73%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/Fixture/skip_array_merge.php.inc (85%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/Fixture/skip_countable_local_property.php.inc (67%) rename packages/{Php => Php71}/tests/Rector/FuncCall/CountOnNullRector/Source/CountableClass.php (68%) create mode 100644 packages/Php71/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/better_func_get_all.php.inc create mode 100644 packages/Php71/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/external_scope.php.inc rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/fixture.php.inc (73%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/func_get_all.php.inc (76%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/function_with_one_required_and_one_optional_parameter.php.inc (76%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/methods.php.inc (85%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/remove_another_class_method_call_extra_argument.php.inc (78%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/skip_call_user_func_array.php.inc (78%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/skip_commented_param_func_get_args.php.inc (52%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/skip_invoke.php.inc (77%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/static_call_parent.php.inc (57%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/static_calls.php.inc (73%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/RemoveExtraParametersRectorTest.php (95%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Source/ChildOrmion.php (77%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Source/Db.php (54%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Source/MagicEventDispatcher.php (83%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Source/MethodWithFuncGetArgs.php (78%) rename packages/{Php => Php71}/tests/Rector/FuncCall/RemoveExtraParametersRector/Source/Ormion.php (55%) rename packages/{Php => Php71}/tests/Rector/TryCatch/MultiExceptionCatchRector/Fixture/fixture.php.inc (87%) rename packages/{Php => Php71}/tests/Rector/TryCatch/MultiExceptionCatchRector/MultiExceptionCatchRectorTest.php (89%) rename packages/{Php => Php72}/tests/Rector/ConstFetch/BarewordStringRector/BarewordStringRectorTest.php (90%) rename packages/{Php => Php72}/tests/Rector/ConstFetch/BarewordStringRector/Fixture/define.php.inc (54%) rename packages/{Php => Php72}/tests/Rector/ConstFetch/BarewordStringRector/Fixture/fixture.php.inc (66%) rename packages/{Php => Php72}/tests/Rector/Each/EachRectorTest.php (96%) rename packages/{Php => Php72}/tests/Rector/Each/Fixture/fixture.php.inc (84%) rename packages/{Php => Php72}/tests/Rector/Each/Fixture/fixture2.php.inc (77%) rename packages/{Php => Php72}/tests/Rector/Each/Fixture/fixture3.php.inc (82%) rename packages/{Php => Php72}/tests/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector/CreateFunctionToAnonymousFunctionRectorTest.php (92%) rename packages/{Php => Php72}/tests/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector/Fixture/concat.php.inc (76%) rename packages/{Php => Php72}/tests/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector/Fixture/drupal.php.inc (78%) rename packages/{Php => Php72}/tests/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector/Fixture/fixture.php.inc (89%) rename packages/{Php => Php72}/tests/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector/Fixture/php_net.php.inc (92%) rename packages/{Php => Php72}/tests/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector/Fixture/reference.php.inc (67%) rename packages/{Php => Php72}/tests/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector/Fixture/stackoverflow.php.inc (84%) rename packages/{Php => Php72}/tests/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector/Fixture/wordpress.php.inc (84%) rename packages/{Php => Php72}/tests/Rector/FuncCall/GetClassOnNullRector/Fixture/fixture.php.inc (84%) rename packages/{Php => Php72}/tests/Rector/FuncCall/GetClassOnNullRector/Fixture/tricky_cases.php.inc (87%) rename packages/{Php => Php72}/tests/Rector/FuncCall/GetClassOnNullRector/GetClassOnNullRectorTest.php (91%) rename packages/{Php => Php72}/tests/Rector/FuncCall/IsObjectOnIncompleteClassRector/Fixture/fixture.php.inc (81%) rename packages/{Php => Php72}/tests/Rector/FuncCall/IsObjectOnIncompleteClassRector/IsObjectOnIncompleteClassRectorTest.php (89%) rename packages/{Php => Php72}/tests/Rector/FuncCall/ParseStrWithResultArgumentRector/Fixture/fixture.php.inc (65%) rename packages/{Php => Php72}/tests/Rector/FuncCall/ParseStrWithResultArgumentRector/Fixture/skip_already_set.php.inc (58%) rename packages/{Php => Php72}/tests/Rector/FuncCall/ParseStrWithResultArgumentRector/ParseStrWithResultArgumentRectorTest.php (90%) rename packages/{Php => Php72}/tests/Rector/FuncCall/StringifyDefineRector/Fixture/fixture.php.inc (67%) rename packages/{Php => Php72}/tests/Rector/FuncCall/StringifyDefineRector/StringifyDefineRectorTest.php (90%) rename packages/{Php => Php72}/tests/Rector/FuncCall/StringsAssertNakedRector/Fixture/fixture.php.inc (77%) rename packages/{Php => Php72}/tests/Rector/FuncCall/StringsAssertNakedRector/StringsAssertNakedRectorTest.php (89%) rename packages/{Php => Php72}/tests/Rector/Unset_/UnsetCastRector/Fixture/fixture.php.inc (54%) rename packages/{Php => Php72}/tests/Rector/Unset_/UnsetCastRector/UnsetCastRectorTest.php (91%) rename packages/{Php => Php73}/tests/Rector/BinaryOp/IsCountableRector/Fixture/fixture71.php.inc (55%) rename packages/{Php => Php73}/tests/Rector/BinaryOp/IsCountableRector/Fixture/fixture73.php.inc (52%) rename packages/{Php => Php73}/tests/Rector/BinaryOp/IsCountableRector/Fixture/polyfill_function.php.inc (78%) rename packages/{Php => Php73}/tests/Rector/BinaryOp/IsCountableRector/IsCountableRectorTest.php (91%) rename packages/{Php => Php73}/tests/Rector/BinaryOp/IsCountableRector/PolyfillRectorTest.php (95%) rename packages/{Php => Php73}/tests/Rector/ConstFetch/SensitiveConstantNameRector/Fixture/fixture.php.inc (62%) rename packages/{Php => Php73}/tests/Rector/ConstFetch/SensitiveConstantNameRector/SensitiveConstantNameRectorTest.php (89%) rename packages/{Php => Php73}/tests/Rector/FuncCall/ArrayKeyFirstLastRector/ArrayKeyFirstLastRectorTest.php (91%) rename packages/{Php => Php73}/tests/Rector/FuncCall/ArrayKeyFirstLastRector/Fixture/array_key_first.php.inc (67%) rename packages/{Php => Php73}/tests/Rector/FuncCall/ArrayKeyFirstLastRector/Fixture/array_key_last.php.inc (77%) rename packages/{Php => Php73}/tests/Rector/FuncCall/ArrayKeyFirstLastRector/Fixture/both.php.inc (74%) rename packages/{Php => Php73}/tests/Rector/FuncCall/JsonThrowOnErrorRector/Fixture/fixture.php.inc (74%) rename packages/{Php => Php73}/tests/Rector/FuncCall/JsonThrowOnErrorRector/JsonThrowOnErrorRectorTest.php (90%) rename packages/{Php => Php73}/tests/Rector/FuncCall/RegexDashEscapeRector/Fixture/const.php.inc (78%) rename packages/{Php => Php73}/tests/Rector/FuncCall/RegexDashEscapeRector/Fixture/external_const.php.inc (78%) rename packages/{Php => Php73}/tests/Rector/FuncCall/RegexDashEscapeRector/Fixture/fixture.php.inc (79%) rename packages/{Php => Php73}/tests/Rector/FuncCall/RegexDashEscapeRector/Fixture/method_call.php.inc (81%) rename packages/{Php => Php73}/tests/Rector/FuncCall/RegexDashEscapeRector/Fixture/multiple_variables.php.inc (84%) rename packages/{Php => Php73}/tests/Rector/FuncCall/RegexDashEscapeRector/Fixture/variable.php.inc (76%) rename packages/{Php => Php73}/tests/Rector/FuncCall/RegexDashEscapeRector/RegexDashEscapeRectorTest.php (93%) rename packages/{Php => Php73}/tests/Rector/FuncCall/RemoveMissingCompactVariableRector/Fixture/empty_compact.php.inc (54%) rename packages/{Php => Php73}/tests/Rector/FuncCall/RemoveMissingCompactVariableRector/Fixture/fixture.php.inc (59%) rename packages/{Php => Php73}/tests/Rector/FuncCall/RemoveMissingCompactVariableRector/Fixture/skip_maybe_defined.inc (70%) rename packages/{Php => Php73}/tests/Rector/FuncCall/RemoveMissingCompactVariableRector/RemoveMissingCompactVariableRectorTest.php (90%) rename packages/{Php => Php73}/tests/Rector/FuncCall/SensitiveDefineRector/Fixture/fixture.php.inc (51%) rename packages/{Php => Php73}/tests/Rector/FuncCall/SensitiveDefineRector/SensitiveDefineRectorTest.php (90%) rename packages/{Php => Php73}/tests/Rector/FuncCall/StringifyStrNeedlesRector/Fixture/fixture.php.inc (75%) rename packages/{Php => Php73}/tests/Rector/FuncCall/StringifyStrNeedlesRector/Fixture/skip_twice.php.inc (65%) rename packages/{Php => Php73}/tests/Rector/FuncCall/StringifyStrNeedlesRector/Fixture/trait.php.inc (71%) rename packages/{Php => Php73}/tests/Rector/FuncCall/StringifyStrNeedlesRector/StringifyStrNeedlesRectorTest.php (91%) rename packages/{Php => Php73}/tests/Rector/String_/SensitiveHereNowDocRector/Fixture/fixture.php.inc (71%) rename packages/{Php => Php73}/tests/Rector/String_/SensitiveHereNowDocRector/SensitiveHereNowDocRectorTest.php (89%) rename packages/{Php => Php74}/tests/Rector/Assign/NullCoalescingOperatorRector/Fixture/fixture.php.inc (59%) rename packages/{Php => Php74}/tests/Rector/Assign/NullCoalescingOperatorRector/NullCoalescingOperatorRectorTest.php (89%) rename packages/{Php => Php74}/tests/Rector/Closure/ClosureToArrowFunctionRector/ClosureToArrowFunctionRectorTest.php (91%) rename packages/{Php => Php74}/tests/Rector/Closure/ClosureToArrowFunctionRector/Fixture/fixture.php.inc (68%) rename packages/{Php => Php74}/tests/Rector/Closure/ClosureToArrowFunctionRector/Fixture/referenced_but_not_used.php.inc (63%) rename packages/{Php => Php74}/tests/Rector/Closure/ClosureToArrowFunctionRector/Fixture/skip_no_return.php.inc (77%) rename packages/{Php => Php74}/tests/Rector/Closure/ClosureToArrowFunctionRector/Fixture/skip_referenced_value.php.inc (65%) rename packages/{Php => Php74}/tests/Rector/Double/RealToFloatTypeCastRector/Fixture/fixture.php.inc (67%) rename packages/{Php => Php74}/tests/Rector/Double/RealToFloatTypeCastRector/RealToFloatTypeCastRectorTest.php (90%) rename packages/{Php => Php74}/tests/Rector/FuncCall/ArrayKeyExistsOnPropertyRector/ArrayKeyExistsOnPropertyRectorTest.php (89%) rename packages/{Php => Php74}/tests/Rector/FuncCall/ArrayKeyExistsOnPropertyRector/Fixture/fixture.php.inc (59%) rename packages/{Php => Php74}/tests/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector/ArraySpreadInsteadOfArrayMergeRectorTest.php (91%) rename packages/{Php => Php74}/tests/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector/Fixture/fixture.php.inc (77%) rename packages/{Php => Php74}/tests/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector/Fixture/integer_keys.php.inc (66%) rename packages/{Php => Php74}/tests/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector/Fixture/iterator_to_array.php.inc (57%) rename packages/{Php => Php74}/tests/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector/Fixture/skip_simple_array_merge.php.inc (60%) rename packages/{Php => Php74}/tests/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector/Fixture/skip_string_keys.php.inc (78%) rename packages/{Php => Php74}/tests/Rector/FuncCall/FilterVarToAddSlashesRector/FilterVarToAddSlashesRectorTest.php (89%) create mode 100644 packages/Php74/tests/Rector/FuncCall/FilterVarToAddSlashesRector/Fixture/fixture.php.inc rename packages/{Php => Php74}/tests/Rector/FuncCall/GetCalledClassToStaticClassRector/Fixture/fixture.php.inc (56%) rename packages/{Php => Php74}/tests/Rector/FuncCall/GetCalledClassToStaticClassRector/GetCalledClassToStaticClassRectorTest.php (89%) rename packages/{Php => Php74}/tests/Rector/FuncCall/MbStrrposEncodingArgumentPositionRector/Fixture/fixture.php.inc (60%) rename packages/{Php => Php74}/tests/Rector/FuncCall/MbStrrposEncodingArgumentPositionRector/MbStrrposEncodingArgumentPositionRectorTest.php (88%) rename packages/{Php => Php74}/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/AddLiteralSeparatorToNumberRectorTest.php (91%) rename packages/{Php => Php74}/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/Fixture/fixture.php.inc (59%) rename packages/{Php => Php74}/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/Fixture/skip_hexadecimal.php.inc (56%) rename packages/{Php => Php74}/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/Fixture/skip_non_dec_simple_float_numbers.php.inc (69%) rename packages/{Php => Php74}/tests/Rector/MagicConstClass/ClassConstantToSelfClassRector/ClassConstantToSelfClassRectorTest.php (88%) rename packages/{Php => Php74}/tests/Rector/MagicConstClass/ClassConstantToSelfClassRector/Fixture/fixture.php.inc (54%) rename packages/{Php => Php74}/tests/Rector/Property/TypedPropertyRector/Fixture/bool_property.php.inc (63%) create mode 100644 packages/Php74/tests/Rector/Property/TypedPropertyRector/Fixture/class_property.php.inc rename packages/{Php => Php74}/tests/Rector/Property/TypedPropertyRector/Fixture/default_values.php.inc (91%) rename packages/{Php => Php74}/tests/Rector/Property/TypedPropertyRector/Fixture/default_values_for_nullable_iterables.php.inc (79%) rename packages/{Php => Php74}/tests/Rector/Property/TypedPropertyRector/Fixture/match_types.php.inc (87%) rename packages/{Php => Php74}/tests/Rector/Property/TypedPropertyRector/Fixture/match_types_parent.php.inc (67%) create mode 100644 packages/Php74/tests/Rector/Property/TypedPropertyRector/Fixture/nullable_property.php.inc rename packages/{Php => Php74}/tests/Rector/Property/TypedPropertyRector/Fixture/property.php.inc (80%) rename packages/{Php => Php74}/tests/Rector/Property/TypedPropertyRector/Fixture/skip_invalid_property.php.inc (59%) rename packages/{Php => Php74}/tests/Rector/Property/TypedPropertyRector/Fixture/static_analysis_based.php.inc (68%) create mode 100644 packages/Php74/tests/Rector/Property/TypedPropertyRector/Fixture/static_property.php.inc rename packages/{Php => Php74}/tests/Rector/Property/TypedPropertyRector/TypedPropertyRectorTest.php (95%) rename packages/{Php => Php74}/tests/Rector/StaticCall/ExportToReflectionFunctionRector/ExportToReflectionFunctionRectorTest.php (89%) rename packages/{Php => Php74}/tests/Rector/StaticCall/ExportToReflectionFunctionRector/Fixture/fixture.php.inc (71%) rename packages/{Php => TypeDeclaration}/tests/Rector/Property/CompleteVarDocTypePropertyRector/CompleteVarDocTypePropertyRectorTest.php (92%) rename packages/{Php => TypeDeclaration}/tests/Rector/Property/CompleteVarDocTypePropertyRector/Fixture/assign_conflict.php.inc (67%) rename packages/{Php => TypeDeclaration}/tests/Rector/Property/CompleteVarDocTypePropertyRector/Fixture/callable_type.php.inc (84%) rename packages/{Php => TypeDeclaration}/tests/Rector/Property/CompleteVarDocTypePropertyRector/Fixture/default_value.php.inc (74%) rename packages/{Php => TypeDeclaration}/tests/Rector/Property/CompleteVarDocTypePropertyRector/Fixture/property_assign.php.inc (70%) rename packages/{Php => TypeDeclaration}/tests/Rector/Property/CompleteVarDocTypePropertyRector/Fixture/symfony_console_command.php.inc (99%) rename packages/{Php => TypeDeclaration}/tests/Rector/Property/CompleteVarDocTypePropertyRector/Fixture/typed_array.php.inc (68%) rename packages/{Php => TypeDeclaration}/tests/Rector/Property/CompleteVarDocTypePropertyRector/Fixture/typed_array_nested.php.inc (72%) rename packages/{Php => TypeDeclaration}/tests/Rector/Property/CompleteVarDocTypePropertyRector/Source/EventDispatcher.php (100%) create mode 100644 packages/TypeDeclaration/tests/Rector/Property/TypedPropertyRector/Source/AnotherClass.php create mode 100644 renames-rector.yaml diff --git a/composer.json b/composer.json index 98661d695576..03f157ce1346 100644 --- a/composer.json +++ b/composer.json @@ -129,7 +129,15 @@ "Rector\\PSR4\\Tests\\": "packages/PSR4/tests", "Rector\\PhpSpecToPHPUnit\\Tests\\": "packages/PhpSpecToPHPUnit/tests", "Rector\\Php\\Tests\\": "packages/Php/tests", + "Rector\\Php52\\Tests\\": "packages/Php52/tests", + "Rector\\Php53\\Tests\\": "packages/Php53/tests", + "Rector\\Php54\\Tests\\": "packages/Php54/tests", + "Rector\\Php55\\Tests\\": "packages/Php55/tests", + "Rector\\Php56\\Tests\\": "packages/Php56/tests", "Rector\\Php70\\Tests\\": "packages/Php70/tests", + "Rector\\Php71\\Tests\\": "packages/Php71/tests", + "Rector\\Php72\\Tests\\": "packages/Php72/tests", + "Rector\\Php73\\Tests\\": "packages/Php73/tests", "Rector\\Php74\\Tests\\": "packages/Php74/tests", "Rector\\RemovingStatic\\Tests\\": "packages/RemovingStatic/tests", "Rector\\Restoration\\Tests\\": "packages/Restoration/tests", @@ -160,7 +168,7 @@ ], "files": [ "packages/DeadCode/tests/Rector/MethodCall/RemoveDefaultArgumentValueRector/Source/UserDefined.php", - "packages/Php/tests/Rector/Property/CompleteVarDocTypePropertyRector/Source/EventDispatcher.php", + "packages/TypeDeclaration/tests/Rector/Property/CompleteVarDocTypePropertyRector/Source/EventDispatcher.php", "tests/Rector/Namespace_/PseudoNamespaceToNamespaceRector/Source/ChangeMeAnotherNamespace.php", "packages/TypeDeclaration/tests/Rector/FunctionLike/ReturnTypeDeclarationRector/Source/MyBar.php", "tests/Rector/Class_/RenameClassRector/Source/Twig_Extension_Sandbox.php", diff --git a/config/set/celebrity/celebrity.yaml b/config/set/celebrity/celebrity.yaml index b0a1c8b6b172..f75ac49fcdaa 100644 --- a/config/set/celebrity/celebrity.yaml +++ b/config/set/celebrity/celebrity.yaml @@ -10,7 +10,8 @@ services: Rector\Celebrity\Rector\FuncCall\SetTypeToCastRector: ~ # class { var $value; } → class { public $value; } - Rector\Php\Rector\Property\VarToPublicPropertyRector: ~ + Rector\Php52\Rector\Property\VarToPublicPropertyRector: ~pu + # false or true → false || true # false and true → false && true diff --git a/config/set/code-quality/code-quality.yaml b/config/set/code-quality/code-quality.yaml index b72714aad6d9..7646201a2bda 100644 --- a/config/set/code-quality/code-quality.yaml +++ b/config/set/code-quality/code-quality.yaml @@ -15,7 +15,7 @@ services: Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector: ~ Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector: ~ - Rector\Php\Rector\FuncCall\RemoveExtraParametersRector: ~ + Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector: ~ Rector\CodeQuality\Rector\BinaryOp\SimplifyDeMorganBinaryRector: ~ Rector\CodeQuality\Rector\Ternary\SimplifyTautologyTernaryRector: ~ Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToArrayFilterRector: ~ diff --git a/config/set/coding-style/coding-style.yaml b/config/set/coding-style/coding-style.yaml index 0c719bdc1bd1..8ebd7b65162a 100644 --- a/config/set/coding-style/coding-style.yaml +++ b/config/set/coding-style/coding-style.yaml @@ -15,7 +15,7 @@ services: Rector\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector: ~ # 'ClassName' → ClassName::class - Rector\Php\Rector\String_\StringClassNameToClassConstantRector: ~ + Rector\Php55\Rector\String_\StringClassNameToClassConstantRector: ~ Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector: ~ Rector\CodingStyle\Rector\Include_\FollowRequireByDirRector: ~ Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector: ~ diff --git a/packages/Php/tests/Rector/Assign/AssignArrayToStringRector/Fixture/skip.php.inc b/packages/Php/tests/Rector/Assign/AssignArrayToStringRector/Fixture/skip.php.inc deleted file mode 100644 index e98b59864c62..000000000000 --- a/packages/Php/tests/Rector/Assign/AssignArrayToStringRector/Fixture/skip.php.inc +++ /dev/null @@ -1,6 +0,0 @@ - ------ - diff --git a/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/better_func_get_all.php.inc b/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/better_func_get_all.php.inc deleted file mode 100644 index 0d58e7d97d09..000000000000 --- a/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/better_func_get_all.php.inc +++ /dev/null @@ -1,31 +0,0 @@ - ------ - diff --git a/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/external_scope.php.inc b/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/external_scope.php.inc deleted file mode 100644 index b03c0c6d146f..000000000000 --- a/packages/Php/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/external_scope.php.inc +++ /dev/null @@ -1,10 +0,0 @@ - ------ - diff --git a/packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/class_property.php.inc b/packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/class_property.php.inc deleted file mode 100644 index 34d469acd983..000000000000 --- a/packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/class_property.php.inc +++ /dev/null @@ -1,31 +0,0 @@ - ------ - diff --git a/packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/nullable_property.php.inc b/packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/nullable_property.php.inc deleted file mode 100644 index 0475d5197a04..000000000000 --- a/packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/nullable_property.php.inc +++ /dev/null @@ -1,41 +0,0 @@ - ------ - diff --git a/packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/static_property.php.inc b/packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/static_property.php.inc deleted file mode 100644 index 058dd4b2feea..000000000000 --- a/packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/static_property.php.inc +++ /dev/null @@ -1,31 +0,0 @@ - ------ - diff --git a/packages/Php/tests/Rector/Property/TypedPropertyRector/Source/AnotherClass.php b/packages/Php/tests/Rector/Property/TypedPropertyRector/Source/AnotherClass.php deleted file mode 100644 index 8b21772bbe39..000000000000 --- a/packages/Php/tests/Rector/Property/TypedPropertyRector/Source/AnotherClass.php +++ /dev/null @@ -1,8 +0,0 @@ - ------ - diff --git a/packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/pre_slash.php.inc b/packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/pre_slash.php.inc deleted file mode 100644 index 288007794e3f..000000000000 --- a/packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/pre_slash.php.inc +++ /dev/null @@ -1,27 +0,0 @@ - ------ - diff --git a/packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_sensitive.php.inc b/packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_sensitive.php.inc deleted file mode 100644 index c614765ae38b..000000000000 --- a/packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_sensitive.php.inc +++ /dev/null @@ -1,27 +0,0 @@ - 'Exception']; - } -} - -?> ------ - \Exception::class]; - } -} - -?> diff --git a/packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_slashes.php.inc b/packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_slashes.php.inc deleted file mode 100644 index a87dcdd57dfa..000000000000 --- a/packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_slashes.php.inc +++ /dev/null @@ -1,13 +0,0 @@ - +----- + diff --git a/packages/Php/tests/Rector/FuncCall/RemoveReferenceFromCallRector/RemoveReferenceFromCallRectorTest.php b/packages/Php54/tests/Rector/FuncCall/RemoveReferenceFromCallRector/RemoveReferenceFromCallRectorTest.php similarity index 89% rename from packages/Php/tests/Rector/FuncCall/RemoveReferenceFromCallRector/RemoveReferenceFromCallRectorTest.php rename to packages/Php54/tests/Rector/FuncCall/RemoveReferenceFromCallRector/RemoveReferenceFromCallRectorTest.php index 01fa0cae0daa..ab48a152aa8c 100644 --- a/packages/Php/tests/Rector/FuncCall/RemoveReferenceFromCallRector/RemoveReferenceFromCallRectorTest.php +++ b/packages/Php54/tests/Rector/FuncCall/RemoveReferenceFromCallRector/RemoveReferenceFromCallRectorTest.php @@ -1,6 +1,6 @@ +----- + diff --git a/packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_error.php.inc b/packages/Php55/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_error.php.inc similarity index 56% rename from packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_error.php.inc rename to packages/Php55/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_error.php.inc index 39ce1d9e7e5f..b696be0850f2 100644 --- a/packages/Php/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_error.php.inc +++ b/packages/Php55/tests/Rector/String_/StringClassNameToClassConstantRector/Fixture/skip_error.php.inc @@ -1,6 +1,6 @@ 'Exception']; + } +} + +?> +----- + \Exception::class]; + } +} + +?> diff --git a/packages/Php55/tests/Rector/String_/StringClassNameToClassConstantRector/Source/AnotherClass.php b/packages/Php55/tests/Rector/String_/StringClassNameToClassConstantRector/Source/AnotherClass.php new file mode 100644 index 000000000000..8d835f4145c8 --- /dev/null +++ b/packages/Php55/tests/Rector/String_/StringClassNameToClassConstantRector/Source/AnotherClass.php @@ -0,0 +1,8 @@ + $b) ? 1 : 0); @@ -12,7 +12,7 @@ function order_func($a, $b) { ----- $b; diff --git a/packages/Php/tests/Rector/Ternary/TernaryToSpaceshipRector/TernaryToSpaceshipRectorTest.php b/packages/Php70/tests/Rector/Ternary/TernaryToSpaceshipRector/TernaryToSpaceshipRectorTest.php similarity index 90% rename from packages/Php/tests/Rector/Ternary/TernaryToSpaceshipRector/TernaryToSpaceshipRectorTest.php rename to packages/Php70/tests/Rector/Ternary/TernaryToSpaceshipRector/TernaryToSpaceshipRectorTest.php index c4fb3baf20b3..cfac2b5a87cd 100644 --- a/packages/Php/tests/Rector/Ternary/TernaryToSpaceshipRector/TernaryToSpaceshipRectorTest.php +++ b/packages/Php70/tests/Rector/Ternary/TernaryToSpaceshipRector/TernaryToSpaceshipRectorTest.php @@ -1,6 +1,6 @@ +----- + diff --git a/packages/Php71/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/external_scope.php.inc b/packages/Php71/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/external_scope.php.inc new file mode 100644 index 000000000000..cd372d5757d8 --- /dev/null +++ b/packages/Php71/tests/Rector/FuncCall/RemoveExtraParametersRector/Fixture/external_scope.php.inc @@ -0,0 +1,10 @@ + +----- + diff --git a/packages/Php/tests/Rector/FuncCall/GetCalledClassToStaticClassRector/Fixture/fixture.php.inc b/packages/Php74/tests/Rector/FuncCall/GetCalledClassToStaticClassRector/Fixture/fixture.php.inc similarity index 56% rename from packages/Php/tests/Rector/FuncCall/GetCalledClassToStaticClassRector/Fixture/fixture.php.inc rename to packages/Php74/tests/Rector/FuncCall/GetCalledClassToStaticClassRector/Fixture/fixture.php.inc index c4a658a2274c..48be34a6276f 100644 --- a/packages/Php/tests/Rector/FuncCall/GetCalledClassToStaticClassRector/Fixture/fixture.php.inc +++ b/packages/Php74/tests/Rector/FuncCall/GetCalledClassToStaticClassRector/Fixture/fixture.php.inc @@ -1,6 +1,6 @@ +----- + diff --git a/packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/default_values.php.inc b/packages/Php74/tests/Rector/Property/TypedPropertyRector/Fixture/default_values.php.inc similarity index 91% rename from packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/default_values.php.inc rename to packages/Php74/tests/Rector/Property/TypedPropertyRector/Fixture/default_values.php.inc index 4c507dd61404..c619b20460cb 100644 --- a/packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/default_values.php.inc +++ b/packages/Php74/tests/Rector/Property/TypedPropertyRector/Fixture/default_values.php.inc @@ -1,6 +1,6 @@ +----- + diff --git a/packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/property.php.inc b/packages/Php74/tests/Rector/Property/TypedPropertyRector/Fixture/property.php.inc similarity index 80% rename from packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/property.php.inc rename to packages/Php74/tests/Rector/Property/TypedPropertyRector/Fixture/property.php.inc index a34fc837b296..62086b44a835 100644 --- a/packages/Php/tests/Rector/Property/TypedPropertyRector/Fixture/property.php.inc +++ b/packages/Php74/tests/Rector/Property/TypedPropertyRector/Fixture/property.php.inc @@ -1,6 +1,6 @@ +----- + diff --git a/packages/Php/tests/Rector/Property/TypedPropertyRector/TypedPropertyRectorTest.php b/packages/Php74/tests/Rector/Property/TypedPropertyRector/TypedPropertyRectorTest.php similarity index 95% rename from packages/Php/tests/Rector/Property/TypedPropertyRector/TypedPropertyRectorTest.php rename to packages/Php74/tests/Rector/Property/TypedPropertyRector/TypedPropertyRectorTest.php index bfd01260f2d0..46989ea99205 100644 --- a/packages/Php/tests/Rector/Property/TypedPropertyRector/TypedPropertyRectorTest.php +++ b/packages/Php74/tests/Rector/Property/TypedPropertyRector/TypedPropertyRectorTest.php @@ -1,6 +1,6 @@