Updated Rector to commit 59cdfc8d814b094bffd814f4679c828cd45c7ec9

59cdfc8d81 Use isInteger() (#3571)
This commit is contained in:
Tomas Votruba 2023-04-08 01:19:54 +00:00
parent e7c7a40197
commit aaddfe2522
16 changed files with 28 additions and 29 deletions

View File

@ -242,7 +242,7 @@ final class NodeTypeResolver
public function isNumberType(Expr $expr) : bool
{
$nodeType = $this->getType($expr);
if ($nodeType instanceof IntegerType) {
if ($nodeType->isInteger()->yes()) {
return \true;
}
return $nodeType->isFloat()->yes();

View File

@ -63,7 +63,7 @@ final class StaticTypeAnalyzer
if ($type->isString()->yes()) {
return \true;
}
if ($type instanceof IntegerType) {
if ($type->isInteger()->yes()) {
return \true;
}
return $type->isFloat()->yes();

View File

@ -22,7 +22,7 @@ final class ScalarTypeComparator
$secondTypeClass = \get_class($secondType);
return $firstTypeClass === $secondTypeClass;
}
if ($firstType instanceof IntegerType && $secondType instanceof IntegerType) {
if ($firstType->isInteger()->yes() && $secondType->isInteger()->yes()) {
return \true;
}
if ($firstType->isFloat()->yes() && $secondType->isFloat()->yes()) {
@ -64,7 +64,7 @@ final class ScalarTypeComparator
if ($type->isFloat()->yes()) {
return \true;
}
if ($type instanceof IntegerType) {
if ($type->isInteger()->yes()) {
return \true;
}
return $type->isBoolean()->yes();

View File

@ -96,7 +96,7 @@ final class UnionTypeAnalyzer
if ($type->isFloat()->yes()) {
continue;
}
if ($type instanceof IntegerType) {
if ($type->isInteger()->yes()) {
continue;
}
if ($type->isBoolean()->yes()) {

View File

@ -209,7 +209,7 @@ final class ArrayTypeMapper implements TypeMapperInterface
}
private function isIntegerKeyAndNonNestedArray(ArrayType $arrayType) : bool
{
if (!$arrayType->getKeyType() instanceof IntegerType) {
if (!$arrayType->getKeyType()->isInteger()->yes()) {
return \false;
}
return !$arrayType->getItemType() instanceof ArrayType;

View File

@ -89,7 +89,7 @@ final class ExprParameterReflectionTypeCorrector
}
$clearParameterType = TypeCombinator::removeNull($parameterType);
// correct type
if ($clearParameterType instanceof IntegerType && $item instanceof String_) {
if ($clearParameterType->isInteger()->yes() && $item instanceof String_) {
return new LNumber((int) $item->value);
}
if ($clearParameterType->isBoolean()->yes() && $item instanceof String_) {

View File

@ -146,7 +146,7 @@ CODE_SAMPLE
return $this->resolveString($isNegated, $expr);
}
$exprType = $this->getType($expr);
if ($exprType instanceof IntegerType) {
if ($exprType->isInteger()->yes()) {
return $this->resolveInteger($isNegated, $expr);
}
if ($exprType->isFloat()->yes()) {

View File

@ -53,7 +53,7 @@ final class MbStrrposEncodingArgumentPositionRector extends AbstractRector imple
return null;
}
$secondArgType = $this->getType($node->args[2]->value);
if ($secondArgType instanceof IntegerType) {
if ($secondArgType->isInteger()->yes()) {
return null;
}
$node->args[3] = $node->args[2];

View File

@ -46,7 +46,7 @@ final class SwitchAnalyzer
}
$uniqueTypes = $this->typeFactory->uniquateTypes($types);
$countUniqueTypes = \count($uniqueTypes);
if ($countUniqueTypes === 1 && $uniqueTypes[0] instanceof IntegerType) {
if ($countUniqueTypes === 1 && $uniqueTypes[0]->isInteger()->yes()) {
$switchCondType = $this->nodeTypeResolver->getType($expr);
if (!$switchCondType instanceof MixedType && $switchCondType->isString()->maybe()) {
return \true;

View File

@ -41,7 +41,7 @@ final class ExactCompareFactory
if ($exprType->isString()->yes()) {
return new Identical($expr, new String_(''));
}
if ($exprType instanceof IntegerType) {
if ($exprType->isInteger()->yes()) {
return new Identical($expr, new LNumber(0));
}
if ($exprType->isBoolean()->yes()) {
@ -66,7 +66,7 @@ final class ExactCompareFactory
if ($exprType->isString()->yes()) {
return new NotIdentical($expr, new String_(''));
}
if ($exprType instanceof IntegerType) {
if ($exprType->isInteger()->yes()) {
return new NotIdentical($expr, new LNumber(0));
}
if ($exprType->isArray()->yes()) {

View File

@ -121,7 +121,7 @@ final class AlwaysStrictScalarExprAnalyzer
if ($type->isFloat()->yes()) {
return \true;
}
if ($type instanceof IntegerType) {
if ($type->isInteger()->yes()) {
return \true;
}
return $type->isBoolean()->yes();

View File

@ -163,7 +163,7 @@ final class ReturnTypeInferer
}
if ($resolvedType instanceof UnionType) {
$benevolentUnionTypeIntegerType = $this->resolveBenevolentUnionTypeInteger($functionLike, $resolvedType);
if ($benevolentUnionTypeIntegerType instanceof IntegerType) {
if ($benevolentUnionTypeIntegerType->isInteger()->yes()) {
return $benevolentUnionTypeIntegerType;
}
}
@ -171,16 +171,15 @@ final class ReturnTypeInferer
}
/**
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $functionLike
* @return \PHPStan\Type\UnionType|\PHPStan\Type\IntegerType
*/
private function resolveBenevolentUnionTypeInteger($functionLike, UnionType $unionType)
private function resolveBenevolentUnionTypeInteger($functionLike, UnionType $unionType) : Type
{
$types = $unionType->getTypes();
$countTypes = \count($types);
if ($countTypes !== 2) {
return $unionType;
}
if (!($types[0] instanceof IntegerType && $types[1]->isString()->yes())) {
if (!($types[0]->isInteger()->yes() && $types[1]->isString()->yes())) {
return $unionType;
}
if (!$functionLike instanceof ArrowFunction) {

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '437cc5aa660262603343cdbb193e0a54abf9037e';
public const PACKAGE_VERSION = '59cdfc8d814b094bffd814f4679c828cd45c7ec9';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-04-08 08:08:35';
public const RELEASE_DATE = '2023-04-08 08:15:49';
/**
* @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 ComposerAutoloaderInit667f5694da781b4883bc1005569ab3d1::getLoader();
return ComposerAutoloaderInit4df32a3c45bbdb27f25006bd04e40b5a::getLoader();

View File

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