mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-29 11:33:33 +01:00
Updated Rector to commit 64cca7759d28f2dc0d17acdf55eb10779818726c
64cca7759d
[DeadCode] Improve RemoveUnusedNonEmptyArrayBeforeForeachRector with && (#3587)
This commit is contained in:
parent
470e7f2c55
commit
7025ec875c
@ -4,6 +4,8 @@ declare (strict_types=1);
|
||||
namespace Rector\DeadCode\Rector\If_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Foreach_;
|
||||
@ -124,8 +126,13 @@ CODE_SAMPLE
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
if (($if->cond instanceof Variable || $this->propertyFetchAnalyzer->isPropertyFetch($if->cond)) && $this->nodeComparator->areNodesEqual($if->cond, $foreachExpr)) {
|
||||
return $scope->getType($if->cond)->isArray()->yes();
|
||||
$ifCond = $if->cond;
|
||||
if ($ifCond instanceof BooleanAnd) {
|
||||
return $this->isUselessBooleanAnd($ifCond, $foreachExpr);
|
||||
}
|
||||
if (($ifCond instanceof Variable || $this->propertyFetchAnalyzer->isPropertyFetch($ifCond)) && $this->nodeComparator->areNodesEqual($ifCond, $foreachExpr)) {
|
||||
$ifType = $scope->getType($ifCond);
|
||||
return $ifType->isArray()->yes();
|
||||
}
|
||||
if ($this->uselessIfCondBeforeForeachDetector->isMatchingNotIdenticalEmptyArray($if, $foreachExpr)) {
|
||||
return \true;
|
||||
@ -135,4 +142,14 @@ CODE_SAMPLE
|
||||
}
|
||||
return $this->countManipulator->isCounterHigherThanOne($if->cond, $foreachExpr);
|
||||
}
|
||||
private function isUselessBooleanAnd(BooleanAnd $booleanAnd, Expr $foreachExpr) : bool
|
||||
{
|
||||
if (!$booleanAnd->left instanceof Variable) {
|
||||
return \false;
|
||||
}
|
||||
if (!$this->nodeComparator->areNodesEqual($booleanAnd->left, $foreachExpr)) {
|
||||
return \false;
|
||||
}
|
||||
return $this->countManipulator->isCounterHigherThanOne($booleanAnd->right, $foreachExpr);
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ use PHPStan\Reflection\ParametersAcceptorSelector;
|
||||
use PHPStan\Reflection\Php\PhpMethodReflection;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\VoidType;
|
||||
use Rector\Core\PhpParser\AstResolver;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\PhpParser\Node\NodeFactory;
|
||||
|
@ -22,7 +22,6 @@ use PHPStan\Type\ThisType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\TypeWithClassName;
|
||||
use PHPStan\Type\UnionType;
|
||||
use PHPStan\Type\VoidType;
|
||||
use Rector\Core\Enum\ObjectReference;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Php\PhpVersionProvider;
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'a6ca5a0e8429d8c1423916c07ba5e72efdeafd44';
|
||||
public const PACKAGE_VERSION = '64cca7759d28f2dc0d17acdf55eb10779818726c';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-04-08 20:56:34';
|
||||
public const RELEASE_DATE = '2023-04-08 14:08:04';
|
||||
/**
|
||||
* @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 ComposerAutoloaderInitae801d21aa72af266cc7eac6f82f933f::getLoader();
|
||||
return ComposerAutoloaderInit033adc17bbfb50a98dd62d2bd676dc77::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 ComposerAutoloaderInitae801d21aa72af266cc7eac6f82f933f
|
||||
class ComposerAutoloaderInit033adc17bbfb50a98dd62d2bd676dc77
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInitae801d21aa72af266cc7eac6f82f933f
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitae801d21aa72af266cc7eac6f82f933f', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit033adc17bbfb50a98dd62d2bd676dc77', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitae801d21aa72af266cc7eac6f82f933f', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit033adc17bbfb50a98dd62d2bd676dc77', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitae801d21aa72af266cc7eac6f82f933f::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit033adc17bbfb50a98dd62d2bd676dc77::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitae801d21aa72af266cc7eac6f82f933f::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit033adc17bbfb50a98dd62d2bd676dc77::$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 ComposerStaticInitae801d21aa72af266cc7eac6f82f933f
|
||||
class ComposerStaticInit033adc17bbfb50a98dd62d2bd676dc77
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3135,9 +3135,9 @@ class ComposerStaticInitae801d21aa72af266cc7eac6f82f933f
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitae801d21aa72af266cc7eac6f82f933f::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitae801d21aa72af266cc7eac6f82f933f::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitae801d21aa72af266cc7eac6f82f933f::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit033adc17bbfb50a98dd62d2bd676dc77::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit033adc17bbfb50a98dd62d2bd676dc77::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit033adc17bbfb50a98dd62d2bd676dc77::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user