diff --git a/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index bad79c590f9..3e9a9f0a875 100644 --- a/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -17,7 +17,9 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\Ternary; use PhpParser\Node\Expr\Variable; use PhpParser\Node\Identifier; +use PhpParser\Node\IntersectionType; use PhpParser\Node\Name; +use PhpParser\Node\NullableType; use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassLike; @@ -33,6 +35,7 @@ use PhpParser\Node\Stmt\Return_; use PhpParser\Node\Stmt\Switch_; use PhpParser\Node\Stmt\Trait_; use PhpParser\Node\Stmt\TryCatch; +use PhpParser\Node\UnionType; use PhpParser\NodeTraverser; use PHPStan\AnalysedCodeException; use PHPStan\Analyser\MutatingScope; @@ -202,6 +205,14 @@ final class PHPStanNodeScopeResolver if ($node instanceof FuncCall && $node->name instanceof Expr) { $node->name->setAttribute(AttributeKey::SCOPE, $mutatingScope); } + if ($node instanceof NullableType) { + $node->type->setAttribute(AttributeKey::SCOPE, $mutatingScope); + } + if ($node instanceof UnionType || $node instanceof IntersectionType) { + foreach ($node->types as $type) { + $type->setAttribute(AttributeKey::SCOPE, $mutatingScope); + } + } if ($node instanceof Trait_) { $traitName = $this->resolveClassName($node); $traitClassReflection = $this->reflectionProvider->getClass($traitName); diff --git a/packages/StaticTypeMapper/PhpParser/NameNodeMapper.php b/packages/StaticTypeMapper/PhpParser/NameNodeMapper.php index 6f923333dc0..76b8e000f84 100644 --- a/packages/StaticTypeMapper/PhpParser/NameNodeMapper.php +++ b/packages/StaticTypeMapper/PhpParser/NameNodeMapper.php @@ -5,7 +5,6 @@ namespace Rector\StaticTypeMapper\PhpParser; use PhpParser\Node; use PhpParser\Node\Name; -use PhpParser\Node\Stmt\ClassLike; use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\ReflectionProvider; use PHPStan\Type\ArrayType; @@ -21,8 +20,7 @@ use PHPStan\Type\ThisType; use PHPStan\Type\Type; use Rector\Core\Configuration\RenamedClassesDataCollector; use Rector\Core\Enum\ObjectReference; -use Rector\Core\PhpParser\Node\BetterNodeFinder; -use Rector\NodeNameResolver\NodeNameResolver; +use Rector\Core\Reflection\ReflectionResolver; use Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\ParentObjectWithoutClassType; @@ -45,20 +43,14 @@ final class NameNodeMapper implements PhpParserNodeMapperInterface private $reflectionProvider; /** * @readonly - * @var \Rector\Core\PhpParser\Node\BetterNodeFinder + * @var \Rector\Core\Reflection\ReflectionResolver */ - private $betterNodeFinder; - /** - * @readonly - * @var \Rector\NodeNameResolver\NodeNameResolver - */ - private $nodeNameResolver; - public function __construct(RenamedClassesDataCollector $renamedClassesDataCollector, ReflectionProvider $reflectionProvider, BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver) + private $reflectionResolver; + public function __construct(RenamedClassesDataCollector $renamedClassesDataCollector, ReflectionProvider $reflectionProvider, ReflectionResolver $reflectionResolver) { $this->renamedClassesDataCollector = $renamedClassesDataCollector; $this->reflectionProvider = $reflectionProvider; - $this->betterNodeFinder = $betterNodeFinder; - $this->nodeNameResolver = $nodeNameResolver; + $this->reflectionResolver = $reflectionResolver; } public function getNodeType() : string { @@ -92,12 +84,10 @@ final class NameNodeMapper implements PhpParserNodeMapperInterface */ private function createClassReferenceType(Name $name, string $reference) { - $classLike = $this->betterNodeFinder->findParentType($name, ClassLike::class); - if (!$classLike instanceof ClassLike) { + $classReflection = $this->reflectionResolver->resolveClassReflection($name); + if (!$classReflection instanceof ClassReflection) { return new MixedType(); } - $className = (string) $this->nodeNameResolver->getName($classLike); - $classReflection = $this->reflectionProvider->getClass($className); if ($reference === ObjectReference::STATIC) { return new StaticType($classReflection); } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 81ec8054a72..925a02bb42b 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 = '7b5102670f0a290038229f8e3bb690e2336920b9'; + public const PACKAGE_VERSION = '8263d9097dd362abd5f9f3ffa6aa560b2abffa8d'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-06-17 07:15:58'; + public const RELEASE_DATE = '2023-06-17 11:50:29'; /** * @var int */ diff --git a/vendor/autoload.php b/vendor/autoload.php index c3fa25fb309..74e28e5c5d1 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 ComposerAutoloaderInitd34ecc3fb274e960cc0c65cf7508c84a::getLoader(); +return ComposerAutoloaderInitf2ece9244f054090d0f0593eeeec3f90::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 9b36c6091c1..3dd4507c894 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitd34ecc3fb274e960cc0c65cf7508c84a +class ComposerAutoloaderInitf2ece9244f054090d0f0593eeeec3f90 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInitd34ecc3fb274e960cc0c65cf7508c84a return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitd34ecc3fb274e960cc0c65cf7508c84a', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitf2ece9244f054090d0f0593eeeec3f90', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitd34ecc3fb274e960cc0c65cf7508c84a', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitf2ece9244f054090d0f0593eeeec3f90', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitd34ecc3fb274e960cc0c65cf7508c84a::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitf2ece9244f054090d0f0593eeeec3f90::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInitd34ecc3fb274e960cc0c65cf7508c84a::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInitf2ece9244f054090d0f0593eeeec3f90::$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 ee8c5c216da..a0eafa2741e 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitd34ecc3fb274e960cc0c65cf7508c84a +class ComposerStaticInitf2ece9244f054090d0f0593eeeec3f90 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3094,9 +3094,9 @@ class ComposerStaticInitd34ecc3fb274e960cc0c65cf7508c84a public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitd34ecc3fb274e960cc0c65cf7508c84a::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitd34ecc3fb274e960cc0c65cf7508c84a::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitd34ecc3fb274e960cc0c65cf7508c84a::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitf2ece9244f054090d0f0593eeeec3f90::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitf2ece9244f054090d0f0593eeeec3f90::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitf2ece9244f054090d0f0593eeeec3f90::$classMap; }, null, ClassLoader::class); }