Updated Rector to commit 6655c2c4e3d72d513c38162da5087bbc2df25b83

6655c2c4e3 [PHPStanStaticTypeMapper] Reduce bool check on UnionTypeMapper (#3778)
This commit is contained in:
Tomas Votruba 2023-05-09 07:42:34 +00:00
parent 6105d98780
commit 3f1ac1628e
6 changed files with 12 additions and 48 deletions

View File

@ -3,7 +3,6 @@
declare (strict_types=1);
namespace Rector\PHPStanStaticTypeMapper\TypeAnalyzer;
use PHPStan\Type\NullType;
use PHPStan\Type\UnionType;
final class BoolUnionTypeAnalyzer
{
@ -16,19 +15,4 @@ final class BoolUnionTypeAnalyzer
}
return \true;
}
public function isNullableBoolUnionType(UnionType $unionType) : bool
{
$hasNullable = \false;
foreach ($unionType->getTypes() as $unionedType) {
if ($unionedType instanceof NullType) {
$hasNullable = \true;
continue;
}
if ($unionedType->isBoolean()->yes()) {
continue;
}
return \false;
}
return $hasNullable;
}
}

View File

@ -134,13 +134,6 @@ final class UnionTypeMapper implements TypeMapperInterface
if ($arrayNode !== null) {
return $arrayNode;
}
if ($this->boolUnionTypeAnalyzer->isNullableBoolUnionType($type) && !$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES)) {
return $this->resolveNullableType(new NullableType(new Identifier('bool')));
}
if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES) && $this->isFalseBoolUnion($type)) {
// return new Bool
return new Identifier('bool');
}
// special case for nullable
$nullabledType = $this->matchTypeForNullableUnionType($type);
if (!$nullabledType instanceof Type) {
@ -436,19 +429,6 @@ final class UnionTypeMapper implements TypeMapperInterface
}
return $typeWithClassName;
}
private function isFalseBoolUnion(UnionType $unionType) : bool
{
if (\count($unionType->getTypes()) !== 2) {
return \false;
}
foreach ($unionType->getTypes() as $unionedType) {
if ($unionedType instanceof ConstantBooleanType) {
continue;
}
return \false;
}
return \true;
}
private function narrowIntegerType(UnionType $unionType) : ?Identifier
{
foreach ($unionType->getTypes() as $unionedType) {

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'cb30fd90e2fafe2b0bc7f6bd3f3ec2e6c09a4b09';
public const PACKAGE_VERSION = '6655c2c4e3d72d513c38162da5087bbc2df25b83';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-05-08 21:14:10';
public const RELEASE_DATE = '2023-05-09 14:38:07';
/**
* @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 ComposerAutoloaderInit4b7ef3b28e4f79e09b1d95321673e9a9::getLoader();
return ComposerAutoloaderInit5e7fb43124e1dedec1564683666324a6::getLoader();

View File

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