Updated Rector to commit bf80d3275ecd256b71a25a910f5fdd70770feab9

bf80d3275e [Php74] Skip ObjectProphecy type on TypedPropertyRector (#1358)
This commit is contained in:
Tomas Votruba 2021-12-01 09:10:34 +00:00
parent 0988a578ae
commit 1c7b228d5a
8 changed files with 55 additions and 23 deletions

View File

@ -26,11 +26,11 @@ use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover;
use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Php74\TypeAnalyzer\ObjectTypeAnalyzer;
use Rector\Php74\TypeAnalyzer\PropertyUnionTypeResolver;
use Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer;
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType;
use Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType;
use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer;
use Rector\VendorLocker\VendorLockResolver;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
@ -106,7 +106,11 @@ final class TypedPropertyRector extends \Rector\Core\Rector\AbstractRector imple
* @var \Rector\Core\PhpParser\AstResolver
*/
private $astResolver;
public function __construct(\Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer $propertyTypeInferer, \Rector\VendorLocker\VendorLockResolver $vendorLockResolver, \Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer $doctrineTypeAnalyzer, \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer, \Rector\Core\NodeAnalyzer\PropertyAnalyzer $propertyAnalyzer, \Rector\Php74\TypeAnalyzer\PropertyUnionTypeResolver $propertyUnionTypeResolver, \Rector\Core\PhpParser\AstResolver $astResolver)
/**
* @var \Rector\Php74\TypeAnalyzer\ObjectTypeAnalyzer
*/
private $objectTypeAnalyzer;
public function __construct(\Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer $propertyTypeInferer, \Rector\VendorLocker\VendorLockResolver $vendorLockResolver, \Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer $doctrineTypeAnalyzer, \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer, \Rector\Core\NodeAnalyzer\PropertyAnalyzer $propertyAnalyzer, \Rector\Php74\TypeAnalyzer\PropertyUnionTypeResolver $propertyUnionTypeResolver, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\Php74\TypeAnalyzer\ObjectTypeAnalyzer $objectTypeAnalyzer)
{
$this->propertyTypeInferer = $propertyTypeInferer;
$this->vendorLockResolver = $vendorLockResolver;
@ -118,6 +122,7 @@ final class TypedPropertyRector extends \Rector\Core\Rector\AbstractRector imple
$this->propertyAnalyzer = $propertyAnalyzer;
$this->propertyUnionTypeResolver = $propertyUnionTypeResolver;
$this->astResolver = $astResolver;
$this->objectTypeAnalyzer = $objectTypeAnalyzer;
}
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
@ -165,8 +170,7 @@ CODE_SAMPLE
return $node;
}
}
// we are not sure what object type this is
if ($varType instanceof \Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType) {
if ($this->objectTypeAnalyzer->isSpecial($varType)) {
return null;
}
$propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());

View File

@ -0,0 +1,26 @@
<?php
declare (strict_types=1);
namespace Rector\Php74\TypeAnalyzer;
use PHPStan\Type\Type;
use PHPStan\Type\UnionType;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType;
final class ObjectTypeAnalyzer
{
public function isSpecial(\PHPStan\Type\Type $varType) : bool
{
// we are not sure what object type this is
if ($varType instanceof \Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType) {
return \true;
}
$types = !$varType instanceof \PHPStan\Type\UnionType ? [$varType] : $varType->getTypes();
foreach ($types as $type) {
if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType && $type->getClassName() === 'Prophecy\\Prophecy\\ObjectProphecy') {
return \true;
}
}
return \false;
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '9e81001c68167a6a6187f2ea6520a62c9574926d';
public const PACKAGE_VERSION = 'bf80d3275ecd256b71a25a910f5fdd70770feab9';
/**
* @var string
*/
public const RELEASE_DATE = '2021-12-01 09:52:15';
public const RELEASE_DATE = '2021-12-01 09:54:01';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211201\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 ComposerAutoloaderInit339fd23614cf7069735be55116fb550d::getLoader();
return ComposerAutoloaderInitee6ea53d7cfb21fda71adb5bce83fcd0::getLoader();

View File

@ -2593,6 +2593,7 @@ return array(
'Rector\\Php74\\Rector\\Property\\TypedPropertyRector' => $baseDir . '/rules/Php74/Rector/Property/TypedPropertyRector.php',
'Rector\\Php74\\Rector\\StaticCall\\ExportToReflectionFunctionRector' => $baseDir . '/rules/Php74/Rector/StaticCall/ExportToReflectionFunctionRector.php',
'Rector\\Php74\\Tokenizer\\FollowedByCurlyBracketAnalyzer' => $baseDir . '/rules/Php74/Tokenizer/FollowedByCurlyBracketAnalyzer.php',
'Rector\\Php74\\TypeAnalyzer\\ObjectTypeAnalyzer' => $baseDir . '/rules/Php74/TypeAnalyzer/ObjectTypeAnalyzer.php',
'Rector\\Php74\\TypeAnalyzer\\PropertyUnionTypeResolver' => $baseDir . '/rules/Php74/TypeAnalyzer/PropertyUnionTypeResolver.php',
'Rector\\Php80\\Contract\\StrStartWithMatchAndRefactorInterface' => $baseDir . '/rules/Php80/Contract/StrStartWithMatchAndRefactorInterface.php',
'Rector\\Php80\\Enum\\MatchKind' => $baseDir . '/rules/Php80/Enum/MatchKind.php',

View File

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

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit339fd23614cf7069735be55116fb550d
class ComposerStaticInitee6ea53d7cfb21fda71adb5bce83fcd0
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -2990,6 +2990,7 @@ class ComposerStaticInit339fd23614cf7069735be55116fb550d
'Rector\\Php74\\Rector\\Property\\TypedPropertyRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/Property/TypedPropertyRector.php',
'Rector\\Php74\\Rector\\StaticCall\\ExportToReflectionFunctionRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/StaticCall/ExportToReflectionFunctionRector.php',
'Rector\\Php74\\Tokenizer\\FollowedByCurlyBracketAnalyzer' => __DIR__ . '/../..' . '/rules/Php74/Tokenizer/FollowedByCurlyBracketAnalyzer.php',
'Rector\\Php74\\TypeAnalyzer\\ObjectTypeAnalyzer' => __DIR__ . '/../..' . '/rules/Php74/TypeAnalyzer/ObjectTypeAnalyzer.php',
'Rector\\Php74\\TypeAnalyzer\\PropertyUnionTypeResolver' => __DIR__ . '/../..' . '/rules/Php74/TypeAnalyzer/PropertyUnionTypeResolver.php',
'Rector\\Php80\\Contract\\StrStartWithMatchAndRefactorInterface' => __DIR__ . '/../..' . '/rules/Php80/Contract/StrStartWithMatchAndRefactorInterface.php',
'Rector\\Php80\\Enum\\MatchKind' => __DIR__ . '/../..' . '/rules/Php80/Enum/MatchKind.php',
@ -3791,9 +3792,9 @@ class ComposerStaticInit339fd23614cf7069735be55116fb550d
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit339fd23614cf7069735be55116fb550d::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit339fd23614cf7069735be55116fb550d::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit339fd23614cf7069735be55116fb550d::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitee6ea53d7cfb21fda71adb5bce83fcd0::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitee6ea53d7cfb21fda71adb5bce83fcd0::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitee6ea53d7cfb21fda71adb5bce83fcd0::$classMap;
}, null, ClassLoader::class);
}

View File

@ -12,8 +12,8 @@ if (!class_exists('GenerateChangelogCommand', false) && !interface_exists('Gener
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20211201\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit339fd23614cf7069735be55116fb550d', false) && !interface_exists('ComposerAutoloaderInit339fd23614cf7069735be55116fb550d', false) && !trait_exists('ComposerAutoloaderInit339fd23614cf7069735be55116fb550d', false)) {
spl_autoload_call('RectorPrefix20211201\ComposerAutoloaderInit339fd23614cf7069735be55116fb550d');
if (!class_exists('ComposerAutoloaderInitee6ea53d7cfb21fda71adb5bce83fcd0', false) && !interface_exists('ComposerAutoloaderInitee6ea53d7cfb21fda71adb5bce83fcd0', false) && !trait_exists('ComposerAutoloaderInitee6ea53d7cfb21fda71adb5bce83fcd0', false)) {
spl_autoload_call('RectorPrefix20211201\ComposerAutoloaderInitee6ea53d7cfb21fda71adb5bce83fcd0');
}
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('RectorPrefix20211201\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -81,9 +81,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20211201\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire339fd23614cf7069735be55116fb550d')) {
function composerRequire339fd23614cf7069735be55116fb550d() {
return \RectorPrefix20211201\composerRequire339fd23614cf7069735be55116fb550d(...func_get_args());
if (!function_exists('composerRequireee6ea53d7cfb21fda71adb5bce83fcd0')) {
function composerRequireee6ea53d7cfb21fda71adb5bce83fcd0() {
return \RectorPrefix20211201\composerRequireee6ea53d7cfb21fda71adb5bce83fcd0(...func_get_args());
}
}
if (!function_exists('scanPath')) {