Updated Rector to commit b98dc27704c64122750d3bbae3731cb820ae8c11

b98dc27704 [Php80][TypeDeclaration] Handle UnionTypesRector+AddArrayReturnDocTypeRector on auto import FullyQualified doc (#2730)
This commit is contained in:
Tomas Votruba 2022-08-04 12:09:16 +00:00
parent 184a304008
commit 502082ac85
5 changed files with 31 additions and 19 deletions

View File

@ -4,10 +4,11 @@ declare (strict_types=1);
namespace Rector\Privatization\TypeManipulator;
use PhpParser\Node;
use PHPStan\Type\Accessory\NonEmptyArrayType;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Type\ArrayType;
use PHPStan\Type\IntersectionType;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use PHPStan\Type\UnionType;
use Rector\NodeNameResolver\NodeNameResolver;
@ -22,7 +23,10 @@ final class NormalizeTypeToRespectArrayScalarType
{
$this->nodeNameResolver = $nodeNameResolver;
}
public function normalizeToArray(Type $type, ?Node $returnNode) : Type
/**
* @return \PHPStan\Type\ArrayType|\PHPStan\Type\UnionType|\PHPStan\Type\Type
*/
public function normalizeToArray(Type $type, ?Node $returnNode)
{
if ($returnNode === null) {
return $type;
@ -49,11 +53,19 @@ final class NormalizeTypeToRespectArrayScalarType
}
$types = $itemType->getTypes();
foreach ($types as $key => $itemTypeType) {
if ($itemTypeType instanceof NonEmptyArrayType) {
unset($types[$key]);
if ($itemTypeType instanceof ObjectType && $itemTypeType->getClassReflection() instanceof ClassReflection) {
continue;
}
if ($itemTypeType instanceof ArrayType) {
continue;
}
unset($types[$key]);
}
if ($types === []) {
$arrayItemType = new MixedType();
} else {
$arrayItemType = \count($types) === 1 ? \array_pop($types) : new IntersectionType($types);
}
$arrayItemType = \count($types) === 1 ? \array_pop($types) : new IntersectionType($types);
return new ArrayType($arrayType->getKeyType(), $arrayItemType);
}
private function normalizeUnionType(UnionType $unionType) : UnionType

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '61b6e86d17923a29a7dad1530a9dd82bc3bf5ee2';
public const PACKAGE_VERSION = 'b98dc27704c64122750d3bbae3731cb820ae8c11';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-08-03 20:30:41';
public const RELEASE_DATE = '2022-08-04 19:02:26';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit2a9cc3ab76269ee1bff220fc506c66d4::getLoader();
return ComposerAutoloaderInit9396c4dcd694bbf0466b74cb1a1376d2::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit2a9cc3ab76269ee1bff220fc506c66d4
class ComposerAutoloaderInit9396c4dcd694bbf0466b74cb1a1376d2
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit2a9cc3ab76269ee1bff220fc506c66d4
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit2a9cc3ab76269ee1bff220fc506c66d4', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit9396c4dcd694bbf0466b74cb1a1376d2', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit2a9cc3ab76269ee1bff220fc506c66d4', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit9396c4dcd694bbf0466b74cb1a1376d2', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit2a9cc3ab76269ee1bff220fc506c66d4::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit9396c4dcd694bbf0466b74cb1a1376d2::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit2a9cc3ab76269ee1bff220fc506c66d4::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit9396c4dcd694bbf0466b74cb1a1376d2::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire2a9cc3ab76269ee1bff220fc506c66d4($fileIdentifier, $file);
composerRequire9396c4dcd694bbf0466b74cb1a1376d2($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit2a9cc3ab76269ee1bff220fc506c66d4
* @param string $file
* @return void
*/
function composerRequire2a9cc3ab76269ee1bff220fc506c66d4($fileIdentifier, $file)
function composerRequire9396c4dcd694bbf0466b74cb1a1376d2($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

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