From 89c1a25d91fa65d9098b41b02931a8427dfd96eb Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 17 Jun 2023 10:37:31 +0000 Subject: [PATCH] Updated Rector to commit aebf30995293f3ba2cb6bb2d10e3084f7e925a11 https://github.com/rectorphp/rector-src/commit/aebf30995293f3ba2cb6bb2d10e3084f7e925a11 [StaticTypeMapper] Remove parent lookup on NameScopeFactory (#4252) --- .../Naming/NameScopeFactory.php | 28 +++++++++++++------ src/Application/VersionResolver.php | 4 +-- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 10 +++---- vendor/composer/autoload_static.php | 8 +++--- 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/packages/StaticTypeMapper/Naming/NameScopeFactory.php b/packages/StaticTypeMapper/Naming/NameScopeFactory.php index 4f5a5f994e5..a04aab01218 100644 --- a/packages/StaticTypeMapper/Naming/NameScopeFactory.php +++ b/packages/StaticTypeMapper/Naming/NameScopeFactory.php @@ -14,7 +14,9 @@ use PHPStan\Reflection\ClassReflection; use PHPStan\Type\Generic\TemplateTypeMap; use PHPStan\Type\Type; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; +use Rector\Core\PhpParser\ClassLikeAstResolver; use Rector\Core\PhpParser\Node\BetterNodeFinder; +use Rector\Core\Reflection\ReflectionResolver; use Rector\Naming\Naming\UseImportsResolver; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\StaticTypeMapper\StaticTypeMapper; @@ -32,24 +34,29 @@ final class NameScopeFactory * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - /** - * @var \Rector\Core\PhpParser\Node\BetterNodeFinder - */ - private $betterNodeFinder; /** * @var \Rector\Naming\Naming\UseImportsResolver */ private $useImportsResolver; + /** + * @var \Rector\Core\Reflection\ReflectionResolver + */ + private $reflectionResolver; + /** + * @var \Rector\Core\PhpParser\ClassLikeAstResolver + */ + private $classLikeAstResolver; // This is needed to avoid circular references /** * @required */ - public function autowire(PhpDocInfoFactory $phpDocInfoFactory, StaticTypeMapper $staticTypeMapper, BetterNodeFinder $betterNodeFinder, UseImportsResolver $useImportsResolver) : void + public function autowire(PhpDocInfoFactory $phpDocInfoFactory, StaticTypeMapper $staticTypeMapper, BetterNodeFinder $betterNodeFinder, UseImportsResolver $useImportsResolver, ReflectionResolver $reflectionResolver, ClassLikeAstResolver $classLikeAstResolver) : void { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->staticTypeMapper = $staticTypeMapper; - $this->betterNodeFinder = $betterNodeFinder; $this->useImportsResolver = $useImportsResolver; + $this->reflectionResolver = $reflectionResolver; + $this->classLikeAstResolver = $classLikeAstResolver; } public function createNameScopeFromNodeWithoutTemplateTypes(Node $node) : NameScope { @@ -93,10 +100,13 @@ final class NameScopeFactory private function templateTemplateTypeMap(Node $node) : TemplateTypeMap { $nodeTemplateTypes = $this->resolveTemplateTypesFromNode($node); - $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); $classTemplateTypes = []; - if ($classLike instanceof ClassLike) { - $classTemplateTypes = $this->resolveTemplateTypesFromNode($classLike); + $classReflection = $this->reflectionResolver->resolveClassReflection($node); + if ($classReflection instanceof ClassReflection) { + $classLike = $this->classLikeAstResolver->resolveClassFromClassReflection($classReflection); + if ($classLike instanceof ClassLike) { + $classTemplateTypes = $this->resolveTemplateTypesFromNode($classLike); + } } $templateTypes = \array_merge($nodeTemplateTypes, $classTemplateTypes); return new TemplateTypeMap($templateTypes); diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index f1d7f7a23ed..e5db402367d 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 = '3122f5ec7f47d275de30bfbc44f61607dbc9cc64'; + public const PACKAGE_VERSION = 'aebf30995293f3ba2cb6bb2d10e3084f7e925a11'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-06-17 16:33:24'; + public const RELEASE_DATE = '2023-06-17 17:33:17'; /** * @var int */ diff --git a/vendor/autoload.php b/vendor/autoload.php index cd0adc2a68d..fb5b7efadf0 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 ComposerAutoloaderInit4d5ad76e5d632208ecd59f21bdd1a624::getLoader(); +return ComposerAutoloaderInite73eb82043fbea86adc9ecc4b98e94ff::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 5db334ebb5f..458e29dff9d 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit4d5ad76e5d632208ecd59f21bdd1a624 +class ComposerAutoloaderInite73eb82043fbea86adc9ecc4b98e94ff { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInit4d5ad76e5d632208ecd59f21bdd1a624 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit4d5ad76e5d632208ecd59f21bdd1a624', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInite73eb82043fbea86adc9ecc4b98e94ff', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit4d5ad76e5d632208ecd59f21bdd1a624', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInite73eb82043fbea86adc9ecc4b98e94ff', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit4d5ad76e5d632208ecd59f21bdd1a624::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInite73eb82043fbea86adc9ecc4b98e94ff::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInit4d5ad76e5d632208ecd59f21bdd1a624::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInite73eb82043fbea86adc9ecc4b98e94ff::$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 01b90eeaaa6..a67a4b5f00e 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit4d5ad76e5d632208ecd59f21bdd1a624 +class ComposerStaticInite73eb82043fbea86adc9ecc4b98e94ff { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3094,9 +3094,9 @@ class ComposerStaticInit4d5ad76e5d632208ecd59f21bdd1a624 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit4d5ad76e5d632208ecd59f21bdd1a624::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit4d5ad76e5d632208ecd59f21bdd1a624::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit4d5ad76e5d632208ecd59f21bdd1a624::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInite73eb82043fbea86adc9ecc4b98e94ff::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInite73eb82043fbea86adc9ecc4b98e94ff::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInite73eb82043fbea86adc9ecc4b98e94ff::$classMap; }, null, ClassLoader::class); }