diff --git a/rules/Php80/NodeAnalyzer/SwitchAnalyzer.php b/rules/Php80/NodeAnalyzer/SwitchAnalyzer.php index f26f02d7a37e..1828077598a6 100644 --- a/rules/Php80/NodeAnalyzer/SwitchAnalyzer.php +++ b/rules/Php80/NodeAnalyzer/SwitchAnalyzer.php @@ -5,6 +5,8 @@ use PhpParser\Node; use PhpParser\Node\Stmt\Break_; +use PhpParser\Node\Stmt\Case_; +use PhpParser\Node\Stmt\Return_; use PhpParser\Node\Stmt\Switch_; final class SwitchAnalyzer { @@ -18,10 +20,8 @@ public function hasEachCaseBreak(\PhpParser\Node\Stmt\Switch_ $switch) : bool if ($key === $totalCases - 1) { return \true; } - foreach ($case->stmts as $caseStmt) { - if ($caseStmt instanceof \PhpParser\Node\Stmt\Break_) { - continue 2; - } + if ($this->hasBreakOrReturn($case)) { + continue; } return \false; } @@ -48,4 +48,16 @@ public function hasDefault(\PhpParser\Node\Stmt\Switch_ $switch) : bool } return \false; } + private function hasBreakOrReturn(\PhpParser\Node\Stmt\Case_ $case) : bool + { + foreach ($case->stmts as $caseStmt) { + if ($caseStmt instanceof \PhpParser\Node\Stmt\Break_) { + return \true; + } + if ($caseStmt instanceof \PhpParser\Node\Stmt\Return_) { + return \true; + } + } + return \false; + } } diff --git a/rules/Php80/NodeResolver/SwitchExprsResolver.php b/rules/Php80/NodeResolver/SwitchExprsResolver.php index 7b4f5db1e62f..5dcf58c4980c 100644 --- a/rules/Php80/NodeResolver/SwitchExprsResolver.php +++ b/rules/Php80/NodeResolver/SwitchExprsResolver.php @@ -61,6 +61,10 @@ private function isValidCase(\PhpParser\Node\Stmt\Case_ $case) : bool if ($case->stmts[0] instanceof \PhpParser\Node\Stmt\Throw_) { return \true; } + // instant return + if ($case->stmts[0] instanceof \PhpParser\Node\Stmt\Return_) { + return \true; + } // default value return $case->cond === null; } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 719538e08358..cc51088ba555 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -16,11 +16,11 @@ final class VersionResolver /** * @var string */ - public const PACKAGE_VERSION = 'e3e31f5eba216cb79f0130e7d6327d65eca0d4b1'; + public const PACKAGE_VERSION = 'ca1cdfa8705d38acd10c26d79db630f7d2b96874'; /** * @var string */ - public const RELEASE_DATE = '2021-06-08 07:50:11'; + public const RELEASE_DATE = '2021-06-08 08:11:25'; public static function resolvePackageVersion() : string { $process = new \RectorPrefix20210608\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__); diff --git a/vendor/autoload.php b/vendor/autoload.php index 3440202f7c88..0d9b88ae60ba 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit16373a4a7b44f1d56492a8ac3787ff26::getLoader(); +return ComposerAutoloaderInitb1be5d6eac857f69487006a3dd7f0afe::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 41817bd2401d..b4d7d7039fbe 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit16373a4a7b44f1d56492a8ac3787ff26 +class ComposerAutoloaderInitb1be5d6eac857f69487006a3dd7f0afe { private static $loader; @@ -22,15 +22,15 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit16373a4a7b44f1d56492a8ac3787ff26', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitb1be5d6eac857f69487006a3dd7f0afe', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); - spl_autoload_unregister(array('ComposerAutoloaderInit16373a4a7b44f1d56492a8ac3787ff26', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitb1be5d6eac857f69487006a3dd7f0afe', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit16373a4a7b44f1d56492a8ac3787ff26::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitb1be5d6eac857f69487006a3dd7f0afe::getInitializer($loader)); } else { $classMap = require __DIR__ . '/autoload_classmap.php'; if ($classMap) { @@ -42,19 +42,19 @@ public static function getLoader() $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit16373a4a7b44f1d56492a8ac3787ff26::$files; + $includeFiles = Composer\Autoload\ComposerStaticInitb1be5d6eac857f69487006a3dd7f0afe::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire16373a4a7b44f1d56492a8ac3787ff26($fileIdentifier, $file); + composerRequireb1be5d6eac857f69487006a3dd7f0afe($fileIdentifier, $file); } return $loader; } } -function composerRequire16373a4a7b44f1d56492a8ac3787ff26($fileIdentifier, $file) +function composerRequireb1be5d6eac857f69487006a3dd7f0afe($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index e46bb6e1ec23..57099ae1c246 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit16373a4a7b44f1d56492a8ac3787ff26 +class ComposerStaticInitb1be5d6eac857f69487006a3dd7f0afe { public static $files = array ( 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', @@ -3875,9 +3875,9 @@ class ComposerStaticInit16373a4a7b44f1d56492a8ac3787ff26 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit16373a4a7b44f1d56492a8ac3787ff26::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit16373a4a7b44f1d56492a8ac3787ff26::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit16373a4a7b44f1d56492a8ac3787ff26::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitb1be5d6eac857f69487006a3dd7f0afe::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitb1be5d6eac857f69487006a3dd7f0afe::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitb1be5d6eac857f69487006a3dd7f0afe::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/scoper-autoload.php b/vendor/scoper-autoload.php index 64a18051fc3d..c1ea084948d0 100644 --- a/vendor/scoper-autoload.php +++ b/vendor/scoper-autoload.php @@ -21,8 +21,8 @@ if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) { spl_autoload_call('RectorPrefix20210608\CheckoutEntityFactory'); } -if (!class_exists('ComposerAutoloaderInit16373a4a7b44f1d56492a8ac3787ff26', false) && !interface_exists('ComposerAutoloaderInit16373a4a7b44f1d56492a8ac3787ff26', false) && !trait_exists('ComposerAutoloaderInit16373a4a7b44f1d56492a8ac3787ff26', false)) { - spl_autoload_call('RectorPrefix20210608\ComposerAutoloaderInit16373a4a7b44f1d56492a8ac3787ff26'); +if (!class_exists('ComposerAutoloaderInitb1be5d6eac857f69487006a3dd7f0afe', false) && !interface_exists('ComposerAutoloaderInitb1be5d6eac857f69487006a3dd7f0afe', false) && !trait_exists('ComposerAutoloaderInitb1be5d6eac857f69487006a3dd7f0afe', false)) { + spl_autoload_call('RectorPrefix20210608\ComposerAutoloaderInitb1be5d6eac857f69487006a3dd7f0afe'); } if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) { spl_autoload_call('RectorPrefix20210608\Doctrine\Inflector\Inflector'); @@ -3323,9 +3323,9 @@ function print_node() { return \RectorPrefix20210608\print_node(...func_get_args()); } } -if (!function_exists('composerRequire16373a4a7b44f1d56492a8ac3787ff26')) { - function composerRequire16373a4a7b44f1d56492a8ac3787ff26() { - return \RectorPrefix20210608\composerRequire16373a4a7b44f1d56492a8ac3787ff26(...func_get_args()); +if (!function_exists('composerRequireb1be5d6eac857f69487006a3dd7f0afe')) { + function composerRequireb1be5d6eac857f69487006a3dd7f0afe() { + return \RectorPrefix20210608\composerRequireb1be5d6eac857f69487006a3dd7f0afe(...func_get_args()); } } if (!function_exists('parseArgs')) {