Updated Rector to commit f9ee33b4e4

f9ee33b4e4 [DowngradePhp70] Add DowngradeParentTypeDeclarationRector (#755)
This commit is contained in:
Tomas Votruba 2021-08-25 07:01:24 +00:00
parent f6bf813917
commit cf026995d8
7 changed files with 32 additions and 38 deletions

View File

@ -12,7 +12,6 @@ use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Property;
use PHPStan\Type\Generic\TemplateType;
use PHPStan\Type\MixedType;
use PHPStan\Type\Type;
use PHPStan\Type\UnionType;
use Rector\Core\PhpParser\Comparing\NodeComparator;
@ -23,6 +22,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
{
@ -173,31 +173,29 @@ final class PromotedPropertyCandidateResolver
$defaultValueType = $this->nodeTypeResolver->getStaticType($param->default);
$matchedParamType = $this->typeFactory->createMixedPassedOrUnionType([$matchedParamType, $defaultValueType]);
}
if (!$propertyType instanceof \PHPStan\Type\UnionType) {
return \false;
$isAllFullyQualifiedObjectType = \true;
if ($propertyType instanceof \PHPStan\Type\UnionType) {
if ($this->hasGenericTemplateType($propertyType)) {
return \false;
}
$isAllFullyQualifiedObjectType = !$this->hasNonFullyQualifiedObjectType($propertyType);
}
if ($this->typeComparator->areTypesEqual($propertyType, $matchedParamType)) {
return \false;
}
// different types, check not has mixed and not has templated generic types
if (!$this->hasMixedType($propertyType)) {
return \false;
}
return !$this->hasTemplatedGenericType($propertyType);
// different types, not a good to fit
return !$isAllFullyQualifiedObjectType && !$this->typeComparator->areTypesEqual($propertyType, $matchedParamType);
}
private function hasTemplatedGenericType(\PHPStan\Type\UnionType $unionType) : bool
private function hasNonFullyQualifiedObjectType(\PHPStan\Type\UnionType $unionType) : bool
{
foreach ($unionType->getTypes() as $type) {
if ($type instanceof \PHPStan\Type\Generic\TemplateType) {
if (!$type instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) {
return \true;
}
}
return \false;
}
private function hasMixedType(\PHPStan\Type\UnionType $unionType) : bool
private function hasGenericTemplateType(\PHPStan\Type\UnionType $unionType) : bool
{
foreach ($unionType->getTypes() as $type) {
if ($type instanceof \PHPStan\Type\MixedType) {
if ($type instanceof \PHPStan\Type\Generic\TemplateType) {
return \true;
}
}

View File

@ -9,7 +9,6 @@ use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\Interface_;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover;
@ -149,9 +148,6 @@ CODE_SAMPLE
if ($inferedType instanceof \PHPStan\Type\MixedType) {
return;
}
if ($inferedType instanceof \PHPStan\Type\NullType) {
return;
}
if ($this->traitTypeAnalyzer->isTraitType($inferedType)) {
return;
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'aa2221058197470ae92b55574bb35e676a441837';
public const PACKAGE_VERSION = 'f9ee33b4e4699c62c1a96c53ca921e8454e7f12f';
/**
* @var string
*/
public const RELEASE_DATE = '2021-08-25 08:50:15';
public const RELEASE_DATE = '2021-08-25 08:48:25';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20210825\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 ComposerAutoloaderInitb648c50cc1305b3e5db74322f2b6b1a2::getLoader();
return ComposerAutoloaderInit410382a21525a0dad1e6755afee2da89::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitb648c50cc1305b3e5db74322f2b6b1a2
class ComposerAutoloaderInit410382a21525a0dad1e6755afee2da89
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInitb648c50cc1305b3e5db74322f2b6b1a2
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitb648c50cc1305b3e5db74322f2b6b1a2', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit410382a21525a0dad1e6755afee2da89', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInitb648c50cc1305b3e5db74322f2b6b1a2', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit410382a21525a0dad1e6755afee2da89', '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\ComposerStaticInitb648c50cc1305b3e5db74322f2b6b1a2::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit410382a21525a0dad1e6755afee2da89::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInitb648c50cc1305b3e5db74322f2b6b1a2
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitb648c50cc1305b3e5db74322f2b6b1a2::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit410382a21525a0dad1e6755afee2da89::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireb648c50cc1305b3e5db74322f2b6b1a2($fileIdentifier, $file);
composerRequire410382a21525a0dad1e6755afee2da89($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequireb648c50cc1305b3e5db74322f2b6b1a2($fileIdentifier, $file)
function composerRequire410382a21525a0dad1e6755afee2da89($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitb648c50cc1305b3e5db74322f2b6b1a2
class ComposerStaticInit410382a21525a0dad1e6755afee2da89
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3856,9 +3856,9 @@ class ComposerStaticInitb648c50cc1305b3e5db74322f2b6b1a2
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitb648c50cc1305b3e5db74322f2b6b1a2::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitb648c50cc1305b3e5db74322f2b6b1a2::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitb648c50cc1305b3e5db74322f2b6b1a2::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit410382a21525a0dad1e6755afee2da89::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit410382a21525a0dad1e6755afee2da89::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit410382a21525a0dad1e6755afee2da89::$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('RectorPrefix20210825\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitb648c50cc1305b3e5db74322f2b6b1a2', false) && !interface_exists('ComposerAutoloaderInitb648c50cc1305b3e5db74322f2b6b1a2', false) && !trait_exists('ComposerAutoloaderInitb648c50cc1305b3e5db74322f2b6b1a2', false)) {
spl_autoload_call('RectorPrefix20210825\ComposerAutoloaderInitb648c50cc1305b3e5db74322f2b6b1a2');
if (!class_exists('ComposerAutoloaderInit410382a21525a0dad1e6755afee2da89', false) && !interface_exists('ComposerAutoloaderInit410382a21525a0dad1e6755afee2da89', false) && !trait_exists('ComposerAutoloaderInit410382a21525a0dad1e6755afee2da89', false)) {
spl_autoload_call('RectorPrefix20210825\ComposerAutoloaderInit410382a21525a0dad1e6755afee2da89');
}
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('RectorPrefix20210825\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210825\print_node(...func_get_args());
}
}
if (!function_exists('composerRequireb648c50cc1305b3e5db74322f2b6b1a2')) {
function composerRequireb648c50cc1305b3e5db74322f2b6b1a2() {
return \RectorPrefix20210825\composerRequireb648c50cc1305b3e5db74322f2b6b1a2(...func_get_args());
if (!function_exists('composerRequire410382a21525a0dad1e6755afee2da89')) {
function composerRequire410382a21525a0dad1e6755afee2da89() {
return \RectorPrefix20210825\composerRequire410382a21525a0dad1e6755afee2da89(...func_get_args());
}
}
if (!function_exists('parseArgs')) {