From 4b78aad94855c58144de4637784f8855926d0577 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 7 May 2023 20:26:15 +0100 Subject: [PATCH] [CodingStyle] Remove RemoveDoubleUnderscoreInMethodNameRector, as naming is not handled for breaking reasons --- config/set/coding-style.php | 2 - .../Fixture/class_method_declaration.php.inc | 21 ---- .../Fixture/methods_calling.php.inc | 61 ------------ .../Fixture/skip_native_php_methods.php.inc | 29 ------ ...ip_numeric_after_double_underscore.php.inc | 10 -- .../skip_only_double_underscore.php.inc | 10 -- ...DoubleUnderscoreInMethodNameRectorTest.php | 28 ------ .../config/configured_rule.php | 10 -- ...moveDoubleUnderscoreInMethodNameRector.php | 96 ------------------- 9 files changed, 267 deletions(-) delete mode 100644 rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/class_method_declaration.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/methods_calling.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/skip_native_php_methods.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/skip_numeric_after_double_underscore.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/skip_only_double_underscore.php.inc delete mode 100644 rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/RemoveDoubleUnderscoreInMethodNameRectorTest.php delete mode 100644 rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/config/configured_rule.php delete mode 100644 rules/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector.php diff --git a/config/set/coding-style.php b/config/set/coding-style.php index c8b4a63f1c1..b3c590c2574 100644 --- a/config/set/coding-style.php +++ b/config/set/coding-style.php @@ -12,7 +12,6 @@ use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector; use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector; use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector; -use Rector\CodingStyle\Rector\ClassMethod\RemoveDoubleUnderscoreInMethodNameRector; use Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector; use Rector\CodingStyle\Rector\Closure\StaticClosureRector; use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; @@ -48,7 +47,6 @@ $rectorConfig->rules([ SeparateMultiUseImportsRector::class, - RemoveDoubleUnderscoreInMethodNameRector::class, PostIncDecToPreIncDecRector::class, UnSpreadOperatorRector::class, NewlineAfterStatementRector::class, diff --git a/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/class_method_declaration.php.inc b/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/class_method_declaration.php.inc deleted file mode 100644 index 691cd2aa22f..00000000000 --- a/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/class_method_declaration.php.inc +++ /dev/null @@ -1,21 +0,0 @@ - ------ - diff --git a/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/methods_calling.php.inc b/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/methods_calling.php.inc deleted file mode 100644 index 87aa73000f9..00000000000 --- a/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/methods_calling.php.inc +++ /dev/null @@ -1,61 +0,0 @@ -__doSomething(); - - $myClass->__construct(); - $myClass->__destruct(); - $myClass->__call(); - $myClass->__callStatic(); - $myClass->__get(); - $myClass->__set(); - $myClass->__isset(); - $myClass->__unset(); - $myClass->__sleep(); - $myClass->__wakeup(); - $myClass->__serialize(); - $myClass->__unserialize(); - $myClass->__toString(); - $myClass->__invoke(); - $myClass->__set_state(); - $myClass->__debugInfo(); - } -} - -?> ------ -doSomething(); - - $myClass->__construct(); - $myClass->__destruct(); - $myClass->__call(); - $myClass->__callStatic(); - $myClass->__get(); - $myClass->__set(); - $myClass->__isset(); - $myClass->__unset(); - $myClass->__sleep(); - $myClass->__wakeup(); - $myClass->__serialize(); - $myClass->__unserialize(); - $myClass->__toString(); - $myClass->__invoke(); - $myClass->__set_state(); - $myClass->__debugInfo(); - } -} - -?> diff --git a/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/skip_native_php_methods.php.inc b/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/skip_native_php_methods.php.inc deleted file mode 100644 index 0d21f42f088..00000000000 --- a/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/skip_native_php_methods.php.inc +++ /dev/null @@ -1,29 +0,0 @@ - diff --git a/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/skip_only_double_underscore.php.inc b/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/skip_only_double_underscore.php.inc deleted file mode 100644 index 4ccf6184d38..00000000000 --- a/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/Fixture/skip_only_double_underscore.php.inc +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/RemoveDoubleUnderscoreInMethodNameRectorTest.php b/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/RemoveDoubleUnderscoreInMethodNameRectorTest.php deleted file mode 100644 index e2c5083e86b..00000000000 --- a/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/RemoveDoubleUnderscoreInMethodNameRectorTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/config/configured_rule.php b/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/config/configured_rule.php deleted file mode 100644 index bf382d9408b..00000000000 --- a/rules-tests/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector/config/configured_rule.php +++ /dev/null @@ -1,10 +0,0 @@ -rule(RemoveDoubleUnderscoreInMethodNameRector::class); -}; diff --git a/rules/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector.php b/rules/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector.php deleted file mode 100644 index 5f6d8043f88..00000000000 --- a/rules/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector.php +++ /dev/null @@ -1,96 +0,0 @@ -__getSurname(); - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -class SomeClass -{ - public function getName($anotherObject) - { - $anotherObject->getSurname(); - } -} -CODE_SAMPLE - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [ClassMethod::class, MethodCall::class, StaticCall::class]; - } - - /** - * @param ClassMethod|MethodCall|StaticCall $node - */ - public function refactor(Node $node): ?Node - { - $methodName = $this->getName($node->name); - if ($methodName === null) { - return null; - } - - if (in_array($methodName, ObjectMagicMethods::METHOD_NAMES, true)) { - return null; - } - - if (! StringUtils::isMatch($methodName, self::DOUBLE_UNDERSCORE_START_REGEX)) { - return null; - } - - $newName = Strings::substring($methodName, 2); - - if (is_numeric($newName[0])) { - return null; - } - - $node->name = new Identifier($newName); - - return $node; - } -}