mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-04 02:10:51 +00:00
Updated Rector to commit 2cca234e54b88d14b9017ec343b3a9804d90a348
2cca234e54
Remove PropertyFetchTypeAnalyzer and it's usages (#3410)
This commit is contained in:
parent
1b65d11365
commit
949980905b
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\TypeDeclaration\TypeAnalyzer;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\Php\PhpPropertyReflection;
|
||||
use PHPStan\Reflection\PropertyReflection;
|
||||
use PHPStan\Reflection\WrapperPropertyReflection;
|
||||
use PHPStan\Type\MixedType;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
final class PropertyFetchTypeAnalyzer
|
||||
{
|
||||
public function isPropertyFetchExprNotNativelyTyped(Expr $expr) : bool
|
||||
{
|
||||
if (!$expr instanceof PropertyFetch) {
|
||||
return \false;
|
||||
}
|
||||
if (!$expr->name instanceof Identifier) {
|
||||
return \false;
|
||||
}
|
||||
$scope = $expr->getAttribute(AttributeKey::SCOPE);
|
||||
if (!$scope instanceof Scope) {
|
||||
return \false;
|
||||
}
|
||||
$propertyName = $expr->name->toString();
|
||||
$propertyHolderType = $scope->getType($expr->var);
|
||||
if (!$propertyHolderType->hasProperty($propertyName)->yes()) {
|
||||
return \false;
|
||||
}
|
||||
$propertyReflection = $propertyHolderType->getProperty($propertyName, $scope);
|
||||
$phpPropertyReflection = $this->getNativeReflectionForProperty($propertyReflection);
|
||||
if (!$phpPropertyReflection instanceof PhpPropertyReflection) {
|
||||
return \false;
|
||||
}
|
||||
return $phpPropertyReflection->getNativeType() instanceof MixedType;
|
||||
}
|
||||
private function getNativeReflectionForProperty(PropertyReflection $propertyReflection) : ?PhpPropertyReflection
|
||||
{
|
||||
$reflection = $propertyReflection;
|
||||
while ($reflection instanceof WrapperPropertyReflection) {
|
||||
$reflection = $reflection->getOriginalReflection();
|
||||
}
|
||||
if (!$reflection instanceof PhpPropertyReflection) {
|
||||
return null;
|
||||
}
|
||||
return $reflection;
|
||||
}
|
||||
}
|
|
@ -27,7 +27,6 @@ use Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector;
|
|||
use Rector\TypeDeclaration\AlreadyAssignDetector\NullTypeAssignDetector;
|
||||
use Rector\TypeDeclaration\AlreadyAssignDetector\PropertyDefaultAssignDetector;
|
||||
use Rector\TypeDeclaration\Matcher\PropertyAssignMatcher;
|
||||
use Rector\TypeDeclaration\TypeAnalyzer\PropertyFetchTypeAnalyzer;
|
||||
/**
|
||||
* @deprecated
|
||||
* @todo Split into many narrow-focused rules
|
||||
|
@ -84,12 +83,7 @@ final class AssignToPropertyTypeInferer
|
|||
* @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer
|
||||
*/
|
||||
private $propertyFetchAnalyzer;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\TypeAnalyzer\PropertyFetchTypeAnalyzer
|
||||
*/
|
||||
private $propertyFetchTypeAnalyzer;
|
||||
public function __construct(ConstructorAssignDetector $constructorAssignDetector, PropertyAssignMatcher $propertyAssignMatcher, PropertyDefaultAssignDetector $propertyDefaultAssignDetector, NullTypeAssignDetector $nullTypeAssignDetector, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, TypeFactory $typeFactory, NodeTypeResolver $nodeTypeResolver, ExprAnalyzer $exprAnalyzer, ValueResolver $valueResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer, PropertyFetchTypeAnalyzer $propertyFetchTypeAnalyzer)
|
||||
public function __construct(ConstructorAssignDetector $constructorAssignDetector, PropertyAssignMatcher $propertyAssignMatcher, PropertyDefaultAssignDetector $propertyDefaultAssignDetector, NullTypeAssignDetector $nullTypeAssignDetector, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, TypeFactory $typeFactory, NodeTypeResolver $nodeTypeResolver, ExprAnalyzer $exprAnalyzer, ValueResolver $valueResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer)
|
||||
{
|
||||
$this->constructorAssignDetector = $constructorAssignDetector;
|
||||
$this->propertyAssignMatcher = $propertyAssignMatcher;
|
||||
|
@ -101,7 +95,6 @@ final class AssignToPropertyTypeInferer
|
|||
$this->exprAnalyzer = $exprAnalyzer;
|
||||
$this->valueResolver = $valueResolver;
|
||||
$this->propertyFetchAnalyzer = $propertyFetchAnalyzer;
|
||||
$this->propertyFetchTypeAnalyzer = $propertyFetchTypeAnalyzer;
|
||||
}
|
||||
public function inferPropertyInClassLike(Property $property, string $propertyName, ClassLike $classLike) : ?Type
|
||||
{
|
||||
|
@ -215,9 +208,6 @@ final class AssignToPropertyTypeInferer
|
|||
if (!$expr instanceof Expr) {
|
||||
return null;
|
||||
}
|
||||
if ($this->propertyFetchAnalyzer->isPropertyFetch($node->expr) && $this->propertyFetchTypeAnalyzer->isPropertyFetchExprNotNativelyTyped($node->expr)) {
|
||||
return null;
|
||||
}
|
||||
if ($this->exprAnalyzer->isNonTypedFromParam($node->expr)) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ use PHPStan\Type\Type;
|
|||
use PHPStan\Type\TypeCombinator;
|
||||
use PHPStan\Type\UnionType;
|
||||
use Rector\Core\NodeAnalyzer\ParamAnalyzer;
|
||||
use Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer;
|
||||
use Rector\Core\NodeManipulator\ClassMethodPropertyFetchManipulator;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
|
@ -34,7 +33,6 @@ use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser;
|
|||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
|
||||
use Rector\TypeDeclaration\TypeAnalyzer\PropertyFetchTypeAnalyzer;
|
||||
use Rector\TypeDeclaration\TypeInferer\AssignToPropertyTypeInferer;
|
||||
/**
|
||||
* @deprecated
|
||||
|
@ -97,17 +95,7 @@ final class TrustedClassMethodPropertyTypeInferer
|
|||
* @var \Rector\NodeTypeResolver\TypeComparator\TypeComparator
|
||||
*/
|
||||
private $typeComparator;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer
|
||||
*/
|
||||
private $propertyFetchAnalyzer;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\TypeAnalyzer\PropertyFetchTypeAnalyzer
|
||||
*/
|
||||
private $propertyFetchTypeAnalyzer;
|
||||
public function __construct(ClassMethodPropertyFetchManipulator $classMethodPropertyFetchManipulator, ReflectionProvider $reflectionProvider, NodeNameResolver $nodeNameResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, TypeFactory $typeFactory, StaticTypeMapper $staticTypeMapper, NodeTypeResolver $nodeTypeResolver, BetterNodeFinder $betterNodeFinder, ParamAnalyzer $paramAnalyzer, AssignToPropertyTypeInferer $assignToPropertyTypeInferer, TypeComparator $typeComparator, PropertyFetchAnalyzer $propertyFetchAnalyzer, PropertyFetchTypeAnalyzer $propertyFetchTypeAnalyzer)
|
||||
public function __construct(ClassMethodPropertyFetchManipulator $classMethodPropertyFetchManipulator, ReflectionProvider $reflectionProvider, NodeNameResolver $nodeNameResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, TypeFactory $typeFactory, StaticTypeMapper $staticTypeMapper, NodeTypeResolver $nodeTypeResolver, BetterNodeFinder $betterNodeFinder, ParamAnalyzer $paramAnalyzer, AssignToPropertyTypeInferer $assignToPropertyTypeInferer, TypeComparator $typeComparator)
|
||||
{
|
||||
$this->classMethodPropertyFetchManipulator = $classMethodPropertyFetchManipulator;
|
||||
$this->reflectionProvider = $reflectionProvider;
|
||||
|
@ -120,8 +108,6 @@ final class TrustedClassMethodPropertyTypeInferer
|
|||
$this->paramAnalyzer = $paramAnalyzer;
|
||||
$this->assignToPropertyTypeInferer = $assignToPropertyTypeInferer;
|
||||
$this->typeComparator = $typeComparator;
|
||||
$this->propertyFetchAnalyzer = $propertyFetchAnalyzer;
|
||||
$this->propertyFetchTypeAnalyzer = $propertyFetchTypeAnalyzer;
|
||||
}
|
||||
public function inferProperty(Property $property, ClassMethod $classMethod) : Type
|
||||
{
|
||||
|
@ -140,9 +126,6 @@ final class TrustedClassMethodPropertyTypeInferer
|
|||
$assignedExprs = $this->classMethodPropertyFetchManipulator->findAssignsToPropertyName($classMethod, $propertyName);
|
||||
$resolvedTypes = [];
|
||||
foreach ($assignedExprs as $assignedExpr) {
|
||||
if ($this->propertyFetchAnalyzer->isPropertyFetch($assignedExpr) && $this->propertyFetchTypeAnalyzer->isPropertyFetchExprNotNativelyTyped($assignedExpr)) {
|
||||
continue;
|
||||
}
|
||||
$resolvedTypes[] = $this->nodeTypeResolver->getType($assignedExpr);
|
||||
}
|
||||
if ($resolvedTypes === []) {
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '9c7da411e7a32b7adca8af2bc9640c3cf0029583';
|
||||
public const PACKAGE_VERSION = '2cca234e54b88d14b9017ec343b3a9804d90a348';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-02-23 14:58:26';
|
||||
public const RELEASE_DATE = '2023-02-24 15:30:52';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit466f8ae2befaae596f962111b327b685::getLoader();
|
||||
return ComposerAutoloaderInit916c90a106fbfd244faef021e7e06d3e::getLoader();
|
||||
|
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
|
@ -2827,7 +2827,6 @@ return array(
|
|||
'Rector\\TypeDeclaration\\TypeAnalyzer\\AlwaysStrictBoolExprAnalyzer' => $baseDir . '/rules/TypeDeclaration/TypeAnalyzer/AlwaysStrictBoolExprAnalyzer.php',
|
||||
'Rector\\TypeDeclaration\\TypeAnalyzer\\AlwaysStrictScalarExprAnalyzer' => $baseDir . '/rules/TypeDeclaration/TypeAnalyzer/AlwaysStrictScalarExprAnalyzer.php',
|
||||
'Rector\\TypeDeclaration\\TypeAnalyzer\\GenericClassStringTypeNormalizer' => $baseDir . '/rules/TypeDeclaration/TypeAnalyzer/GenericClassStringTypeNormalizer.php',
|
||||
'Rector\\TypeDeclaration\\TypeAnalyzer\\PropertyFetchTypeAnalyzer' => $baseDir . '/rules/TypeDeclaration/TypeAnalyzer/PropertyFetchTypeAnalyzer.php',
|
||||
'Rector\\TypeDeclaration\\TypeAnalyzer\\ReturnStrictTypeAnalyzer' => $baseDir . '/rules/TypeDeclaration/TypeAnalyzer/ReturnStrictTypeAnalyzer.php',
|
||||
'Rector\\TypeDeclaration\\TypeAnalyzer\\StrictReturnClassConstReturnTypeAnalyzer' => $baseDir . '/rules/TypeDeclaration/TypeAnalyzer/StrictReturnClassConstReturnTypeAnalyzer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\AssignToPropertyTypeInferer' => $baseDir . '/rules/TypeDeclaration/TypeInferer/AssignToPropertyTypeInferer.php',
|
||||
|
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit466f8ae2befaae596f962111b327b685
|
||||
class ComposerAutoloaderInit916c90a106fbfd244faef021e7e06d3e
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInit466f8ae2befaae596f962111b327b685
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit466f8ae2befaae596f962111b327b685', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit916c90a106fbfd244faef021e7e06d3e', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit466f8ae2befaae596f962111b327b685', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit916c90a106fbfd244faef021e7e06d3e', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit466f8ae2befaae596f962111b327b685::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit916c90a106fbfd244faef021e7e06d3e::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit466f8ae2befaae596f962111b327b685::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit916c90a106fbfd244faef021e7e06d3e::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit466f8ae2befaae596f962111b327b685
|
||||
class ComposerStaticInit916c90a106fbfd244faef021e7e06d3e
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -3074,7 +3074,6 @@ class ComposerStaticInit466f8ae2befaae596f962111b327b685
|
|||
'Rector\\TypeDeclaration\\TypeAnalyzer\\AlwaysStrictBoolExprAnalyzer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeAnalyzer/AlwaysStrictBoolExprAnalyzer.php',
|
||||
'Rector\\TypeDeclaration\\TypeAnalyzer\\AlwaysStrictScalarExprAnalyzer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeAnalyzer/AlwaysStrictScalarExprAnalyzer.php',
|
||||
'Rector\\TypeDeclaration\\TypeAnalyzer\\GenericClassStringTypeNormalizer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeAnalyzer/GenericClassStringTypeNormalizer.php',
|
||||
'Rector\\TypeDeclaration\\TypeAnalyzer\\PropertyFetchTypeAnalyzer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeAnalyzer/PropertyFetchTypeAnalyzer.php',
|
||||
'Rector\\TypeDeclaration\\TypeAnalyzer\\ReturnStrictTypeAnalyzer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeAnalyzer/ReturnStrictTypeAnalyzer.php',
|
||||
'Rector\\TypeDeclaration\\TypeAnalyzer\\StrictReturnClassConstReturnTypeAnalyzer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeAnalyzer/StrictReturnClassConstReturnTypeAnalyzer.php',
|
||||
'Rector\\TypeDeclaration\\TypeInferer\\AssignToPropertyTypeInferer' => __DIR__ . '/../..' . '/rules/TypeDeclaration/TypeInferer/AssignToPropertyTypeInferer.php',
|
||||
|
@ -3126,9 +3125,9 @@ class ComposerStaticInit466f8ae2befaae596f962111b327b685
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit466f8ae2befaae596f962111b327b685::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit466f8ae2befaae596f962111b327b685::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit466f8ae2befaae596f962111b327b685::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit916c90a106fbfd244faef021e7e06d3e::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit916c90a106fbfd244faef021e7e06d3e::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit916c90a106fbfd244faef021e7e06d3e::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user