diff --git a/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/AllAssignNodePropertyTypeInferer.php b/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/AllAssignNodePropertyTypeInferer.php index 9ee12296e83..3ebe57c8b82 100644 --- a/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/AllAssignNodePropertyTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/AllAssignNodePropertyTypeInferer.php @@ -5,8 +5,10 @@ namespace Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer; use PhpParser\Node\Stmt\ClassLike; use PhpParser\Node\Stmt\Property; +use PHPStan\Reflection\ClassReflection; use PHPStan\Type\Type; -use Rector\Core\PhpParser\Node\BetterNodeFinder; +use Rector\Core\PhpParser\ClassLikeAstResolver; +use Rector\Core\Reflection\ReflectionResolver; use Rector\NodeNameResolver\NodeNameResolver; use Rector\TypeDeclaration\TypeInferer\AssignToPropertyTypeInferer; final class AllAssignNodePropertyTypeInferer @@ -23,21 +25,29 @@ final class AllAssignNodePropertyTypeInferer private $nodeNameResolver; /** * @readonly - * @var \Rector\Core\PhpParser\Node\BetterNodeFinder + * @var \Rector\Core\Reflection\ReflectionResolver */ - private $betterNodeFinder; - public function __construct(AssignToPropertyTypeInferer $assignToPropertyTypeInferer, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder) + private $reflectionResolver; + /** + * @readonly + * @var \Rector\Core\PhpParser\ClassLikeAstResolver + */ + private $classLikeAstResolver; + public function __construct(AssignToPropertyTypeInferer $assignToPropertyTypeInferer, NodeNameResolver $nodeNameResolver, ReflectionResolver $reflectionResolver, ClassLikeAstResolver $classLikeAstResolver) { $this->assignToPropertyTypeInferer = $assignToPropertyTypeInferer; $this->nodeNameResolver = $nodeNameResolver; - $this->betterNodeFinder = $betterNodeFinder; + $this->reflectionResolver = $reflectionResolver; + $this->classLikeAstResolver = $classLikeAstResolver; } public function inferProperty(Property $property) : ?Type { - $classLike = $this->betterNodeFinder->findParentType($property, ClassLike::class); - if (!$classLike instanceof ClassLike) { + $classReflection = $this->reflectionResolver->resolveClassReflection($property); + if (!$classReflection instanceof ClassReflection) { return null; } + /** @var ClassLike $classLike */ + $classLike = $this->classLikeAstResolver->resolveClassFromClassReflection($classReflection); $propertyName = $this->nodeNameResolver->getName($property); return $this->assignToPropertyTypeInferer->inferPropertyInClassLike($property, $propertyName, $classLike); } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index b80ff650366..dea48556cd0 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 = '5f976fa8c3eccf209e17e16d36fb6eb68c782ab4'; + public const PACKAGE_VERSION = 'd036eeb6e6a09eed0286272da58299a90c818675'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-06-18 03:12:56'; + public const RELEASE_DATE = '2023-06-17 20:32:26'; /** * @var int */ diff --git a/vendor/autoload.php b/vendor/autoload.php index 9c65c512f10..b83e1a39dcf 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 ComposerAutoloaderInit4a8167255d24e2d319fa9c0d2dfb312f::getLoader(); +return ComposerAutoloaderInit7e306566bd44a4f4eeebccf7abf1230a::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index eb8eebf1244..e14db261130 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit4a8167255d24e2d319fa9c0d2dfb312f +class ComposerAutoloaderInit7e306566bd44a4f4eeebccf7abf1230a { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInit4a8167255d24e2d319fa9c0d2dfb312f return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit4a8167255d24e2d319fa9c0d2dfb312f', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit7e306566bd44a4f4eeebccf7abf1230a', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit4a8167255d24e2d319fa9c0d2dfb312f', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit7e306566bd44a4f4eeebccf7abf1230a', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit4a8167255d24e2d319fa9c0d2dfb312f::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit7e306566bd44a4f4eeebccf7abf1230a::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInit4a8167255d24e2d319fa9c0d2dfb312f::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit7e306566bd44a4f4eeebccf7abf1230a::$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 0cd55163fc5..a7e6d672e3c 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit4a8167255d24e2d319fa9c0d2dfb312f +class ComposerStaticInit7e306566bd44a4f4eeebccf7abf1230a { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3094,9 +3094,9 @@ class ComposerStaticInit4a8167255d24e2d319fa9c0d2dfb312f public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit4a8167255d24e2d319fa9c0d2dfb312f::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit4a8167255d24e2d319fa9c0d2dfb312f::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit4a8167255d24e2d319fa9c0d2dfb312f::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit7e306566bd44a4f4eeebccf7abf1230a::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit7e306566bd44a4f4eeebccf7abf1230a::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit7e306566bd44a4f4eeebccf7abf1230a::$classMap; }, null, ClassLoader::class); }