Updated Rector to commit 31e22ff70699ac52c0cd4faee5b5f42291bb8ccb

31e22ff706 [PHPStanStaticTypeMapper] Improve performance of UnionTypeMapper take 3 (#3690)
This commit is contained in:
Tomas Votruba 2023-04-26 13:34:46 +00:00
parent c6bd0e5845
commit 62693051ca
5 changed files with 19 additions and 18 deletions

View File

@ -154,7 +154,8 @@ final class UnionTypeMapper implements TypeMapperInterface
*/
public function resolveTypeWithNullablePHPParserUnionType(PhpParserUnionType $phpParserUnionType)
{
if (\count($phpParserUnionType->types) === 2) {
$totalTypes = \count($phpParserUnionType->types);
if ($totalTypes === 2) {
$phpParserUnionType->types = \array_values($phpParserUnionType->types);
$firstType = $phpParserUnionType->types[0];
$secondType = $phpParserUnionType->types[1];
@ -162,12 +163,12 @@ final class UnionTypeMapper implements TypeMapperInterface
Assert::isAnyOf($firstType, [Name::class, Identifier::class]);
Assert::isAnyOf($secondType, [Name::class, Identifier::class]);
} catch (InvalidArgumentException $exception) {
return $this->resolveUnionTypes($phpParserUnionType);
return $this->resolveUnionTypes($phpParserUnionType, $totalTypes);
}
$firstTypeValue = $firstType->toString();
$secondTypeValue = $secondType->toString();
if ($firstTypeValue === $secondTypeValue) {
return $this->resolveUnionTypes($phpParserUnionType);
return $this->resolveUnionTypes($phpParserUnionType, $totalTypes);
}
if ($firstTypeValue === 'null') {
return $this->resolveNullableType(new NullableType($secondType));
@ -176,7 +177,7 @@ final class UnionTypeMapper implements TypeMapperInterface
return $this->resolveNullableType(new NullableType($firstType));
}
}
return $this->resolveUnionTypes($phpParserUnionType);
return $this->resolveUnionTypes($phpParserUnionType, $totalTypes);
}
/**
* @return null|\PhpParser\Node\NullableType|PhpParserUnionType
@ -246,12 +247,12 @@ final class UnionTypeMapper implements TypeMapperInterface
}
return new Identifier($type);
}
private function resolveUnionTypes(PhpParserUnionType $phpParserUnionType) : ?PhpParserUnionType
private function resolveUnionTypes(PhpParserUnionType $phpParserUnionType, int $totalTypes) : ?PhpParserUnionType
{
if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES)) {
return null;
}
if (\count($phpParserUnionType->types) === 2) {
if ($totalTypes === 2) {
return $phpParserUnionType;
}
$identifierNames = [];

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '7e7b155023e00867ba3f061c4c6b01b5f2fc361a';
public const PACKAGE_VERSION = '31e22ff70699ac52c0cd4faee5b5f42291bb8ccb';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-04-26 12:09:58';
public const RELEASE_DATE = '2023-04-26 20:29:58';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit0bb5bcd839c89e6c19f726b989d2d6a3
class ComposerAutoloaderInit1059b3a7b4881f801c4e30b8ee7d67d7
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit0bb5bcd839c89e6c19f726b989d2d6a3
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit0bb5bcd839c89e6c19f726b989d2d6a3', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit1059b3a7b4881f801c4e30b8ee7d67d7', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit0bb5bcd839c89e6c19f726b989d2d6a3', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit1059b3a7b4881f801c4e30b8ee7d67d7', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit0bb5bcd839c89e6c19f726b989d2d6a3::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit0bb5bcd839c89e6c19f726b989d2d6a3::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7::$files;
$requireFile = \Closure::bind(static function ($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 ComposerStaticInit0bb5bcd839c89e6c19f726b989d2d6a3
class ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3150,9 +3150,9 @@ class ComposerStaticInit0bb5bcd839c89e6c19f726b989d2d6a3
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit0bb5bcd839c89e6c19f726b989d2d6a3::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit0bb5bcd839c89e6c19f726b989d2d6a3::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit0bb5bcd839c89e6c19f726b989d2d6a3::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit1059b3a7b4881f801c4e30b8ee7d67d7::$classMap;
}, null, ClassLoader::class);
}