diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md index f1c8acb72f6..17699230803 100644 --- a/docs/rector_rules_overview.md +++ b/docs/rector_rules_overview.md @@ -1,4 +1,4 @@ -# 374 Rules Overview +# 373 Rules Overview
@@ -56,7 +56,7 @@ - [Strict](#strict) (5) -- [Transform](#transform) (25) +- [Transform](#transform) (24) - [TypeDeclaration](#typedeclaration) (40) @@ -7679,42 +7679,6 @@ return static function (RectorConfig $rectorConfig): void {
-### UnsetAndIssetToMethodCallRector - -Turns defined `__isset`/`__unset` calls to specific method calls. - -:wrench: **configure it!** - -- class: [`Rector\Transform\Rector\Isset_\UnsetAndIssetToMethodCallRector`](../rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php) - -```php -ruleWithConfiguration(UnsetAndIssetToMethodCallRector::class, [ - new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService'), - ]); -}; -``` - -↓ - -```diff - $container = new SomeContainer; --isset($container["someKey"]); --unset($container["someKey"]); -+$container->hasService("someKey"); -+$container->removeService("someKey"); -``` - -
- ### WrapReturnRector Wrap return value of specific method diff --git a/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php b/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php deleted file mode 100644 index ffd2428f19d..00000000000 --- a/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php +++ /dev/null @@ -1,92 +0,0 @@ -hasService("someKey"); -$container->removeService("someKey"); -CODE_SAMPLE -, [new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService')])]); - } - /** - * @return array> - */ - public function getNodeTypes() : array - { - return [Isset_::class, Unset_::class]; - } - /** - * @param Isset_|Unset_ $node - */ - public function refactor(Node $node) : ?Node - { - foreach ($node->vars as $arrayDimFetch) { - if (!$arrayDimFetch instanceof ArrayDimFetch) { - continue; - } - foreach ($this->issetUnsetToMethodCalls as $issetUnsetToMethodCall) { - if (!$this->isObjectType($arrayDimFetch->var, $issetUnsetToMethodCall->getObjectType())) { - continue; - } - $newNode = $this->processArrayDimFetchNode($node, $arrayDimFetch, $issetUnsetToMethodCall); - if ($newNode instanceof Node) { - return $newNode; - } - } - } - return null; - } - /** - * @param mixed[] $configuration - */ - public function configure(array $configuration) : void - { - Assert::allIsAOf($configuration, UnsetAndIssetToMethodCall::class); - $this->issetUnsetToMethodCalls = $configuration; - } - private function processArrayDimFetchNode(Node $node, ArrayDimFetch $arrayDimFetch, UnsetAndIssetToMethodCall $unsetAndIssetToMethodCall) : ?Node - { - if ($node instanceof Isset_) { - if ($unsetAndIssetToMethodCall->getIssetMethodCall() === '') { - return null; - } - return $this->nodeFactory->createMethodCall($arrayDimFetch->var, $unsetAndIssetToMethodCall->getIssetMethodCall(), [$arrayDimFetch->dim]); - } - if ($node instanceof Unset_) { - if ($unsetAndIssetToMethodCall->getUnsedMethodCall() === '') { - return null; - } - return $this->nodeFactory->createMethodCall($arrayDimFetch->var, $unsetAndIssetToMethodCall->getUnsedMethodCall(), [$arrayDimFetch->dim]); - } - return null; - } -} diff --git a/rules/Transform/ValueObject/UnsetAndIssetToMethodCall.php b/rules/Transform/ValueObject/UnsetAndIssetToMethodCall.php deleted file mode 100644 index 6262b28bec7..00000000000 --- a/rules/Transform/ValueObject/UnsetAndIssetToMethodCall.php +++ /dev/null @@ -1,46 +0,0 @@ -type = $type; - $this->issetMethodCall = $issetMethodCall; - $this->unsedMethodCall = $unsedMethodCall; - RectorAssert::className($type); - RectorAssert::methodName($issetMethodCall); - RectorAssert::methodName($unsedMethodCall); - } - public function getObjectType() : ObjectType - { - return new ObjectType($this->type); - } - public function getIssetMethodCall() : string - { - return $this->issetMethodCall; - } - public function getUnsedMethodCall() : string - { - return $this->unsedMethodCall; - } -} diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index c1c263ce52d..5d27df9de6c 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = 'f2509fa341525d3939073c5b4513f47ab8362fda'; + public const PACKAGE_VERSION = '2c13033108f884fb007ccfa74d29e85cc726b985'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-06-08 22:19:05'; + public const RELEASE_DATE = '2023-06-08 22:29:53'; /** * @var int */ diff --git a/vendor/autoload.php b/vendor/autoload.php index c947b458663..d6556bd3ad0 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderIniteba99b089a008fa8685ebae07df294c6::getLoader(); +return ComposerAutoloaderInitabbd4d71331eac28853a6c6f03eeca65::getLoader(); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 70f937e7d38..3a8155bb88a 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -2738,7 +2738,6 @@ return array( 'Rector\\Transform\\Rector\\FuncCall\\FuncCallToMethodCallRector' => $baseDir . '/rules/Transform/Rector/FuncCall/FuncCallToMethodCallRector.php', 'Rector\\Transform\\Rector\\FuncCall\\FuncCallToNewRector' => $baseDir . '/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php', 'Rector\\Transform\\Rector\\FuncCall\\FuncCallToStaticCallRector' => $baseDir . '/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php', - 'Rector\\Transform\\Rector\\Isset_\\UnsetAndIssetToMethodCallRector' => $baseDir . '/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php', 'Rector\\Transform\\Rector\\MethodCall\\MethodCallToFuncCallRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToFuncCallRector.php', 'Rector\\Transform\\Rector\\MethodCall\\MethodCallToMethodCallRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToMethodCallRector.php', 'Rector\\Transform\\Rector\\MethodCall\\MethodCallToPropertyFetchRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php', @@ -2768,7 +2767,6 @@ return array( 'Rector\\Transform\\ValueObject\\StaticCallToMethodCall' => $baseDir . '/rules/Transform/ValueObject/StaticCallToMethodCall.php', 'Rector\\Transform\\ValueObject\\StaticCallToNew' => $baseDir . '/rules/Transform/ValueObject/StaticCallToNew.php', 'Rector\\Transform\\ValueObject\\StringToClassConstant' => $baseDir . '/rules/Transform/ValueObject/StringToClassConstant.php', - 'Rector\\Transform\\ValueObject\\UnsetAndIssetToMethodCall' => $baseDir . '/rules/Transform/ValueObject/UnsetAndIssetToMethodCall.php', 'Rector\\Transform\\ValueObject\\WrapReturn' => $baseDir . '/rules/Transform/ValueObject/WrapReturn.php', 'Rector\\TypeDeclaration\\AlreadyAssignDetector\\ConstructorAssignDetector' => $baseDir . '/rules/TypeDeclaration/AlreadyAssignDetector/ConstructorAssignDetector.php', 'Rector\\TypeDeclaration\\AlreadyAssignDetector\\NullTypeAssignDetector' => $baseDir . '/rules/TypeDeclaration/AlreadyAssignDetector/NullTypeAssignDetector.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index df790e596ec..dee00e9865a 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderIniteba99b089a008fa8685ebae07df294c6 +class ComposerAutoloaderInitabbd4d71331eac28853a6c6f03eeca65 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderIniteba99b089a008fa8685ebae07df294c6 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderIniteba99b089a008fa8685ebae07df294c6', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitabbd4d71331eac28853a6c6f03eeca65', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderIniteba99b089a008fa8685ebae07df294c6', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitabbd4d71331eac28853a6c6f03eeca65', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticIniteba99b089a008fa8685ebae07df294c6::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticIniteba99b089a008fa8685ebae07df294c6::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65::$files; $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 4a1dad0b45a..8793807c7a7 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticIniteba99b089a008fa8685ebae07df294c6 +class ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -2989,7 +2989,6 @@ class ComposerStaticIniteba99b089a008fa8685ebae07df294c6 'Rector\\Transform\\Rector\\FuncCall\\FuncCallToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/FuncCall/FuncCallToMethodCallRector.php', 'Rector\\Transform\\Rector\\FuncCall\\FuncCallToNewRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php', 'Rector\\Transform\\Rector\\FuncCall\\FuncCallToStaticCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php', - 'Rector\\Transform\\Rector\\Isset_\\UnsetAndIssetToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php', 'Rector\\Transform\\Rector\\MethodCall\\MethodCallToFuncCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToFuncCallRector.php', 'Rector\\Transform\\Rector\\MethodCall\\MethodCallToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToMethodCallRector.php', 'Rector\\Transform\\Rector\\MethodCall\\MethodCallToPropertyFetchRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php', @@ -3019,7 +3018,6 @@ class ComposerStaticIniteba99b089a008fa8685ebae07df294c6 'Rector\\Transform\\ValueObject\\StaticCallToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/StaticCallToMethodCall.php', 'Rector\\Transform\\ValueObject\\StaticCallToNew' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/StaticCallToNew.php', 'Rector\\Transform\\ValueObject\\StringToClassConstant' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/StringToClassConstant.php', - 'Rector\\Transform\\ValueObject\\UnsetAndIssetToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/UnsetAndIssetToMethodCall.php', 'Rector\\Transform\\ValueObject\\WrapReturn' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/WrapReturn.php', 'Rector\\TypeDeclaration\\AlreadyAssignDetector\\ConstructorAssignDetector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/AlreadyAssignDetector/ConstructorAssignDetector.php', 'Rector\\TypeDeclaration\\AlreadyAssignDetector\\NullTypeAssignDetector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/AlreadyAssignDetector/NullTypeAssignDetector.php', @@ -3144,9 +3142,9 @@ class ComposerStaticIniteba99b089a008fa8685ebae07df294c6 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticIniteba99b089a008fa8685ebae07df294c6::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticIniteba99b089a008fa8685ebae07df294c6::$prefixDirsPsr4; - $loader->classMap = ComposerStaticIniteba99b089a008fa8685ebae07df294c6::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65::$classMap; }, null, ClassLoader::class); }