From db04f7610485f8c4853cdcf273629400b8593805 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 12 Jul 2023 07:23:56 +0000 Subject: [PATCH] Updated Rector to commit d78bfb44bebd32bd212a1f1ca43d2da51b22286d https://github.com/rectorphp/rector-src/commit/d78bfb44bebd32bd212a1f1ca43d2da51b22286d [Strict] Fix DisallowedEmptyRuleFixerRector on empty string isset (#4485) --- .../Catch_/RemoveUnusedVariableInCatchRector.php | 7 ++++++- .../Empty_/DisallowedEmptyRuleFixerRector.php | 15 +++++++++++++++ src/Application/VersionResolver.php | 4 ++-- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 10 +++++----- vendor/composer/autoload_static.php | 8 ++++---- 6 files changed, 33 insertions(+), 13 deletions(-) diff --git a/rules/Php80/Rector/Catch_/RemoveUnusedVariableInCatchRector.php b/rules/Php80/Rector/Catch_/RemoveUnusedVariableInCatchRector.php index cd99dd03bf2..ee4c3b6d63d 100644 --- a/rules/Php80/Rector/Catch_/RemoveUnusedVariableInCatchRector.php +++ b/rules/Php80/Rector/Catch_/RemoveUnusedVariableInCatchRector.php @@ -70,6 +70,7 @@ CODE_SAMPLE if ($node->stmts === null) { return null; } + $hasChanged = \false; foreach ($node->stmts as $key => $stmt) { if (!$stmt instanceof TryCatch) { continue; @@ -89,9 +90,13 @@ CODE_SAMPLE continue; } $catch->var = null; + $hasChanged = \true; } } - return $node; + if ($hasChanged) { + return $node; + } + return null; } public function provideMinPhpVersion() : int { diff --git a/rules/Strict/Rector/Empty_/DisallowedEmptyRuleFixerRector.php b/rules/Strict/Rector/Empty_/DisallowedEmptyRuleFixerRector.php index c0408a473e4..52bd46a7ba9 100644 --- a/rules/Strict/Rector/Empty_/DisallowedEmptyRuleFixerRector.php +++ b/rules/Strict/Rector/Empty_/DisallowedEmptyRuleFixerRector.php @@ -6,8 +6,10 @@ namespace Rector\Strict\Rector\Empty_; use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Expr\ArrayDimFetch; +use PhpParser\Node\Expr\BinaryOp\BooleanAnd; use PhpParser\Node\Expr\BooleanNot; use PhpParser\Node\Expr\Empty_; +use PhpParser\Node\Expr\Isset_; use PHPStan\Analyser\Scope; use Rector\Strict\NodeFactory\ExactCompareFactory; use Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector; @@ -76,6 +78,9 @@ CODE_SAMPLE return null; } $empty = $booleanNot->expr; + if ($empty->expr instanceof ArrayDimFetch) { + return $this->createDimFetchBooleanAnd($empty); + } $emptyExprType = $scope->getType($empty->expr); return $this->exactCompareFactory->createNotIdenticalFalsyCompare($emptyExprType, $empty->expr, $this->treatAsNonEmpty); } @@ -84,4 +89,14 @@ CODE_SAMPLE $exprType = $scope->getType($empty->expr); return $this->exactCompareFactory->createIdenticalFalsyCompare($exprType, $empty->expr, $treatAsNonEmpty); } + private function createDimFetchBooleanAnd(Empty_ $empty) : ?BooleanAnd + { + $exprType = $this->getType($empty->expr); + $isset = new Isset_([$empty->expr]); + $compareExpr = $this->exactCompareFactory->createNotIdenticalFalsyCompare($exprType, $empty->expr, \false); + if (!$compareExpr instanceof Expr) { + return null; + } + return new BooleanAnd($isset, $compareExpr); + } } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 8f4249c77a6..a595691caaf 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 = '3648297e5b2bc393b41fa85eba1028d3735dbaa6'; + public const PACKAGE_VERSION = 'd78bfb44bebd32bd212a1f1ca43d2da51b22286d'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-07-11 23:45:14'; + public const RELEASE_DATE = '2023-07-12 07:18:29'; /** * @var int */ diff --git a/vendor/autoload.php b/vendor/autoload.php index 61d099afa8b..528bf02db0d 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 ComposerAutoloaderInit8ba89176c86d2d04645b4b1044bc6857::getLoader(); +return ComposerAutoloaderInit13e0f54f1e6a63de1ed53ff5e41b1b62::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index b32afb6adfc..ca4cb8a955d 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit8ba89176c86d2d04645b4b1044bc6857 +class ComposerAutoloaderInit13e0f54f1e6a63de1ed53ff5e41b1b62 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInit8ba89176c86d2d04645b4b1044bc6857 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit8ba89176c86d2d04645b4b1044bc6857', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit13e0f54f1e6a63de1ed53ff5e41b1b62', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit8ba89176c86d2d04645b4b1044bc6857', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit13e0f54f1e6a63de1ed53ff5e41b1b62', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit8ba89176c86d2d04645b4b1044bc6857::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit13e0f54f1e6a63de1ed53ff5e41b1b62::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInit8ba89176c86d2d04645b4b1044bc6857::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit13e0f54f1e6a63de1ed53ff5e41b1b62::$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 d3721b2cc37..61ef4a3fe28 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit8ba89176c86d2d04645b4b1044bc6857 +class ComposerStaticInit13e0f54f1e6a63de1ed53ff5e41b1b62 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3062,9 +3062,9 @@ class ComposerStaticInit8ba89176c86d2d04645b4b1044bc6857 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit8ba89176c86d2d04645b4b1044bc6857::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit8ba89176c86d2d04645b4b1044bc6857::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit8ba89176c86d2d04645b4b1044bc6857::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit13e0f54f1e6a63de1ed53ff5e41b1b62::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit13e0f54f1e6a63de1ed53ff5e41b1b62::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit13e0f54f1e6a63de1ed53ff5e41b1b62::$classMap; }, null, ClassLoader::class); }