Updated Rector to commit 998029d4fc

998029d4fc [Php80] Handle union collection of FullyQualifieds on ClassPropertyAssignToConstructorPromotionRector (#722)
This commit is contained in:
Tomas Votruba 2021-08-20 10:38:01 +00:00
parent 65ad60c6e9
commit 92566bbfbc
7 changed files with 45 additions and 24 deletions

View File

@ -155,12 +155,10 @@ CODE_SAMPLE
/** @var ClassReflection[] $parentClassReflections */
$parentClassReflections = \array_merge($classReflection->getParents(), $classReflection->getInterfaces());
foreach ($parentClassReflections as $parentClassReflection) {
if (!$parentClassReflection->hasMethod($methodName)) {
$parentReflectionMethod = $this->resolveParentReflectionMethod($parentClassReflection, $methodName);
if (!$parentReflectionMethod instanceof \ReflectionMethod) {
continue;
}
$nativeClassReflection = $parentClassReflection->getNativeReflection();
// Find the param we're looking for
$parentReflectionMethod = $nativeClassReflection->getMethod($methodName);
$differentAncestorParamTypeName = $this->getDifferentParamTypeFromReflectionMethod($parentReflectionMethod, $paramName, $paramTypeName);
if ($differentAncestorParamTypeName !== null) {
return $differentAncestorParamTypeName;
@ -168,6 +166,18 @@ CODE_SAMPLE
}
return null;
}
private function resolveParentReflectionMethod(\PHPStan\Reflection\ClassReflection $classReflection, string $methodName) : ?\ReflectionMethod
{
if (!$classReflection->hasMethod($methodName)) {
return null;
}
$reflectionClass = $classReflection->getNativeReflection();
if (!$reflectionClass->hasMethod($methodName)) {
return null;
}
// Find the param we're looking for
return $reflectionClass->getMethod($methodName);
}
private function getDifferentParamTypeFromReflectionMethod(\ReflectionMethod $reflectionMethod, string $paramName, string $paramTypeName) : ?string
{
/** @var ReflectionParameter[] $parentReflectionMethodParams */

View File

@ -12,6 +12,7 @@ use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Property;
use PHPStan\Type\Type;
use PHPStan\Type\UnionType;
use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\ValueObject\MethodName;
@ -20,6 +21,7 @@ use Rector\NodeTypeResolver\NodeTypeResolver;
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
use Rector\Php80\ValueObject\PropertyPromotionCandidate;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer;
final class PromotedPropertyCandidateResolver
{
@ -170,8 +172,17 @@ final class PromotedPropertyCandidateResolver
$defaultValueType = $this->nodeTypeResolver->getStaticType($param->default);
$matchedParamType = $this->typeFactory->createMixedPassedOrUnionType([$matchedParamType, $defaultValueType]);
}
$isAllFullyQualifiedObjectType = \true;
if ($propertyType instanceof \PHPStan\Type\UnionType) {
foreach ($propertyType->getTypes() as $type) {
if (!$type instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) {
$isAllFullyQualifiedObjectType = \false;
break;
}
}
}
// different types, not a good to fit
return !$this->typeComparator->areTypesEqual($propertyType, $matchedParamType);
return !$isAllFullyQualifiedObjectType && !$this->typeComparator->areTypesEqual($propertyType, $matchedParamType);
}
/**
* @param int[] $firstParamAsVariable

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '2623e6773c8e2f6dccb963caa794e23f56d0b3a3';
public const PACKAGE_VERSION = '998029d4fc3654d5c361c37247b224b052d6d597';
/**
* @var string
*/
public const RELEASE_DATE = '2021-08-20 16:53:29';
public const RELEASE_DATE = '2021-08-20 12:27:01';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20210820\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit1ba193f1cf3413e027eddb35515b2ff1::getLoader();
return ComposerAutoloaderInit35f421af3cb4251cc08ce0d18ab29b18::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit1ba193f1cf3413e027eddb35515b2ff1
class ComposerAutoloaderInit35f421af3cb4251cc08ce0d18ab29b18
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit1ba193f1cf3413e027eddb35515b2ff1
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit1ba193f1cf3413e027eddb35515b2ff1', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit35f421af3cb4251cc08ce0d18ab29b18', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit1ba193f1cf3413e027eddb35515b2ff1', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit35f421af3cb4251cc08ce0d18ab29b18', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit1ba193f1cf3413e027eddb35515b2ff1::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit35f421af3cb4251cc08ce0d18ab29b18::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit1ba193f1cf3413e027eddb35515b2ff1
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit1ba193f1cf3413e027eddb35515b2ff1::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit35f421af3cb4251cc08ce0d18ab29b18::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire1ba193f1cf3413e027eddb35515b2ff1($fileIdentifier, $file);
composerRequire35f421af3cb4251cc08ce0d18ab29b18($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire1ba193f1cf3413e027eddb35515b2ff1($fileIdentifier, $file)
function composerRequire35f421af3cb4251cc08ce0d18ab29b18($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit1ba193f1cf3413e027eddb35515b2ff1
class ComposerStaticInit35f421af3cb4251cc08ce0d18ab29b18
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3851,9 +3851,9 @@ class ComposerStaticInit1ba193f1cf3413e027eddb35515b2ff1
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit1ba193f1cf3413e027eddb35515b2ff1::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit1ba193f1cf3413e027eddb35515b2ff1::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit1ba193f1cf3413e027eddb35515b2ff1::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit35f421af3cb4251cc08ce0d18ab29b18::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit35f421af3cb4251cc08ce0d18ab29b18::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit35f421af3cb4251cc08ce0d18ab29b18::$classMap;
}, null, ClassLoader::class);
}

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20210820\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit1ba193f1cf3413e027eddb35515b2ff1', false) && !interface_exists('ComposerAutoloaderInit1ba193f1cf3413e027eddb35515b2ff1', false) && !trait_exists('ComposerAutoloaderInit1ba193f1cf3413e027eddb35515b2ff1', false)) {
spl_autoload_call('RectorPrefix20210820\ComposerAutoloaderInit1ba193f1cf3413e027eddb35515b2ff1');
if (!class_exists('ComposerAutoloaderInit35f421af3cb4251cc08ce0d18ab29b18', false) && !interface_exists('ComposerAutoloaderInit35f421af3cb4251cc08ce0d18ab29b18', false) && !trait_exists('ComposerAutoloaderInit35f421af3cb4251cc08ce0d18ab29b18', false)) {
spl_autoload_call('RectorPrefix20210820\ComposerAutoloaderInit35f421af3cb4251cc08ce0d18ab29b18');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20210820\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210820\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire1ba193f1cf3413e027eddb35515b2ff1')) {
function composerRequire1ba193f1cf3413e027eddb35515b2ff1() {
return \RectorPrefix20210820\composerRequire1ba193f1cf3413e027eddb35515b2ff1(...func_get_args());
if (!function_exists('composerRequire35f421af3cb4251cc08ce0d18ab29b18')) {
function composerRequire35f421af3cb4251cc08ce0d18ab29b18() {
return \RectorPrefix20210820\composerRequire35f421af3cb4251cc08ce0d18ab29b18(...func_get_args());
}
}
if (!function_exists('parseArgs')) {