Skip to content

Commit

Permalink
Updated Rector to commit ca1cdfa
Browse files Browse the repository at this point in the history
rectorphp/rector-src@ca1cdfa [PHP 8.0] Include instant returns in match (#177)
  • Loading branch information
TomasVotruba committed Jun 8, 2021
1 parent 9e4c2be commit a5a511d
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 23 deletions.
20 changes: 16 additions & 4 deletions rules/Php80/NodeAnalyzer/SwitchAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
}
Expand All @@ -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;
}
}
4 changes: 4 additions & 0 deletions rules/Php80/NodeResolver/SwitchExprsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit16373a4a7b44f1d56492a8ac3787ff26::getLoader();
return ComposerAutoloaderInitb1be5d6eac857f69487006a3dd7f0afe::getLoader();
14 changes: 7 additions & 7 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit16373a4a7b44f1d56492a8ac3787ff26
class ComposerAutoloaderInitb1be5d6eac857f69487006a3dd7f0afe
{
private static $loader;

Expand All @@ -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) {
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit16373a4a7b44f1d56492a8ac3787ff26
class ComposerStaticInitb1be5d6eac857f69487006a3dd7f0afe
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions vendor/scoper-autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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')) {
Expand Down

0 comments on commit a5a511d

Please sign in to comment.