mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 05:18:18 +01:00
Updated Rector to commit d78bfb44bebd32bd212a1f1ca43d2da51b22286d
d78bfb44be
[Strict] Fix DisallowedEmptyRuleFixerRector on empty string isset (#4485)
This commit is contained in:
parent
ae068885cc
commit
db04f76104
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit8ba89176c86d2d04645b4b1044bc6857::getLoader();
|
||||
return ComposerAutoloaderInit13e0f54f1e6a63de1ed53ff5e41b1b62::getLoader();
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -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;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user