mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-26 04:42:36 +00:00
Updated Rector to commit c115811102
c115811102
[DeadCode] Skip Union Array without type on RemoveDeadInstanceOfRector (#672)
This commit is contained in:
parent
fd9090a133
commit
aeb2451688
|
@ -18,6 +18,7 @@ use PHPStan\Analyser\Scope;
|
|||
use Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer;
|
||||
use Rector\Core\NodeManipulator\IfManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeNestingScope\ContextAnalyzer;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\Php80\NodeAnalyzer\PromotedPropertyResolver;
|
||||
use Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector;
|
||||
|
@ -44,12 +45,17 @@ final class RemoveDeadInstanceOfRector extends \Rector\Core\Rector\AbstractRecto
|
|||
* @var \Rector\Php80\NodeAnalyzer\PromotedPropertyResolver
|
||||
*/
|
||||
private $promotedPropertyResolver;
|
||||
public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector $constructorAssignDetector, \Rector\Php80\NodeAnalyzer\PromotedPropertyResolver $promotedPropertyResolver)
|
||||
/**
|
||||
* @var \Rector\NodeNestingScope\ContextAnalyzer
|
||||
*/
|
||||
private $contextAnalyzer;
|
||||
public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector $constructorAssignDetector, \Rector\Php80\NodeAnalyzer\PromotedPropertyResolver $promotedPropertyResolver, \Rector\NodeNestingScope\ContextAnalyzer $contextAnalyzer)
|
||||
{
|
||||
$this->ifManipulator = $ifManipulator;
|
||||
$this->propertyFetchAnalyzer = $propertyFetchAnalyzer;
|
||||
$this->constructorAssignDetector = $constructorAssignDetector;
|
||||
$this->promotedPropertyResolver = $promotedPropertyResolver;
|
||||
$this->contextAnalyzer = $contextAnalyzer;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
|
@ -97,6 +103,9 @@ CODE_SAMPLE
|
|||
if (!$this->ifManipulator->isIfWithoutElseAndElseIfs($node)) {
|
||||
return null;
|
||||
}
|
||||
if ($this->contextAnalyzer->isInLoop($node)) {
|
||||
return null;
|
||||
}
|
||||
if ($node->cond instanceof \PhpParser\Node\Expr\BooleanNot && $node->cond->expr instanceof \PhpParser\Node\Expr\Instanceof_) {
|
||||
return $this->processMayDeadInstanceOf($node, $node->cond->expr);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,13 @@ CODE_SAMPLE
|
|||
if (!$class instanceof \PhpParser\Node\Stmt\Class_) {
|
||||
return \false;
|
||||
}
|
||||
return $typeWithClassName instanceof \PHPStan\Type\ThisType && !$class->isFinal() && !$classMethod->isPrivate();
|
||||
if (!$typeWithClassName instanceof \PHPStan\Type\ThisType) {
|
||||
return \false;
|
||||
}
|
||||
if ($class->isFinal()) {
|
||||
return \false;
|
||||
}
|
||||
return !$classMethod->isPrivate();
|
||||
}
|
||||
/**
|
||||
* @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\ConstFetch
|
||||
|
|
|
@ -8,6 +8,7 @@ use PhpParser\Node\Arg;
|
|||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Defluent\Matcher\AssignAndRootExprAndNodesToAddMatcher;
|
||||
|
@ -83,6 +84,10 @@ CODE_SAMPLE
|
|||
if (!$parent instanceof \PhpParser\Node\Expr\Assign) {
|
||||
return null;
|
||||
}
|
||||
$parentParent = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
if (!$parentParent instanceof \PhpParser\Node\Stmt\Expression) {
|
||||
return null;
|
||||
}
|
||||
$statement = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
|
||||
$previous = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE);
|
||||
if ($this->isFoundInPrevious($statement, $previous)) {
|
||||
|
|
|
@ -79,11 +79,11 @@ CODE_SAMPLE
|
|||
}
|
||||
$left = $node->expr->left;
|
||||
$ifNegations = $this->createMultipleIfsNegation($left, $node, []);
|
||||
if (!$this->callAnalyzer->doesIfHasObjectCall($ifNegations)) {
|
||||
return null;
|
||||
}
|
||||
$this->mirrorComments($ifNegations[0], $node);
|
||||
foreach ($ifNegations as $ifNegation) {
|
||||
if (!$this->callAnalyzer->isObjectCall($ifNegation->cond)) {
|
||||
return null;
|
||||
}
|
||||
$this->addNodeBeforeNode($ifNegation, $node);
|
||||
}
|
||||
/** @var BooleanAnd $booleanAnd */
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'cc89395feeb3ed2a85b186a93722f9dd27e06ec1';
|
||||
public const PACKAGE_VERSION = 'c115811102cfb2e88b80258e3d18c51a19e9ba44';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-08-13 22:30:34';
|
||||
public const RELEASE_DATE = '2021-08-13 22:32:05';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20210813\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
|
|
@ -162,7 +162,13 @@ final class PropertyFetchAnalyzer
|
|||
if (!$node instanceof \PhpParser\Node\Expr\Assign) {
|
||||
return \false;
|
||||
}
|
||||
return $kindPropertyFetch === \get_class($node->var) && $this->nodeNameResolver->isName($node->var, $propertyName) && $this->nodeComparator->areNodesEqual($node->expr, $paramVariable);
|
||||
if ($kindPropertyFetch !== \get_class($node->var)) {
|
||||
return \false;
|
||||
}
|
||||
if (!$this->nodeNameResolver->isName($node->var, $propertyName)) {
|
||||
return \false;
|
||||
}
|
||||
return $this->nodeComparator->areNodesEqual($node->expr, $paramVariable);
|
||||
});
|
||||
if ($isAssignWithParamVarName !== null) {
|
||||
return \true;
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit5bcc09f43aae40430f1f4d2783d03a49::getLoader();
|
||||
return ComposerAutoloaderInit79c07fcbf7c46bec9d48f90585d68b03::getLoader();
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit5bcc09f43aae40430f1f4d2783d03a49
|
||||
class ComposerAutoloaderInit79c07fcbf7c46bec9d48f90585d68b03
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit5bcc09f43aae40430f1f4d2783d03a49
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit5bcc09f43aae40430f1f4d2783d03a49', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit79c07fcbf7c46bec9d48f90585d68b03', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit5bcc09f43aae40430f1f4d2783d03a49', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit79c07fcbf7c46bec9d48f90585d68b03', '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\ComposerStaticInit5bcc09f43aae40430f1f4d2783d03a49::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit79c07fcbf7c46bec9d48f90585d68b03::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInit5bcc09f43aae40430f1f4d2783d03a49
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit5bcc09f43aae40430f1f4d2783d03a49::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit79c07fcbf7c46bec9d48f90585d68b03::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire5bcc09f43aae40430f1f4d2783d03a49($fileIdentifier, $file);
|
||||
composerRequire79c07fcbf7c46bec9d48f90585d68b03($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire5bcc09f43aae40430f1f4d2783d03a49($fileIdentifier, $file)
|
||||
function composerRequire79c07fcbf7c46bec9d48f90585d68b03($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit5bcc09f43aae40430f1f4d2783d03a49
|
||||
class ComposerStaticInit79c07fcbf7c46bec9d48f90585d68b03
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -3850,9 +3850,9 @@ class ComposerStaticInit5bcc09f43aae40430f1f4d2783d03a49
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit5bcc09f43aae40430f1f4d2783d03a49::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit5bcc09f43aae40430f1f4d2783d03a49::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit5bcc09f43aae40430f1f4d2783d03a49::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit79c07fcbf7c46bec9d48f90585d68b03::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit79c07fcbf7c46bec9d48f90585d68b03::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit79c07fcbf7c46bec9d48f90585d68b03::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
|
@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
|
|||
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
|
||||
spl_autoload_call('RectorPrefix20210813\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit5bcc09f43aae40430f1f4d2783d03a49', false) && !interface_exists('ComposerAutoloaderInit5bcc09f43aae40430f1f4d2783d03a49', false) && !trait_exists('ComposerAutoloaderInit5bcc09f43aae40430f1f4d2783d03a49', false)) {
|
||||
spl_autoload_call('RectorPrefix20210813\ComposerAutoloaderInit5bcc09f43aae40430f1f4d2783d03a49');
|
||||
if (!class_exists('ComposerAutoloaderInit79c07fcbf7c46bec9d48f90585d68b03', false) && !interface_exists('ComposerAutoloaderInit79c07fcbf7c46bec9d48f90585d68b03', false) && !trait_exists('ComposerAutoloaderInit79c07fcbf7c46bec9d48f90585d68b03', false)) {
|
||||
spl_autoload_call('RectorPrefix20210813\ComposerAutoloaderInit79c07fcbf7c46bec9d48f90585d68b03');
|
||||
}
|
||||
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
|
||||
spl_autoload_call('RectorPrefix20210813\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
|
@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20210813\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire5bcc09f43aae40430f1f4d2783d03a49')) {
|
||||
function composerRequire5bcc09f43aae40430f1f4d2783d03a49() {
|
||||
return \RectorPrefix20210813\composerRequire5bcc09f43aae40430f1f4d2783d03a49(...func_get_args());
|
||||
if (!function_exists('composerRequire79c07fcbf7c46bec9d48f90585d68b03')) {
|
||||
function composerRequire79c07fcbf7c46bec9d48f90585d68b03() {
|
||||
return \RectorPrefix20210813\composerRequire79c07fcbf7c46bec9d48f90585d68b03(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user