mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 22:08:00 +01:00
Updated Rector to commit 5f976fa8c3eccf209e17e16d36fb6eb68c782ab4
5f976fa8c3
[ReadWrite] Remove parent lookup on LocalPropertyFetchReadNodeAnalyzer (#4263)
This commit is contained in:
parent
a0d8cc6508
commit
c363d3ea16
@ -7,8 +7,10 @@ use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\StaticPropertyFetch;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use Rector\Core\PhpParser\ClassLikeAstResolver;
|
||||
use Rector\Core\PhpParser\NodeFinder\PropertyFetchFinder;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\ReadWrite\Contract\ReadNodeAnalyzerInterface;
|
||||
/**
|
||||
@ -33,15 +35,21 @@ final class LocalPropertyFetchReadNodeAnalyzer implements ReadNodeAnalyzerInterf
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
|
||||
* @var \Rector\Core\Reflection\ReflectionResolver
|
||||
*/
|
||||
private $betterNodeFinder;
|
||||
public function __construct(\Rector\ReadWrite\ReadNodeAnalyzer\JustReadExprAnalyzer $justReadExprAnalyzer, PropertyFetchFinder $propertyFetchFinder, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder)
|
||||
private $reflectionResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\ClassLikeAstResolver
|
||||
*/
|
||||
private $classLikeAstResolver;
|
||||
public function __construct(\Rector\ReadWrite\ReadNodeAnalyzer\JustReadExprAnalyzer $justReadExprAnalyzer, PropertyFetchFinder $propertyFetchFinder, NodeNameResolver $nodeNameResolver, ReflectionResolver $reflectionResolver, ClassLikeAstResolver $classLikeAstResolver)
|
||||
{
|
||||
$this->justReadExprAnalyzer = $justReadExprAnalyzer;
|
||||
$this->propertyFetchFinder = $propertyFetchFinder;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->reflectionResolver = $reflectionResolver;
|
||||
$this->classLikeAstResolver = $classLikeAstResolver;
|
||||
}
|
||||
public function supports(Expr $expr) : bool
|
||||
{
|
||||
@ -49,8 +57,8 @@ final class LocalPropertyFetchReadNodeAnalyzer implements ReadNodeAnalyzerInterf
|
||||
}
|
||||
public function isRead(Expr $expr) : bool
|
||||
{
|
||||
$class = $this->betterNodeFinder->findParentType($expr, Class_::class);
|
||||
if (!$class instanceof Class_) {
|
||||
$classReflection = $this->reflectionResolver->resolveClassReflection($expr);
|
||||
if (!$classReflection instanceof ClassReflection || !$classReflection->isClass()) {
|
||||
// assume worse to keep node protected
|
||||
return \true;
|
||||
}
|
||||
@ -59,6 +67,8 @@ final class LocalPropertyFetchReadNodeAnalyzer implements ReadNodeAnalyzerInterf
|
||||
// assume worse to keep node protected
|
||||
return \true;
|
||||
}
|
||||
/** @var Class_ $class */
|
||||
$class = $this->classLikeAstResolver->resolveClassFromClassReflection($classReflection);
|
||||
$propertyFetches = $this->propertyFetchFinder->findLocalPropertyFetchesByName($class, $propertyName);
|
||||
foreach ($propertyFetches as $propertyFetch) {
|
||||
if ($this->justReadExprAnalyzer->isReadContext($propertyFetch)) {
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '8550c092de01d1167d95922a77490c282f3154d5';
|
||||
public const PACKAGE_VERSION = '5f976fa8c3eccf209e17e16d36fb6eb68c782ab4';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-06-18 02:33:10';
|
||||
public const RELEASE_DATE = '2023-06-18 03:12:56';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -3,6 +3,7 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\PhpParser\NodeFinder;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\ArrayDimFetch;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
@ -84,14 +85,16 @@ final class PropertyFetchFinder
|
||||
*/
|
||||
public function findLocalPropertyFetchesByName(Class_ $class, string $paramName) : array
|
||||
{
|
||||
/** @var PropertyFetch[]|StaticPropertyFetch[] $propertyFetches */
|
||||
$propertyFetches = $this->betterNodeFinder->findInstancesOf($class, [PropertyFetch::class, StaticPropertyFetch::class]);
|
||||
$foundPropertyFetches = [];
|
||||
foreach ($propertyFetches as $propertyFetch) {
|
||||
if ($this->propertyFetchAnalyzer->isLocalPropertyFetchName($propertyFetch, $paramName)) {
|
||||
$foundPropertyFetches[] = $propertyFetch;
|
||||
/** @var PropertyFetch[]|StaticPropertyFetch[] $foundPropertyFetches */
|
||||
$foundPropertyFetches = $this->betterNodeFinder->find($class->getMethods(), function (Node $subNode) use($paramName) : bool {
|
||||
if ($subNode instanceof PropertyFetch) {
|
||||
return $this->propertyFetchAnalyzer->isLocalPropertyFetchName($subNode, $paramName);
|
||||
}
|
||||
}
|
||||
if ($subNode instanceof StaticPropertyFetch) {
|
||||
return $this->propertyFetchAnalyzer->isLocalPropertyFetchName($subNode, $paramName);
|
||||
}
|
||||
return \false;
|
||||
});
|
||||
return $foundPropertyFetches;
|
||||
}
|
||||
/**
|
||||
|
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 ComposerAutoloaderInit080ef22abaeaf79a5fc0600bde4b5ee7::getLoader();
|
||||
return ComposerAutoloaderInit4a8167255d24e2d319fa9c0d2dfb312f::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 ComposerAutoloaderInit080ef22abaeaf79a5fc0600bde4b5ee7
|
||||
class ComposerAutoloaderInit4a8167255d24e2d319fa9c0d2dfb312f
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit080ef22abaeaf79a5fc0600bde4b5ee7
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit080ef22abaeaf79a5fc0600bde4b5ee7', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit4a8167255d24e2d319fa9c0d2dfb312f', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit080ef22abaeaf79a5fc0600bde4b5ee7', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit4a8167255d24e2d319fa9c0d2dfb312f', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit080ef22abaeaf79a5fc0600bde4b5ee7::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit4a8167255d24e2d319fa9c0d2dfb312f::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit080ef22abaeaf79a5fc0600bde4b5ee7::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit4a8167255d24e2d319fa9c0d2dfb312f::$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 ComposerStaticInit080ef22abaeaf79a5fc0600bde4b5ee7
|
||||
class ComposerStaticInit4a8167255d24e2d319fa9c0d2dfb312f
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3094,9 +3094,9 @@ class ComposerStaticInit080ef22abaeaf79a5fc0600bde4b5ee7
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit080ef22abaeaf79a5fc0600bde4b5ee7::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit080ef22abaeaf79a5fc0600bde4b5ee7::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit080ef22abaeaf79a5fc0600bde4b5ee7::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit4a8167255d24e2d319fa9c0d2dfb312f::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit4a8167255d24e2d319fa9c0d2dfb312f::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit4a8167255d24e2d319fa9c0d2dfb312f::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user