mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-15 15:42:22 +00:00
Updated Rector to commit 63cd74893d
63cd74893d
[DeadCode] Improve RemoveJustPropertyFetchRector and apply (#2435)
This commit is contained in:
parent
03ef1cdc0b
commit
43409e9080
|
@ -21,12 +21,9 @@ final class PhpDocTagRemover
|
|||
unset($phpDocNode->children[$key]);
|
||||
$phpDocInfo->markAsChanged();
|
||||
}
|
||||
if ($phpDocChildNode->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
$doctrineAnnotationTagValueNode = $phpDocChildNode->value;
|
||||
if ($doctrineAnnotationTagValueNode->hasClassName($name)) {
|
||||
unset($phpDocNode->children[$key]);
|
||||
$phpDocInfo->markAsChanged();
|
||||
}
|
||||
if ($phpDocChildNode->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode && $phpDocChildNode->value->hasClassName($name)) {
|
||||
unset($phpDocNode->children[$key]);
|
||||
$phpDocInfo->markAsChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,13 +81,11 @@ final class ClassAnnotationMatcher
|
|||
{
|
||||
foreach ($uses as $use) {
|
||||
$prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : '';
|
||||
$useUses = $use->uses;
|
||||
foreach ($useUses as $useUse) {
|
||||
foreach ($use->uses as $useUse) {
|
||||
if (!$useUse->alias instanceof \PhpParser\Node\Identifier) {
|
||||
continue;
|
||||
}
|
||||
$alias = $useUse->alias;
|
||||
if ($alias->toString() === $tag) {
|
||||
if ($useUse->alias->toString() === $tag) {
|
||||
return $prefix . $useUse->name->toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,9 +193,8 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co
|
|||
}
|
||||
private function createSpacelessPhpDocTagNode(string $tagName, \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode $genericTagValueNode, string $fullyQualifiedAnnotationClass) : \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode
|
||||
{
|
||||
$annotationContent = $genericTagValueNode->value;
|
||||
$formerStartEnd = $genericTagValueNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
||||
return $this->createDoctrineSpacelessPhpDocTagNode($annotationContent, $tagName, $fullyQualifiedAnnotationClass, $formerStartEnd);
|
||||
return $this->createDoctrineSpacelessPhpDocTagNode($genericTagValueNode->value, $tagName, $fullyQualifiedAnnotationClass, $formerStartEnd);
|
||||
}
|
||||
private function createDoctrineSpacelessPhpDocTagNode(string $annotationContent, string $tagName, string $fullyQualifiedAnnotationClass, \Rector\BetterPhpDocParser\ValueObject\StartAndEnd $startAndEnd) : \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode
|
||||
{
|
||||
|
|
|
@ -142,9 +142,8 @@ final class FamilyRelationsAnalyzer
|
|||
}
|
||||
if ($classLike instanceof \PhpParser\Node\Stmt\Class_) {
|
||||
if ($classLike->extends instanceof \PhpParser\Node\Name) {
|
||||
$extendName = $classLike->extends;
|
||||
$ancestorNames[] = $this->nodeNameResolver->getName($extendName);
|
||||
$ancestorNames = \array_merge($ancestorNames, $this->getClassLikeAncestorNames($extendName));
|
||||
$ancestorNames[] = $this->nodeNameResolver->getName($classLike->extends);
|
||||
$ancestorNames = \array_merge($ancestorNames, $this->getClassLikeAncestorNames($classLike->extends));
|
||||
}
|
||||
foreach ($classLike->implements as $implement) {
|
||||
$ancestorNames[] = $this->nodeNameResolver->getName($implement);
|
||||
|
|
|
@ -39,14 +39,13 @@ final class FuncCallNameResolver implements \Rector\NodeNameResolver\Contract\No
|
|||
if ($node->name instanceof \PhpParser\Node\Expr) {
|
||||
return null;
|
||||
}
|
||||
$functionName = $node->name;
|
||||
$namespaceName = $functionName->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NAMESPACED_NAME);
|
||||
$namespaceName = $node->name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NAMESPACED_NAME);
|
||||
if ($namespaceName instanceof \PhpParser\Node\Name\FullyQualified) {
|
||||
$functionFqnName = $namespaceName->toString();
|
||||
if ($this->reflectionProvider->hasFunction($namespaceName, null)) {
|
||||
return $functionFqnName;
|
||||
}
|
||||
}
|
||||
return (string) $functionName;
|
||||
return (string) $node->name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,11 +124,11 @@ final class PhpAttributeGroupFactory
|
|||
if (!$item instanceof \PhpParser\Node\Expr\ArrayItem) {
|
||||
continue;
|
||||
}
|
||||
$arrayItemKey = $item->key;
|
||||
if (!$arrayItemKey instanceof \PhpParser\Node\Scalar\String_) {
|
||||
if (!$item->key instanceof \PhpParser\Node\Scalar\String_) {
|
||||
continue;
|
||||
}
|
||||
if (!\in_array($arrayItemKey->value, $unwrappeColumns, \true)) {
|
||||
$stringItemKey = $item->key;
|
||||
if (!\in_array($stringItemKey->value, $unwrappeColumns, \true)) {
|
||||
continue;
|
||||
}
|
||||
unset($items[$key]);
|
||||
|
|
|
@ -13,6 +13,7 @@ use PhpParser\Node\Stmt;
|
|||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\While_;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\DeadCode\ValueObject\PropertyFetchToVariableAssign;
|
||||
|
@ -161,6 +162,9 @@ CODE_SAMPLE
|
|||
if (!$assign->expr instanceof \PhpParser\Node\Expr\PropertyFetch) {
|
||||
return null;
|
||||
}
|
||||
if ($this->isPropertyFetchCallerNode($assign->expr)) {
|
||||
return null;
|
||||
}
|
||||
// keep property fetch nesting
|
||||
if ($assign->expr->var instanceof \PhpParser\Node\Expr\PropertyFetch) {
|
||||
return null;
|
||||
|
@ -170,4 +174,14 @@ CODE_SAMPLE
|
|||
}
|
||||
return new \Rector\DeadCode\ValueObject\PropertyFetchToVariableAssign($assign->var, $assign->expr);
|
||||
}
|
||||
private function isPropertyFetchCallerNode(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : bool
|
||||
{
|
||||
// skip nodes as mostly used with public property fetches
|
||||
$propertyFetchCallerType = $this->getType($propertyFetch->var);
|
||||
if (!$propertyFetchCallerType instanceof \PHPStan\Type\ObjectType) {
|
||||
return \false;
|
||||
}
|
||||
$nodeObjectType = new \PHPStan\Type\ObjectType('PhpParser\\Node');
|
||||
return $nodeObjectType->isSuperTypeOf($propertyFetchCallerType)->yes();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ final class AliasNameResolver
|
|||
$nameString = $name->toString();
|
||||
foreach ($uses as $use) {
|
||||
$prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : '';
|
||||
$useUses = $use->uses;
|
||||
foreach ($useUses as $useUse) {
|
||||
foreach ($use->uses as $useUse) {
|
||||
if (!$useUse->alias instanceof \PhpParser\Node\Identifier) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'b0a61735508fdcf1adf33b9f8df7950666864c82';
|
||||
public const PACKAGE_VERSION = '63cd74893dcb8f30d0294910a1b23a66cc8ae3a3';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-06-04 17:31:24';
|
||||
public const RELEASE_DATE = '2022-06-04 18:02:21';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -42,8 +42,7 @@ final class ArrayManipulator
|
|||
if (!$this->isAllowedArrayKey($item->key)) {
|
||||
return \true;
|
||||
}
|
||||
$value = $item->value;
|
||||
if (!$this->isAllowedArrayValue($value)) {
|
||||
if (!$this->isAllowedArrayValue($item->value)) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,11 +95,10 @@ final class IfManipulator
|
|||
*/
|
||||
public function matchIfValueReturnValue(\PhpParser\Node\Stmt\If_ $if) : ?\PhpParser\Node\Expr
|
||||
{
|
||||
$stmts = $if->stmts;
|
||||
if (\count($stmts) !== 1) {
|
||||
if (\count($if->stmts) !== 1) {
|
||||
return null;
|
||||
}
|
||||
$insideIfStmt = $stmts[0];
|
||||
$insideIfStmt = $if->stmts[0];
|
||||
if (!$insideIfStmt instanceof \PhpParser\Node\Stmt\Return_) {
|
||||
return null;
|
||||
}
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitcd109bfaf077a7f2657c468440727e78::getLoader();
|
||||
return ComposerAutoloaderIniteac9a8b2d0976088259d2d3411219a6c::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 ComposerAutoloaderInitcd109bfaf077a7f2657c468440727e78
|
||||
class ComposerAutoloaderIniteac9a8b2d0976088259d2d3411219a6c
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInitcd109bfaf077a7f2657c468440727e78
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitcd109bfaf077a7f2657c468440727e78', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderIniteac9a8b2d0976088259d2d3411219a6c', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitcd109bfaf077a7f2657c468440727e78', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderIniteac9a8b2d0976088259d2d3411219a6c', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitcd109bfaf077a7f2657c468440727e78::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticIniteac9a8b2d0976088259d2d3411219a6c::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitcd109bfaf077a7f2657c468440727e78::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticIniteac9a8b2d0976088259d2d3411219a6c::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequirecd109bfaf077a7f2657c468440727e78($fileIdentifier, $file);
|
||||
composerRequireeac9a8b2d0976088259d2d3411219a6c($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInitcd109bfaf077a7f2657c468440727e78
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequirecd109bfaf077a7f2657c468440727e78($fileIdentifier, $file)
|
||||
function composerRequireeac9a8b2d0976088259d2d3411219a6c($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 ComposerStaticInitcd109bfaf077a7f2657c468440727e78
|
||||
class ComposerStaticIniteac9a8b2d0976088259d2d3411219a6c
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
|
@ -3791,9 +3791,9 @@ class ComposerStaticInitcd109bfaf077a7f2657c468440727e78
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitcd109bfaf077a7f2657c468440727e78::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitcd109bfaf077a7f2657c468440727e78::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitcd109bfaf077a7f2657c468440727e78::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticIniteac9a8b2d0976088259d2d3411219a6c::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticIniteac9a8b2d0976088259d2d3411219a6c::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticIniteac9a8b2d0976088259d2d3411219a6c::$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('RectorPrefix20220604\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInitcd109bfaf077a7f2657c468440727e78', false) && !interface_exists('ComposerAutoloaderInitcd109bfaf077a7f2657c468440727e78', false) && !trait_exists('ComposerAutoloaderInitcd109bfaf077a7f2657c468440727e78', false)) {
|
||||
spl_autoload_call('RectorPrefix20220604\ComposerAutoloaderInitcd109bfaf077a7f2657c468440727e78');
|
||||
if (!class_exists('ComposerAutoloaderIniteac9a8b2d0976088259d2d3411219a6c', false) && !interface_exists('ComposerAutoloaderIniteac9a8b2d0976088259d2d3411219a6c', false) && !trait_exists('ComposerAutoloaderIniteac9a8b2d0976088259d2d3411219a6c', false)) {
|
||||
spl_autoload_call('RectorPrefix20220604\ComposerAutoloaderIniteac9a8b2d0976088259d2d3411219a6c');
|
||||
}
|
||||
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('RectorPrefix20220604\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
|
@ -56,9 +56,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20220604\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequirecd109bfaf077a7f2657c468440727e78')) {
|
||||
function composerRequirecd109bfaf077a7f2657c468440727e78() {
|
||||
return \RectorPrefix20220604\composerRequirecd109bfaf077a7f2657c468440727e78(...func_get_args());
|
||||
if (!function_exists('composerRequireeac9a8b2d0976088259d2d3411219a6c')) {
|
||||
function composerRequireeac9a8b2d0976088259d2d3411219a6c() {
|
||||
return \RectorPrefix20220604\composerRequireeac9a8b2d0976088259d2d3411219a6c(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user