Updated Rector to commit 8585ff77542ad3ff7cd55226e23378ee866865aa

8585ff7754 [NodeTypeResolver] Remove parent lookup on ArrayTypeAnalyzer (#4261)
This commit is contained in:
Tomas Votruba 2023-06-17 19:21:37 +00:00
parent 084bcaaa18
commit ab1ff8301f
5 changed files with 29 additions and 24 deletions

View File

@ -10,6 +10,7 @@ use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\Property;
use PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\Php\PhpPropertyReflection;
use PHPStan\Type\Accessory\HasOffsetType;
use PHPStan\Type\Accessory\NonEmptyArrayType;
@ -20,7 +21,7 @@ use PHPStan\Type\MixedType;
use PHPStan\Type\Type;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\PhpParser\ClassLikeAstResolver;
use Rector\Core\Reflection\ReflectionResolver;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\NodeTypeResolver;
@ -36,11 +37,6 @@ final class ArrayTypeAnalyzer
* @var \Rector\NodeTypeResolver\NodeTypeResolver
*/
private $nodeTypeResolver;
/**
* @readonly
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
*/
private $betterNodeFinder;
/**
* @readonly
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
@ -51,13 +47,18 @@ final class ArrayTypeAnalyzer
* @var \Rector\Core\Reflection\ReflectionResolver
*/
private $reflectionResolver;
public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, BetterNodeFinder $betterNodeFinder, PhpDocInfoFactory $phpDocInfoFactory, ReflectionResolver $reflectionResolver)
/**
* @readonly
* @var \Rector\Core\PhpParser\ClassLikeAstResolver
*/
private $classLikeAstResolver;
public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, PhpDocInfoFactory $phpDocInfoFactory, ReflectionResolver $reflectionResolver, ClassLikeAstResolver $classLikeAstResolver)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->nodeTypeResolver = $nodeTypeResolver;
$this->betterNodeFinder = $betterNodeFinder;
$this->phpDocInfoFactory = $phpDocInfoFactory;
$this->reflectionResolver = $reflectionResolver;
$this->classLikeAstResolver = $classLikeAstResolver;
}
public function isArrayType(Expr $expr) : bool
{
@ -108,14 +109,16 @@ final class ArrayTypeAnalyzer
if (!$expr instanceof PropertyFetch && !$expr instanceof StaticPropertyFetch) {
return \false;
}
$classLike = $this->betterNodeFinder->findParentType($expr, ClassLike::class);
if (!$classLike instanceof ClassLike) {
$classReflection = $this->reflectionResolver->resolveClassReflection($expr);
if (!$classReflection instanceof ClassReflection) {
return \false;
}
$propertyName = $this->nodeNameResolver->getName($expr->name);
if ($propertyName === null) {
return \false;
}
/** @var ClassLike $classLike */
$classLike = $this->classLikeAstResolver->resolveClassFromClassReflection($classReflection);
$property = $classLike->getProperty($propertyName);
if (!$property instanceof Property) {
return \false;
@ -139,10 +142,12 @@ final class ArrayTypeAnalyzer
if (!$expr instanceof PropertyFetch && !$expr instanceof StaticPropertyFetch) {
return \false;
}
$classLike = $this->betterNodeFinder->findParentType($expr, ClassLike::class);
if (!$classLike instanceof ClassLike) {
$classReflection = $this->reflectionResolver->resolveClassReflection($expr);
if (!$classReflection instanceof ClassReflection) {
return \false;
}
/** @var ClassLike $classLike */
$classLike = $this->classLikeAstResolver->resolveClassFromClassReflection($classReflection);
$propertyName = $this->nodeNameResolver->getName($expr->name);
if ($propertyName === null) {
return \false;

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'ad65e0445c0a68393d7031067f095ea9f8b1cbde';
public const PACKAGE_VERSION = '8585ff77542ad3ff7cd55226e23378ee866865aa';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-06-18 01:20:01';
public const RELEASE_DATE = '2023-06-18 02:16:03';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitacb289715da70e548cc7249242948952::getLoader();
return ComposerAutoloaderInit45ad86eb8329557aaaa52a427f6e2496::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitacb289715da70e548cc7249242948952
class ComposerAutoloaderInit45ad86eb8329557aaaa52a427f6e2496
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInitacb289715da70e548cc7249242948952
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitacb289715da70e548cc7249242948952', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit45ad86eb8329557aaaa52a427f6e2496', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitacb289715da70e548cc7249242948952', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit45ad86eb8329557aaaa52a427f6e2496', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitacb289715da70e548cc7249242948952::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit45ad86eb8329557aaaa52a427f6e2496::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitacb289715da70e548cc7249242948952::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit45ad86eb8329557aaaa52a427f6e2496::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitacb289715da70e548cc7249242948952
class ComposerStaticInit45ad86eb8329557aaaa52a427f6e2496
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3094,9 +3094,9 @@ class ComposerStaticInitacb289715da70e548cc7249242948952
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitacb289715da70e548cc7249242948952::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitacb289715da70e548cc7249242948952::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitacb289715da70e548cc7249242948952::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit45ad86eb8329557aaaa52a427f6e2496::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit45ad86eb8329557aaaa52a427f6e2496::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit45ad86eb8329557aaaa52a427f6e2496::$classMap;
}, null, ClassLoader::class);
}