Updated Rector to commit 9629890a306844ba49ea6689d58fbecb67a7980e

9629890a30 Use isInteger() (#3593)
This commit is contained in:
Tomas Votruba 2023-04-09 00:51:38 +00:00
parent 2300088c0b
commit 3f1c0e6187
16 changed files with 28 additions and 40 deletions

View File

@ -23,7 +23,6 @@ use PHPStan\Broker\ClassAutoloadingException;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
use PHPStan\Type\ObjectType;
@ -241,7 +240,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

@ -6,7 +6,6 @@ namespace Rector\NodeTypeResolver\PHPStan\Type;
use PHPStan\Type\ArrayType;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\ConstantScalarType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
use PHPStan\Type\ObjectType;
@ -61,7 +60,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

@ -4,7 +4,6 @@ declare (strict_types=1);
namespace Rector\NodeTypeResolver\TypeComparator;
use PHPStan\Type\ClassStringType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\Type;
/**
* @see \Rector\Tests\NodeTypeResolver\TypeComparator\ScalarTypeComparatorTest
@ -19,7 +18,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()) {
@ -61,7 +60,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

@ -5,7 +5,6 @@ namespace Rector\PHPStanStaticTypeMapper\TypeAnalyzer;
use PHPStan\Type\ArrayType;
use PHPStan\Type\Constant\ConstantStringType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\IterableType;
use PHPStan\Type\NullType;
use PHPStan\Type\ObjectType;
@ -93,7 +92,7 @@ final class UnionTypeAnalyzer
if ($type->isFloat()->yes()) {
continue;
}
if ($type instanceof IntegerType) {
if ($type->isInteger()->yes()) {
continue;
}
if ($type->isBoolean()->yes()) {

View File

@ -14,7 +14,6 @@ use PHPStan\Type\ClassStringType;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\Generic\GenericClassStringType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType;
use PHPStan\Type\NeverType;
use PHPStan\Type\ObjectType;
@ -209,7 +208,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

@ -10,7 +10,6 @@ use PhpParser\Node\Scalar\String_;
use PHPStan\Reflection\ParameterReflection;
use PHPStan\Reflection\ParametersAcceptorSelector;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\IntegerType;
use PHPStan\Type\TypeCombinator;
use Rector\Core\PhpParser\Node\NodeFactory;
use Rector\StaticTypeMapper\StaticTypeMapper;
@ -88,7 +87,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

@ -22,7 +22,6 @@ use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\ElseIf_;
use PhpParser\Node\Stmt\If_;
use PHPStan\Type\IntegerType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use Rector\Core\Rector\AbstractRector;
@ -144,7 +143,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

@ -7,7 +7,6 @@ use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Scalar\LNumber;
use PHPStan\Type\IntegerType;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
@ -53,7 +52,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

@ -9,7 +9,6 @@ use PhpParser\Node\Stmt\Break_;
use PhpParser\Node\Stmt\Case_;
use PhpParser\Node\Stmt\Return_;
use PhpParser\Node\Stmt\Switch_;
use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType;
use Rector\NodeTypeResolver\NodeTypeResolver;
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
@ -46,7 +45,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

@ -14,7 +14,6 @@ use PhpParser\Node\Expr\Instanceof_;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\String_;
use PHPStan\Type\IntegerType;
use PHPStan\Type\NullType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
@ -40,7 +39,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()) {
@ -65,7 +64,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

@ -16,7 +16,6 @@ use PhpParser\Node\Stmt\Return_;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\BenevolentUnionType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType;
use PHPStan\Type\ThisType;
use PHPStan\Type\Type;
@ -162,7 +161,7 @@ final class ReturnTypeInferer
}
if ($resolvedType instanceof UnionType) {
$benevolentUnionTypeIntegerType = $this->resolveBenevolentUnionTypeInteger($functionLike, $resolvedType);
if ($benevolentUnionTypeIntegerType instanceof IntegerType) {
if ($benevolentUnionTypeIntegerType->isInteger()->yes()) {
return $benevolentUnionTypeIntegerType;
}
}
@ -170,16 +169,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 = '08660ad7077c86c3c86e7d1cbd14d9d7d71cb450';
public const PACKAGE_VERSION = '9629890a306844ba49ea6689d58fbecb67a7980e';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-04-09 07:35:54';
public const RELEASE_DATE = '2023-04-09 07:47:25';
/**
* @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 ComposerAutoloaderInit87632d981c24bc4d1b41f60c6adf6ecc::getLoader();
return ComposerAutoloaderInitc1aadb08c0eb4a102174237f78568c1e::getLoader();

View File

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