Updated Rector to commit e78e4727d513475187dae0300f78ef70043379f9

e78e4727d5 Utilize Type->isString() in rules/ (#3064)
This commit is contained in:
Tomas Votruba 2022-11-15 00:01:27 +00:00
parent f714817bb9
commit e05478f2e2
15 changed files with 26 additions and 32 deletions

View File

@ -59,7 +59,7 @@ CODE_SAMPLE
return null;
}
$firstArgumentStaticType = $this->getType($node->args[0]->value);
if (!$firstArgumentStaticType instanceof StringType) {
if (!$firstArgumentStaticType->isString()->yes()) {
return null;
}
$node->args[2] = new Arg($this->nodeFactory->createTrue());

View File

@ -88,7 +88,7 @@ CODE_SAMPLE
$secondArg = $node->args[1];
$valueArgument = $secondArg->value;
$valueType = $this->getType($valueArgument);
if (!$valueType instanceof StringType) {
if (!$valueType->isString()->yes()) {
return null;
}
return $valueArgument;

View File

@ -87,7 +87,7 @@ CODE_SAMPLE
$variable = $firstArg->value;
// Needs string cast if variable type is not string
// see https://github.com/rectorphp/rector/issues/6700
$isStringType = $this->nodeTypeResolver->getNativeType($variable) instanceof StringType;
$isStringType = $this->nodeTypeResolver->getNativeType($variable)->isString()->yes();
if (!$isStringType) {
return new Identical(new Expr\Cast\String_($variable), new String_(''));
}

View File

@ -128,7 +128,7 @@ CODE_SAMPLE
}
private function shouldSkip(Type $conditionStaticType, BinaryOp $binaryOp, ?Node $nextNode) : bool
{
return $conditionStaticType instanceof StringType && $binaryOp instanceof BooleanOr && !$nextNode instanceof Node;
return $conditionStaticType->isString()->yes() && $binaryOp instanceof BooleanOr && !$nextNode instanceof Node;
}
private function resolveNewConditionNode(Expr $expr, bool $isNegated) : ?BinaryOp
{

View File

@ -44,7 +44,7 @@ final class ListSplitStringRector extends AbstractRector implements MinPhpVersio
return null;
}
$exprType = $this->getType($node->expr);
if (!$exprType instanceof StringType) {
if (!$exprType->isString()->yes()) {
return null;
}
$node->expr = $this->nodeFactory->createFuncCall('str_split', [$node->expr]);

View File

@ -64,15 +64,9 @@ CODE_SAMPLE
// is argument string?
$needleArgValue = $node->args[1]->value;
$needleType = $this->getType($needleArgValue);
if ($needleType instanceof StringType) {
return null;
}
if ($needleType->isString()->yes()) {
return null;
}
if ($needleArgValue instanceof String_) {
return null;
}
if ($needleArgValue instanceof Encapsed) {
return null;
}

View File

@ -106,7 +106,7 @@ CODE_SAMPLE
return null;
}
$returnType = $this->returnTypeInferer->inferFunctionLike($toStringClassMethod);
if (!$returnType instanceof StringType) {
if (!$returnType->isString()->yes()) {
$this->processNotStringType($toStringClassMethod);
}
// add interface
@ -140,7 +140,7 @@ CODE_SAMPLE
return null;
}
$type = $this->nodeTypeResolver->getType($subNode->expr);
if ($type instanceof StringType) {
if ($type->isString()->yes()) {
return null;
}
$subNode->expr = new CastString_($subNode->expr);

View File

@ -40,7 +40,7 @@ final class ExactCompareFactory
*/
public function createIdenticalFalsyCompare(Type $exprType, Expr $expr, bool $treatAsNonEmpty)
{
if ($exprType instanceof StringType) {
if ($exprType->isString()->yes()) {
return new Identical($expr, new String_(''));
}
if ($exprType instanceof IntegerType) {
@ -65,7 +65,7 @@ final class ExactCompareFactory
*/
public function createNotIdenticalFalsyCompare(Type $exprType, Expr $expr, bool $treatAsNotEmpty)
{
if ($exprType instanceof StringType) {
if ($exprType->isString()->yes()) {
return new NotIdentical($expr, new String_(''));
}
if ($exprType instanceof IntegerType) {

View File

@ -50,7 +50,7 @@ final class AdvancedArrayAnalyzer
if (!$currentReturnType->getItemType() instanceof ClassStringType) {
return \false;
}
return $arrayType->getItemType() instanceof StringType;
return $arrayType->getItemType()->isString()->yes();
}
public function isMixedOfSpecificOverride(ArrayType $arrayType, PhpDocInfo $phpDocInfo) : bool
{

View File

@ -65,7 +65,7 @@ final class AlwaysStrictScalarExprAnalyzer
}
private function isScalarType(Type $type) : bool
{
if ($type instanceof StringType && !$type instanceof ConstantStringType) {
if ($type->isString()->yes() && !$type instanceof ConstantStringType) {
return \true;
}
if ($type instanceof FloatType) {

View File

@ -210,7 +210,7 @@ final class ReturnTypeInferer
if ($countTypes !== 2) {
return $unionType;
}
if (!($types[0] instanceof IntegerType && $types[1] instanceof StringType)) {
if (!($types[0] instanceof IntegerType && $types[1]->isString()->yes())) {
return $unionType;
}
$returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($functionLike, Return_::class);

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'f094438f26f1795a0c4c991aaeaeda37389aff8c';
public const PACKAGE_VERSION = 'e78e4727d513475187dae0300f78ef70043379f9';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-11-14 16:17:33';
public const RELEASE_DATE = '2022-11-15 00:56:37';
/**
* @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 ComposerAutoloaderInit53fe9493af495edb782b0809f61e7ddf::getLoader();
return ComposerAutoloaderInit80f30366f3ef5661db3ef4c92ea7e59d::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit53fe9493af495edb782b0809f61e7ddf
class ComposerAutoloaderInit80f30366f3ef5661db3ef4c92ea7e59d
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit53fe9493af495edb782b0809f61e7ddf
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit53fe9493af495edb782b0809f61e7ddf', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit80f30366f3ef5661db3ef4c92ea7e59d', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit53fe9493af495edb782b0809f61e7ddf', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit80f30366f3ef5661db3ef4c92ea7e59d', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit53fe9493af495edb782b0809f61e7ddf::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit80f30366f3ef5661db3ef4c92ea7e59d::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit53fe9493af495edb782b0809f61e7ddf::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit80f30366f3ef5661db3ef4c92ea7e59d::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire53fe9493af495edb782b0809f61e7ddf($fileIdentifier, $file);
composerRequire80f30366f3ef5661db3ef4c92ea7e59d($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit53fe9493af495edb782b0809f61e7ddf
* @param string $file
* @return void
*/
function composerRequire53fe9493af495edb782b0809f61e7ddf($fileIdentifier, $file)
function composerRequire80f30366f3ef5661db3ef4c92ea7e59d($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 ComposerStaticInit53fe9493af495edb782b0809f61e7ddf
class ComposerStaticInit80f30366f3ef5661db3ef4c92ea7e59d
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3032,9 +3032,9 @@ class ComposerStaticInit53fe9493af495edb782b0809f61e7ddf
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit53fe9493af495edb782b0809f61e7ddf::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit53fe9493af495edb782b0809f61e7ddf::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit53fe9493af495edb782b0809f61e7ddf::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit80f30366f3ef5661db3ef4c92ea7e59d::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit80f30366f3ef5661db3ef4c92ea7e59d::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit80f30366f3ef5661db3ef4c92ea7e59d::$classMap;
}, null, ClassLoader::class);
}