From e00ac02415657e1e31f547eb81fa2bd7f0a68b11 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 17 Jun 2023 09:37:22 +0000 Subject: [PATCH] Updated Rector to commit 3122f5ec7f47d275de30bfbc44f61607dbc9cc64 https://github.com/rectorphp/rector-src/commit/3122f5ec7f47d275de30bfbc44f61607dbc9cc64 [Php71] Remove parent lookup on CountableAnalyzer (#4251) --- .../Php71/NodeAnalyzer/CountableAnalyzer.php | 34 +++++++++++++------ src/Application/VersionResolver.php | 4 +-- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 10 +++--- vendor/composer/autoload_static.php | 8 ++--- 5 files changed, 35 insertions(+), 23 deletions(-) diff --git a/rules/Php71/NodeAnalyzer/CountableAnalyzer.php b/rules/Php71/NodeAnalyzer/CountableAnalyzer.php index e8e6768ab86..06cf4d1447c 100644 --- a/rules/Php71/NodeAnalyzer/CountableAnalyzer.php +++ b/rules/Php71/NodeAnalyzer/CountableAnalyzer.php @@ -10,6 +10,7 @@ use PhpParser\Node\Expr\StaticPropertyFetch; use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\ClassLike; use PHPStan\Analyser\Scope; +use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\Php\PhpPropertyReflection; use PHPStan\Reflection\ReflectionProvider; use PHPStan\Type\ArrayType; @@ -18,7 +19,8 @@ use PHPStan\Type\Type; use PHPStan\Type\TypeWithClassName; use PHPStan\Type\UnionType; use Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer; -use Rector\Core\PhpParser\Node\BetterNodeFinder; +use Rector\Core\PhpParser\AstResolver; +use Rector\Core\Reflection\ReflectionResolver; use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\NodeTypeResolver; use Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector; @@ -39,11 +41,6 @@ final class CountableAnalyzer * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - /** - * @readonly - * @var \Rector\Core\PhpParser\Node\BetterNodeFinder - */ - private $betterNodeFinder; /** * @readonly * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer @@ -54,14 +51,25 @@ final class CountableAnalyzer * @var \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector */ private $constructorAssignDetector; - public function __construct(NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider, BetterNodeFinder $betterNodeFinder, PropertyFetchAnalyzer $propertyFetchAnalyzer, ConstructorAssignDetector $constructorAssignDetector) + /** + * @readonly + * @var \Rector\Core\Reflection\ReflectionResolver + */ + private $reflectionResolver; + /** + * @readonly + * @var \Rector\Core\PhpParser\AstResolver + */ + private $astResolver; + public function __construct(NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider, PropertyFetchAnalyzer $propertyFetchAnalyzer, ConstructorAssignDetector $constructorAssignDetector, ReflectionResolver $reflectionResolver, AstResolver $astResolver) { $this->nodeTypeResolver = $nodeTypeResolver; $this->nodeNameResolver = $nodeNameResolver; $this->reflectionProvider = $reflectionProvider; - $this->betterNodeFinder = $betterNodeFinder; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; $this->constructorAssignDetector = $constructorAssignDetector; + $this->reflectionResolver = $reflectionResolver; + $this->astResolver = $astResolver; } public function isCastableArrayType(Expr $expr, ArrayType $arrayType, Scope $scope) : bool { @@ -119,11 +127,15 @@ final class CountableAnalyzer if ($nativeType->isIterable()->yes()) { return \true; } - $classLike = $this->betterNodeFinder->findParentType($propertyFetch, ClassLike::class); - if (!$classLike instanceof ClassLike) { + if ($propertyFetch->name instanceof Expr) { return \false; } - if ($propertyFetch->name instanceof Expr) { + $classReflection = $this->reflectionResolver->resolveClassReflection($propertyFetch); + if (!$classReflection instanceof ClassReflection) { + return \false; + } + $classLike = $this->astResolver->resolveClassFromName($classReflection->getName()); + if (!$classLike instanceof ClassLike) { return \false; } $propertyName = (string) $this->nodeNameResolver->getName($propertyFetch->name); diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 2e451889bf0..f1d7f7a23ed 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '628260708ccc40d17e1ef2147774170ac030597f'; + public const PACKAGE_VERSION = '3122f5ec7f47d275de30bfbc44f61607dbc9cc64'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-06-17 14:41:44'; + public const RELEASE_DATE = '2023-06-17 16:33:24'; /** * @var int */ diff --git a/vendor/autoload.php b/vendor/autoload.php index 2ada6a44ac3..cd0adc2a68d 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit6d42e8b0ef15f7135414b7766c2104e1::getLoader(); +return ComposerAutoloaderInit4d5ad76e5d632208ecd59f21bdd1a624::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index a714dadd35b..5db334ebb5f 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit6d42e8b0ef15f7135414b7766c2104e1 +class ComposerAutoloaderInit4d5ad76e5d632208ecd59f21bdd1a624 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInit6d42e8b0ef15f7135414b7766c2104e1 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit6d42e8b0ef15f7135414b7766c2104e1', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit4d5ad76e5d632208ecd59f21bdd1a624', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit6d42e8b0ef15f7135414b7766c2104e1', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit4d5ad76e5d632208ecd59f21bdd1a624', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit6d42e8b0ef15f7135414b7766c2104e1::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit4d5ad76e5d632208ecd59f21bdd1a624::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInit6d42e8b0ef15f7135414b7766c2104e1::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit4d5ad76e5d632208ecd59f21bdd1a624::$files; $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index ce761000e5b..01b90eeaaa6 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit6d42e8b0ef15f7135414b7766c2104e1 +class ComposerStaticInit4d5ad76e5d632208ecd59f21bdd1a624 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3094,9 +3094,9 @@ class ComposerStaticInit6d42e8b0ef15f7135414b7766c2104e1 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit6d42e8b0ef15f7135414b7766c2104e1::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit6d42e8b0ef15f7135414b7766c2104e1::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit6d42e8b0ef15f7135414b7766c2104e1::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit4d5ad76e5d632208ecd59f21bdd1a624::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit4d5ad76e5d632208ecd59f21bdd1a624::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit4d5ad76e5d632208ecd59f21bdd1a624::$classMap; }, null, ClassLoader::class); }