Updated Rector to commit 437cc5aa660262603343cdbb193e0a54abf9037e

437cc5aa66 Use isBoolean() (#3570)
This commit is contained in:
Tomas Votruba 2023-04-08 01:12:35 +00:00
parent 5f5a4162ce
commit e7c7a40197
21 changed files with 41 additions and 41 deletions

View File

@ -57,7 +57,7 @@ final class StaticTypeAnalyzer
if ($type instanceof NullType) {
return \true;
}
if ($type instanceof BooleanType) {
if ($type->isBoolean()->yes()) {
return \true;
}
if ($type->isString()->yes()) {

View File

@ -28,10 +28,10 @@ final class ScalarTypeComparator
if ($firstType->isFloat()->yes() && $secondType->isFloat()->yes()) {
return \true;
}
if (!$firstType instanceof BooleanType) {
if (!$firstType->isBoolean()->yes()) {
return \false;
}
return $secondType instanceof BooleanType;
return $secondType->isBoolean()->yes();
}
/**
* E.g. first is string, second is bool
@ -67,6 +67,6 @@ final class ScalarTypeComparator
if ($type instanceof IntegerType) {
return \true;
}
return $type instanceof BooleanType;
return $type->isBoolean()->yes();
}
}

View File

@ -11,7 +11,7 @@ final class BoolUnionTypeAnalyzer
public function isBoolUnionType(UnionType $unionType) : bool
{
foreach ($unionType->getTypes() as $unionedType) {
if (!$unionedType instanceof BooleanType) {
if (!$unionedType->isBoolean()->yes()) {
return \false;
}
}
@ -25,7 +25,7 @@ final class BoolUnionTypeAnalyzer
$hasNullable = \true;
continue;
}
if ($unionedType instanceof BooleanType) {
if ($unionedType->isBoolean()->yes()) {
continue;
}
return \false;

View File

@ -99,7 +99,7 @@ final class UnionTypeAnalyzer
if ($type instanceof IntegerType) {
continue;
}
if ($type instanceof BooleanType) {
if ($type->isBoolean()->yes()) {
continue;
}
return \false;

View File

@ -92,7 +92,7 @@ final class ExprParameterReflectionTypeCorrector
if ($clearParameterType instanceof IntegerType && $item instanceof String_) {
return new LNumber((int) $item->value);
}
if ($clearParameterType instanceof BooleanType && $item instanceof String_) {
if ($clearParameterType->isBoolean()->yes() && $item instanceof String_) {
if (\strtolower($item->value) === 'true') {
return $this->nodeFactory->createTrue();
}

View File

@ -72,7 +72,7 @@ final class ExprBoolCaster
return \false;
}
$exprType = $this->nodeTypeResolver->getType($expr);
if ($exprType instanceof BooleanType) {
if ($exprType->isBoolean()->yes()) {
return \false;
}
return !$expr instanceof BinaryOp;

View File

@ -85,7 +85,7 @@ CODE_SAMPLE
/** @var BooleanAnd|BooleanOr $booleanExpr */
$booleanExpr = $expression->expr;
$leftStaticType = $this->getType($booleanExpr->left);
if (!$leftStaticType instanceof BooleanType) {
if (!$leftStaticType->isBoolean()->yes()) {
return null;
}
$exprLeft = $booleanExpr->left instanceof BooleanNot ? $booleanExpr->left->expr : $booleanExpr->left;

View File

@ -67,11 +67,11 @@ CODE_SAMPLE
if ($node->expr instanceof Identical) {
$identical = $node->expr;
$leftType = $this->getType($identical->left);
if (!$leftType instanceof BooleanType) {
if (!$leftType->isBoolean()->yes()) {
return null;
}
$rightType = $this->getType($identical->right);
if (!$rightType instanceof BooleanType) {
if (!$rightType->isBoolean()->yes()) {
return null;
}
return new NotIdentical($identical->left, $identical->right);
@ -81,11 +81,11 @@ CODE_SAMPLE
private function processIdentical(Identical $identical) : ?NotIdentical
{
$leftType = $this->getType($identical->left);
if (!$leftType instanceof BooleanType) {
if (!$leftType->isBoolean()->yes()) {
return null;
}
$rightType = $this->getType($identical->right);
if (!$rightType instanceof BooleanType) {
if (!$rightType->isBoolean()->yes()) {
return null;
}
if ($identical->left instanceof BooleanNot) {

View File

@ -55,11 +55,11 @@ CODE_SAMPLE
public function refactor(Node $node) : ?Node
{
$leftType = $this->getType($node->left);
if ($leftType instanceof BooleanType && !$this->valueResolver->isTrueOrFalse($node->left)) {
if ($leftType->isBoolean()->yes() && !$this->valueResolver->isTrueOrFalse($node->left)) {
return $this->processBoolTypeToNotBool($node, $node->left, $node->right);
}
$rightType = $this->getType($node->right);
if (!$rightType instanceof BooleanType) {
if (!$rightType->isBoolean()->yes()) {
return null;
}
if ($this->valueResolver->isTrueOrFalse($node->right)) {
@ -89,7 +89,7 @@ CODE_SAMPLE
}
$leftExprType = $this->getType($leftExpr);
// keep as it is, readable enough
if ($leftExpr instanceof Variable && $leftExprType instanceof BooleanType) {
if ($leftExpr instanceof Variable && $leftExprType->isBoolean()->yes()) {
return null;
}
return new BooleanNot($leftExpr);

View File

@ -109,7 +109,7 @@ CODE_SAMPLE
return null;
}
$conditionStaticType = $this->getType($conditionNode);
if ($conditionStaticType instanceof BooleanType) {
if ($conditionStaticType->isBoolean()->yes()) {
return null;
}
$binaryOp = $this->resolveNewConditionNode($conditionNode, $isNegated);

View File

@ -94,7 +94,7 @@ final class UnnecessaryTernaryExpressionRector extends AbstractRector
private function processTrueIfExpressionWithFalseElseExpression(Expr $expr) : Expr
{
$exprType = $this->getType($expr);
if ($exprType instanceof BooleanType) {
if ($exprType->isBoolean()->yes()) {
return $expr;
}
return new Bool_($expr);
@ -103,13 +103,13 @@ final class UnnecessaryTernaryExpressionRector extends AbstractRector
{
if ($expr instanceof BooleanNot) {
$negatedExprType = $this->getType($expr->expr);
if ($negatedExprType instanceof BooleanType) {
if ($negatedExprType->isBoolean()->yes()) {
return $expr->expr;
}
return new Bool_($expr->expr);
}
$exprType = $this->getType($expr);
if ($exprType instanceof BooleanType) {
if ($exprType->isBoolean()->yes()) {
return new BooleanNot($expr);
}
return new BooleanNot(new Bool_($expr));

View File

@ -86,6 +86,6 @@ CODE_SAMPLE
private function isBoolDocType(Property $property) : bool
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
return $phpDocInfo->getVarType() instanceof BooleanType;
return $phpDocInfo->getVarType()->isBoolean()->yes();
}
}

View File

@ -135,7 +135,7 @@ CODE_SAMPLE
return \false;
}
$type = $this->nodeTypeResolver->getType($cond);
if (!$type instanceof BooleanType) {
if (!$type->isBoolean()->yes()) {
return \false;
}
$nextNode = $ifWithOnlyReturns[0]->getAttribute(AttributeKey::NEXT_NODE);

View File

@ -70,7 +70,7 @@ CODE_SAMPLE
return null;
}
$ifType = $this->getType($node->if);
if (!$ifType instanceof BooleanType) {
if (!$ifType->isBoolean()->yes()) {
return null;
}
return new BooleanAnd($node->cond, $node->if);

View File

@ -44,7 +44,7 @@ final class ExactCompareFactory
if ($exprType instanceof IntegerType) {
return new Identical($expr, new LNumber(0));
}
if ($exprType instanceof BooleanType) {
if ($exprType->isBoolean()->yes()) {
return new Identical($expr, $this->nodeFactory->createFalse());
}
if ($exprType->isArray()->yes()) {
@ -83,7 +83,7 @@ final class ExactCompareFactory
private function createFromUnionType(UnionType $unionType, Expr $expr, bool $treatAsNotEmpty)
{
$unionType = TypeCombinator::removeNull($unionType);
if ($unionType instanceof BooleanType) {
if ($unionType->isBoolean()->yes()) {
return new Identical($expr, $this->nodeFactory->createTrue());
}
if ($unionType instanceof TypeWithClassName) {
@ -172,7 +172,7 @@ final class ExactCompareFactory
$compareExprs = $this->collectCompareExprs($unionType, $expr, $treatAsNonEmpty);
return $this->createBooleanOr($compareExprs);
}
if ($unionType instanceof BooleanType) {
if ($unionType->isBoolean()->yes()) {
return new NotIdentical($expr, $this->nodeFactory->createTrue());
}
if ($unionType instanceof TypeWithClassName) {

View File

@ -124,7 +124,7 @@ final class AlwaysStrictScalarExprAnalyzer
if ($type instanceof IntegerType) {
return \true;
}
return $type instanceof BooleanType;
return $type->isBoolean()->yes();
}
private function resolveTypeFromScalar(Scalar $scalar) : ?\PHPStan\Type\Type
{

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '7611dcb05adda44fb14a228574481b3f79d0b9d5';
public const PACKAGE_VERSION = '437cc5aa660262603343cdbb193e0a54abf9037e';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-04-08 08:03:58';
public const RELEASE_DATE = '2023-04-08 08:08:35';
/**
* @var int
*/

View File

@ -97,7 +97,7 @@ final class AssignAndBinaryMap
return new Bool_($expr);
}
$type = $scope->getType($expr);
if ($type instanceof BooleanType) {
if ($type->isBoolean()->yes()) {
return $expr;
}
return new Bool_($expr);

2
vendor/autoload.php vendored
View File

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

View File

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