From 13cb0fa921fdfff899428b2e84ae2bbf63ba022d Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 24 May 2023 09:42:43 +0000 Subject: [PATCH] Updated Rector to commit 279126145e995c4d0b39a60bd6fc5fff5799199e https://github.com/rectorphp/rector-src/commit/279126145e995c4d0b39a60bd6fc5fff5799199e Refactor PARENT_NODE away from UnsetCastRector (#3945) --- rules/Php72/Rector/Unset_/UnsetCastRector.php | 31 ++++++++++++------- src/Application/VersionResolver.php | 4 +-- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 10 +++--- vendor/composer/autoload_static.php | 8 ++--- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/rules/Php72/Rector/Unset_/UnsetCastRector.php b/rules/Php72/Rector/Unset_/UnsetCastRector.php index 9511bb53fb6..d496155e715 100644 --- a/rules/Php72/Rector/Unset_/UnsetCastRector.php +++ b/rules/Php72/Rector/Unset_/UnsetCastRector.php @@ -6,10 +6,10 @@ namespace Rector\Php72\Rector\Unset_; use PhpParser\Node; use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\Cast\Unset_; +use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Stmt\Expression; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; -use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -41,27 +41,34 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [Unset_::class, Assign::class]; + return [Unset_::class, Assign::class, Expression::class]; } /** - * @param Unset_|Assign $node + * @param Unset_|Assign|Expression $node */ public function refactor(Node $node) : ?Node { if ($node instanceof Assign) { - if ($node->expr instanceof Unset_) { - $unset = $node->expr; - if ($this->nodeComparator->areNodesEqual($node->var, $unset->expr)) { - return $this->nodeFactory->createFuncCall('unset', [$node->var]); - } - } - return null; + return $this->refactorAssign($node); } - $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); - if ($parentNode instanceof Expression) { + if ($node instanceof Expression) { + if (!$node->expr instanceof Unset_) { + return null; + } $this->removeNode($node); return null; } return $this->nodeFactory->createNull(); } + private function refactorAssign(Assign $assign) : ?FuncCall + { + if (!$assign->expr instanceof Unset_) { + return null; + } + $unset = $assign->expr; + if (!$this->nodeComparator->areNodesEqual($assign->var, $unset->expr)) { + return null; + } + return $this->nodeFactory->createFuncCall('unset', [$assign->var]); + } } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 369b2515b6a..410ca98bd8f 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 = 'c504b2f11f2b732a744ad804b3a4b5afc30e2841'; + public const PACKAGE_VERSION = '279126145e995c4d0b39a60bd6fc5fff5799199e'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-05-24 09:31:55'; + public const RELEASE_DATE = '2023-05-24 09:38:51'; /** * @var int */ diff --git a/vendor/autoload.php b/vendor/autoload.php index aaa12dece8f..f022580a79a 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 ComposerAutoloaderInitd1e79f67f253438ff69fc93ef401a7af::getLoader(); +return ComposerAutoloaderInit68fa97b402c8b0e8b73786dcfe58719b::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 991e096d065..8d4f9536cfa 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitd1e79f67f253438ff69fc93ef401a7af +class ComposerAutoloaderInit68fa97b402c8b0e8b73786dcfe58719b { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInitd1e79f67f253438ff69fc93ef401a7af return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitd1e79f67f253438ff69fc93ef401a7af', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit68fa97b402c8b0e8b73786dcfe58719b', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitd1e79f67f253438ff69fc93ef401a7af', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit68fa97b402c8b0e8b73786dcfe58719b', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit68fa97b402c8b0e8b73786dcfe58719b::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit68fa97b402c8b0e8b73786dcfe58719b::$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 ff29701d6a4..baf82afbe90 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af +class ComposerStaticInit68fa97b402c8b0e8b73786dcfe58719b { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3106,9 +3106,9 @@ class ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitd1e79f67f253438ff69fc93ef401a7af::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit68fa97b402c8b0e8b73786dcfe58719b::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit68fa97b402c8b0e8b73786dcfe58719b::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit68fa97b402c8b0e8b73786dcfe58719b::$classMap; }, null, ClassLoader::class); }