Updated Rector to commit 08660ad7077c86c3c86e7d1cbd14d9d7d71cb450

08660ad707 Use isFloat() (#3594)
This commit is contained in:
Tomas Votruba 2023-04-09 00:39:59 +00:00
parent 6a6d35d3ed
commit 2300088c0b
13 changed files with 41 additions and 29 deletions

View File

@ -6,11 +6,13 @@ namespace Rector\BetterPhpDocParser\PhpDocManipulator;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Property;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode;
use PHPStan\PhpDocParser\Ast\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode;
use PHPStan\PhpDocParser\Ast\Type\ConstTypeNode;
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
@ -37,7 +39,7 @@ final class PhpDocTypeChanger
/**
* @var array<class-string<Node>>
*/
public const ALLOWED_TYPES = [GenericTypeNode::class, SpacingAwareArrayTypeNode::class, SpacingAwareCallableTypeNode::class, ArrayShapeNode::class];
private const ALLOWED_TYPES = [GenericTypeNode::class, SpacingAwareArrayTypeNode::class, SpacingAwareCallableTypeNode::class, ArrayShapeNode::class];
/**
* @var string[]
*/
@ -182,6 +184,9 @@ final class PhpDocTypeChanger
}
}
}
if ($typeNode instanceof ConstTypeNode && $typeNode->constExpr instanceof ConstFetchNode) {
return \true;
}
if (\in_array(\get_class($typeNode), self::ALLOWED_TYPES, \true)) {
return \true;
}

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\FloatType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
@ -245,7 +244,7 @@ final class NodeTypeResolver
if ($nodeType instanceof IntegerType) {
return \true;
}
return $nodeType instanceof FloatType;
return $nodeType->isFloat()->yes();
}
/**
* @api

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\FloatType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
@ -65,7 +64,7 @@ final class StaticTypeAnalyzer
if ($type instanceof IntegerType) {
return \true;
}
return $type instanceof FloatType;
return $type->isFloat()->yes();
}
private function isAlwaysTruableUnionType(Type $type) : bool
{

View File

@ -4,7 +4,6 @@ declare (strict_types=1);
namespace Rector\NodeTypeResolver\TypeComparator;
use PHPStan\Type\ClassStringType;
use PHPStan\Type\FloatType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\Type;
/**
@ -23,7 +22,7 @@ final class ScalarTypeComparator
if ($firstType instanceof IntegerType && $secondType instanceof IntegerType) {
return \true;
}
if ($firstType instanceof FloatType && $secondType instanceof FloatType) {
if ($firstType->isFloat()->yes() && $secondType->isFloat()->yes()) {
return \true;
}
if (!$firstType->isBoolean()->yes()) {
@ -59,7 +58,7 @@ final class ScalarTypeComparator
if ($type->isString()->yes()) {
return \true;
}
if ($type instanceof FloatType) {
if ($type->isFloat()->yes()) {
return \true;
}
if ($type instanceof IntegerType) {

View File

@ -5,7 +5,6 @@ namespace Rector\PHPStanStaticTypeMapper\TypeAnalyzer;
use PHPStan\Type\ArrayType;
use PHPStan\Type\Constant\ConstantStringType;
use PHPStan\Type\FloatType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\IterableType;
use PHPStan\Type\NullType;
@ -91,7 +90,7 @@ final class UnionTypeAnalyzer
if ($type->isString()->yes() && !$type instanceof ConstantStringType) {
continue;
}
if ($type instanceof FloatType) {
if ($type->isFloat()->yes()) {
continue;
}
if ($type instanceof IntegerType) {

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\FloatType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
@ -148,7 +147,7 @@ CODE_SAMPLE
if ($exprType instanceof IntegerType) {
return $this->resolveInteger($isNegated, $expr);
}
if ($exprType instanceof FloatType) {
if ($exprType->isFloat()->yes()) {
return $this->resolveFloat($isNegated, $expr);
}
if ($this->nodeTypeResolver->isNullableTypeOfSpecificType($expr, ObjectType::class)) {

View File

@ -49,13 +49,19 @@ final class DeadParamTagValueNodeAnalyzer
* @var \Rector\TypeDeclaration\NodeAnalyzer\ParamAnalyzer
*/
private $paramAnalyzer;
public function __construct(NodeNameResolver $nodeNameResolver, TypeComparator $typeComparator, GenericTypeNodeAnalyzer $genericTypeNodeAnalyzer, MixedArrayTypeNodeAnalyzer $mixedArrayTypeNodeAnalyzer, ParamAnalyzer $paramAnalyzer)
/**
* @readonly
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger
*/
private $phpDocTypeChanger;
public function __construct(NodeNameResolver $nodeNameResolver, TypeComparator $typeComparator, GenericTypeNodeAnalyzer $genericTypeNodeAnalyzer, MixedArrayTypeNodeAnalyzer $mixedArrayTypeNodeAnalyzer, ParamAnalyzer $paramAnalyzer, PhpDocTypeChanger $phpDocTypeChanger)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->typeComparator = $typeComparator;
$this->genericTypeNodeAnalyzer = $genericTypeNodeAnalyzer;
$this->mixedArrayTypeNodeAnalyzer = $mixedArrayTypeNodeAnalyzer;
$this->paramAnalyzer = $paramAnalyzer;
$this->phpDocTypeChanger = $phpDocTypeChanger;
}
public function isDead(ParamTagValueNode $paramTagValueNode, FunctionLike $functionLike) : bool
{
@ -72,7 +78,7 @@ final class DeadParamTagValueNodeAnalyzer
if (!$this->typeComparator->arePhpParserAndPhpStanPhpDocTypesEqual($param->type, $paramTagValueNode->type, $functionLike)) {
return \false;
}
if (\in_array(\get_class($paramTagValueNode->type), PhpDocTypeChanger::ALLOWED_TYPES, \true)) {
if ($this->phpDocTypeChanger->isAllowed($paramTagValueNode->type)) {
return \false;
}
if (!$paramTagValueNode->type instanceof BracketsAwareUnionTypeNode) {

View File

@ -44,13 +44,19 @@ final class DeadReturnTagValueNodeAnalyzer
* @var \Rector\DeadCode\PhpDoc\Guard\StandaloneTypeRemovalGuard
*/
private $standaloneTypeRemovalGuard;
public function __construct(TypeComparator $typeComparator, BetterNodeFinder $betterNodeFinder, GenericTypeNodeAnalyzer $genericTypeNodeAnalyzer, MixedArrayTypeNodeAnalyzer $mixedArrayTypeNodeAnalyzer, StandaloneTypeRemovalGuard $standaloneTypeRemovalGuard)
/**
* @readonly
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger
*/
private $phpDocTypeChanger;
public function __construct(TypeComparator $typeComparator, BetterNodeFinder $betterNodeFinder, GenericTypeNodeAnalyzer $genericTypeNodeAnalyzer, MixedArrayTypeNodeAnalyzer $mixedArrayTypeNodeAnalyzer, StandaloneTypeRemovalGuard $standaloneTypeRemovalGuard, PhpDocTypeChanger $phpDocTypeChanger)
{
$this->typeComparator = $typeComparator;
$this->betterNodeFinder = $betterNodeFinder;
$this->genericTypeNodeAnalyzer = $genericTypeNodeAnalyzer;
$this->mixedArrayTypeNodeAnalyzer = $mixedArrayTypeNodeAnalyzer;
$this->standaloneTypeRemovalGuard = $standaloneTypeRemovalGuard;
$this->phpDocTypeChanger = $phpDocTypeChanger;
}
public function isDead(ReturnTagValueNode $returnTagValueNode, FunctionLike $functionLike) : bool
{
@ -65,7 +71,7 @@ final class DeadReturnTagValueNodeAnalyzer
if (!$this->typeComparator->arePhpParserAndPhpStanPhpDocTypesEqual($returnType, $returnTagValueNode->type, $functionLike)) {
return \false;
}
if (\in_array(\get_class($returnTagValueNode->type), PhpDocTypeChanger::ALLOWED_TYPES, \true)) {
if ($this->phpDocTypeChanger->isAllowed($returnTagValueNode->type)) {
return \false;
}
if (!$returnTagValueNode->type instanceof BracketsAwareUnionTypeNode) {

View File

@ -118,7 +118,7 @@ final class AlwaysStrictScalarExprAnalyzer
if ($type->isString()->yes() && !$type instanceof ConstantStringType) {
return \true;
}
if ($type instanceof FloatType) {
if ($type->isFloat()->yes()) {
return \true;
}
if ($type instanceof IntegerType) {

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '0492831348592eba9ac956845d711aa4fe5f7b1a';
public const PACKAGE_VERSION = '08660ad7077c86c3c86e7d1cbd14d9d7d71cb450';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-04-09 07:28:36';
public const RELEASE_DATE = '2023-04-09 07:35:54';
/**
* @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 ComposerAutoloaderInitd7cd785f2c0325940a2fa40e14e0b098::getLoader();
return ComposerAutoloaderInit87632d981c24bc4d1b41f60c6adf6ecc::getLoader();

View File

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