mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 22:08:00 +01:00
Updated Rector to commit 9dc237fff756c096ed67cf835ec1a7f07115e016
9dc237fff7
[NodeAnalyzer] Remove parent lookup on PropertyFetchAnalyzer (#4177)
This commit is contained in:
parent
a3387ee9c4
commit
1b9c15ef4c
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '8c1928bf9866774c5f8be94b88d10c75e31aacfb';
|
||||
public const PACKAGE_VERSION = '9dc237fff756c096ed67cf835ec1a7f07115e016';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-06-11 07:53:22';
|
||||
public const RELEASE_DATE = '2023-06-11 15:25:03';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -15,7 +15,7 @@ final class RectorKernel
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const CACHE_KEY = 'v92';
|
||||
private const CACHE_KEY = 'v93';
|
||||
/**
|
||||
* @var \Symfony\Component\DependencyInjection\ContainerInterface|null
|
||||
*/
|
||||
|
@ -12,17 +12,18 @@ use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Expr\StaticPropertyFetch;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PhpParser\Node\Stmt\Trait_;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\ThisType;
|
||||
use Rector\Core\Enum\ObjectReference;
|
||||
use Rector\Core\PhpParser\AstResolver;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\Core\ValueObject\MethodName;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
@ -49,16 +50,22 @@ final class PropertyFetchAnalyzer
|
||||
* @var \Rector\NodeTypeResolver\NodeTypeResolver
|
||||
*/
|
||||
private $nodeTypeResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Reflection\ReflectionResolver
|
||||
*/
|
||||
private $reflectionResolver;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const THIS = 'this';
|
||||
public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, AstResolver $astResolver, NodeTypeResolver $nodeTypeResolver)
|
||||
public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, AstResolver $astResolver, NodeTypeResolver $nodeTypeResolver, ReflectionResolver $reflectionResolver)
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->astResolver = $astResolver;
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
$this->reflectionResolver = $reflectionResolver;
|
||||
}
|
||||
public function isLocalPropertyFetch(Node $node) : bool
|
||||
{
|
||||
@ -67,9 +74,9 @@ final class PropertyFetchAnalyzer
|
||||
}
|
||||
$variableType = $node instanceof PropertyFetch ? $this->nodeTypeResolver->getType($node->var) : $this->nodeTypeResolver->getType($node->class);
|
||||
if ($variableType instanceof FullyQualifiedObjectType) {
|
||||
$currentClassLike = $this->betterNodeFinder->findParentType($node, ClassLike::class);
|
||||
if ($currentClassLike instanceof ClassLike) {
|
||||
return $this->nodeNameResolver->isName($currentClassLike, $variableType->getClassName());
|
||||
$classReflection = $this->reflectionResolver->resolveClassReflection($node);
|
||||
if ($classReflection instanceof ClassReflection) {
|
||||
return $classReflection->getName() === $variableType->getClassName();
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
@ -137,11 +144,14 @@ final class PropertyFetchAnalyzer
|
||||
if (!$callerClassMethod instanceof ClassMethod) {
|
||||
continue;
|
||||
}
|
||||
$callerClass = $this->betterNodeFinder->findParentType($callerClassMethod, Class_::class);
|
||||
if (!$callerClass instanceof Class_) {
|
||||
$callerClassReflection = $this->reflectionResolver->resolveClassReflection($callerClassMethod);
|
||||
if (!$callerClassReflection instanceof ClassReflection) {
|
||||
continue;
|
||||
}
|
||||
$callerClassName = (string) $this->nodeNameResolver->getName($callerClass);
|
||||
if (!$callerClassReflection->isClass()) {
|
||||
continue;
|
||||
}
|
||||
$callerClassName = $callerClassReflection->getName();
|
||||
$isFound = $this->isPropertyAssignFoundInClassMethod($classLike, $className, $callerClassName, $callerClassMethod, $propertyName);
|
||||
if ($isFound) {
|
||||
return \true;
|
||||
|
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 ComposerAutoloaderInite94aa1c811ee6223fa5d6458b0037926::getLoader();
|
||||
return ComposerAutoloaderInit4c29f62e7d2a2bd42d07053841c1792f::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 ComposerAutoloaderInite94aa1c811ee6223fa5d6458b0037926
|
||||
class ComposerAutoloaderInit4c29f62e7d2a2bd42d07053841c1792f
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInite94aa1c811ee6223fa5d6458b0037926
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInite94aa1c811ee6223fa5d6458b0037926', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit4c29f62e7d2a2bd42d07053841c1792f', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInite94aa1c811ee6223fa5d6458b0037926', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit4c29f62e7d2a2bd42d07053841c1792f', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInite94aa1c811ee6223fa5d6458b0037926::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit4c29f62e7d2a2bd42d07053841c1792f::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInite94aa1c811ee6223fa5d6458b0037926::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit4c29f62e7d2a2bd42d07053841c1792f::$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 ComposerStaticInite94aa1c811ee6223fa5d6458b0037926
|
||||
class ComposerStaticInit4c29f62e7d2a2bd42d07053841c1792f
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3127,9 +3127,9 @@ class ComposerStaticInite94aa1c811ee6223fa5d6458b0037926
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInite94aa1c811ee6223fa5d6458b0037926::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInite94aa1c811ee6223fa5d6458b0037926::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInite94aa1c811ee6223fa5d6458b0037926::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit4c29f62e7d2a2bd42d07053841c1792f::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit4c29f62e7d2a2bd42d07053841c1792f::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit4c29f62e7d2a2bd42d07053841c1792f::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user