mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-28 13:43:31 +00:00
Updated Rector to commit 04257d3c76ee23722447433f07c8e5678ac9a07b
04257d3c76
Utilize Type->isArray() (#3065)
This commit is contained in:
parent
e05478f2e2
commit
b0ce719527
|
@ -106,7 +106,7 @@ CODE_SAMPLE
|
|||
return \true;
|
||||
}
|
||||
$type = $scope->getType($foreach->expr);
|
||||
return !$type instanceof ArrayType;
|
||||
return !$type->isArray()->yes();
|
||||
}
|
||||
private function shouldSkipAsPartOfOtherLoop(Foreach_ $foreach) : bool
|
||||
{
|
||||
|
|
|
@ -159,7 +159,7 @@ CODE_SAMPLE
|
|||
private function resolveCount(bool $isNegated, FuncCall $funcCall)
|
||||
{
|
||||
$countedType = $this->getType($funcCall->args[0]->value);
|
||||
if ($countedType instanceof ArrayType) {
|
||||
if ($countedType->isArray()->yes()) {
|
||||
return null;
|
||||
}
|
||||
$lNumber = new LNumber(0);
|
||||
|
|
|
@ -64,7 +64,7 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
$emptyExprType = $this->getType($negagedExpr->expr);
|
||||
if (!$emptyExprType instanceof ArrayType) {
|
||||
if (!$emptyExprType->isArray()->yes()) {
|
||||
return null;
|
||||
}
|
||||
if (!$node->if instanceof ArrayDimFetch) {
|
||||
|
|
|
@ -108,7 +108,7 @@ CODE_SAMPLE
|
|||
}
|
||||
private function isArray(Expr $expr) : bool
|
||||
{
|
||||
return $this->getType($expr) instanceof ArrayType;
|
||||
return $this->getType($expr)->isArray()->yes();
|
||||
}
|
||||
private function processIdenticalOrNotIdentical(Node $node, FuncCall $funcCall, Expr $expr) : ?Expr
|
||||
{
|
||||
|
|
|
@ -82,7 +82,7 @@ CODE_SAMPLE
|
|||
}
|
||||
// is array?
|
||||
foreach ($staticType->getTypes() as $subType) {
|
||||
if ($subType instanceof ArrayType) {
|
||||
if ($subType->isArray()->yes()) {
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ final class IterableTypeAnalyzer
|
|||
{
|
||||
public function detect(Type $type) : bool
|
||||
{
|
||||
if ($type instanceof ArrayType) {
|
||||
if ($type->isArray()->yes()) {
|
||||
return \true;
|
||||
}
|
||||
if ($type instanceof IterableType) {
|
||||
|
|
|
@ -126,7 +126,7 @@ CODE_SAMPLE
|
|||
}
|
||||
}
|
||||
if (($if->cond instanceof Variable || $this->propertyFetchAnalyzer->isPropertyFetch($if->cond)) && $this->nodeComparator->areNodesEqual($if->cond, $foreachExpr)) {
|
||||
return $scope->getType($if->cond) instanceof ArrayType;
|
||||
return $scope->getType($if->cond)->isArray()->yes();
|
||||
}
|
||||
if ($this->uselessIfCondBeforeForeachDetector->isMatchingNotIdenticalEmptyArray($if, $foreachExpr)) {
|
||||
return \true;
|
||||
|
|
|
@ -61,7 +61,7 @@ final class UselessIfCondBeforeForeachDetector
|
|||
}
|
||||
// is array though?
|
||||
$arrayType = $scope->getType($empty->expr);
|
||||
if (!$arrayType instanceof ArrayType) {
|
||||
if (!$arrayType->isArray()->yes()) {
|
||||
return \false;
|
||||
}
|
||||
$previousParam = $this->fromPreviousParam($foreachExpr);
|
||||
|
|
|
@ -93,7 +93,7 @@ final class TokenManipulator
|
|||
return null;
|
||||
}
|
||||
$tokenStaticType = $this->nodeTypeResolver->getType($node->var);
|
||||
if (!$tokenStaticType instanceof ArrayType) {
|
||||
if (!$tokenStaticType->isArray()->yes()) {
|
||||
return null;
|
||||
}
|
||||
return new PropertyFetch($node->var, 'text');
|
||||
|
@ -113,7 +113,7 @@ final class TokenManipulator
|
|||
return null;
|
||||
}
|
||||
$tokenStaticType = $this->nodeTypeResolver->getType($node->expr);
|
||||
if ($tokenStaticType instanceof ArrayType) {
|
||||
if ($tokenStaticType->isArray()->yes()) {
|
||||
return null;
|
||||
}
|
||||
$node->expr = new PropertyFetch($singleTokenVariable, 'text');
|
||||
|
@ -124,7 +124,7 @@ final class TokenManipulator
|
|||
return null;
|
||||
}
|
||||
$tokenStaticType = $this->nodeTypeResolver->getType($node->expr);
|
||||
if ($tokenStaticType instanceof ArrayType) {
|
||||
if ($tokenStaticType->isArray()->yes()) {
|
||||
return null;
|
||||
}
|
||||
if ($this->assignedNameExpr === null) {
|
||||
|
@ -223,7 +223,7 @@ final class TokenManipulator
|
|||
return null;
|
||||
}
|
||||
$tokenStaticType = $this->nodeTypeResolver->getType($possibleTokenArray->var);
|
||||
if (!$tokenStaticType instanceof ArrayType) {
|
||||
if (!$tokenStaticType->isArray()->yes()) {
|
||||
return null;
|
||||
}
|
||||
if ($possibleTokenArray->dim === null) {
|
||||
|
|
|
@ -220,7 +220,7 @@ CODE_SAMPLE
|
|||
$singleArrayTypes = [];
|
||||
$originalTypeCount = \count($unionType->getTypes());
|
||||
foreach ($unionType->getTypes() as $unionedType) {
|
||||
if ($unionedType instanceof ArrayType) {
|
||||
if ($unionedType->isArray()->yes()) {
|
||||
if ($hasArrayType) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ final class ExactCompareFactory
|
|||
if ($exprType instanceof BooleanType) {
|
||||
return new Identical($expr, $this->nodeFactory->createFalse());
|
||||
}
|
||||
if ($exprType instanceof ArrayType) {
|
||||
if ($exprType->isArray()->yes()) {
|
||||
return new Identical($expr, new Array_([]));
|
||||
}
|
||||
if ($exprType instanceof NullType) {
|
||||
|
@ -71,7 +71,7 @@ final class ExactCompareFactory
|
|||
if ($exprType instanceof IntegerType) {
|
||||
return new NotIdentical($expr, new LNumber(0));
|
||||
}
|
||||
if ($exprType instanceof ArrayType) {
|
||||
if ($exprType->isArray()->yes()) {
|
||||
return new NotIdentical($expr, new Array_([]));
|
||||
}
|
||||
if (!$exprType instanceof UnionType) {
|
||||
|
|
|
@ -71,7 +71,7 @@ final class PropertyTypeDecorator
|
|||
private function isDocBlockRequired(UnionType $unionType) : bool
|
||||
{
|
||||
foreach ($unionType->getTypes() as $unionedType) {
|
||||
if ($unionedType instanceof ArrayType) {
|
||||
if ($unionedType->isArray()->yes()) {
|
||||
$describedArray = $unionedType->describe(VerbosityLevel::value());
|
||||
if ($describedArray !== 'array') {
|
||||
return \true;
|
||||
|
|
|
@ -116,7 +116,7 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
$returnType = $this->nodeTypeResolver->getType($onlyReturn->expr);
|
||||
if (!$returnType instanceof ArrayType) {
|
||||
if (!$returnType->isArray()->yes()) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->nodeNameResolver->areNamesEqual($onlyReturn->expr, $variable)) {
|
||||
|
@ -193,7 +193,7 @@ CODE_SAMPLE
|
|||
// sign of empty array, keep empty
|
||||
return !$exprType->getItemType() instanceof NeverType;
|
||||
}
|
||||
return $exprType instanceof ArrayType;
|
||||
return $exprType->isArray()->yes();
|
||||
}
|
||||
private function narrowConstantArrayType(Type $type) : Type
|
||||
{
|
||||
|
|
|
@ -147,7 +147,7 @@ final class ReturnTypeAlreadyAddedChecker
|
|||
}
|
||||
private function isArrayIterableOrIteratorType(Type $type) : bool
|
||||
{
|
||||
if ($type instanceof ArrayType) {
|
||||
if ($type->isArray()->yes()) {
|
||||
return \true;
|
||||
}
|
||||
if ($type instanceof IterableType) {
|
||||
|
|
|
@ -26,7 +26,7 @@ final class IterableTypeAnalyzer
|
|||
if ($this->isUnionOfIterableTypes($type)) {
|
||||
return \true;
|
||||
}
|
||||
if ($type instanceof ArrayType) {
|
||||
if ($type->isArray()->yes()) {
|
||||
return \true;
|
||||
}
|
||||
if ($type instanceof IterableType) {
|
||||
|
|
|
@ -57,7 +57,7 @@ final class GetterTypeDeclarationPropertyTypeInferer
|
|||
}
|
||||
$returnType = $this->functionLikeReturnTypeResolver->resolveFunctionLikeReturnTypeToPHPStanType($classMethod);
|
||||
// let PhpDoc solve that later for more precise type
|
||||
if ($returnType instanceof ArrayType) {
|
||||
if ($returnType->isArray()->yes()) {
|
||||
return new MixedType();
|
||||
}
|
||||
if (!$returnType instanceof MixedType) {
|
||||
|
|
|
@ -164,7 +164,7 @@ final class TrustedClassMethodPropertyTypeInferer
|
|||
}
|
||||
$types = [];
|
||||
// it's an array - annotation → make type more precise, if possible
|
||||
if ($type instanceof ArrayType || $param->variadic) {
|
||||
if ($type->isArray()->yes() || $param->variadic) {
|
||||
$types[] = $this->getResolveParamStaticTypeAsPHPStanType($classMethod, $propertyName);
|
||||
} else {
|
||||
$types[] = $type;
|
||||
|
|
|
@ -166,7 +166,7 @@ final class TypeNormalizer
|
|||
private function collectNestedArrayTypeFromUnionType(UnionType $unionType, int $arrayNesting) : void
|
||||
{
|
||||
foreach ($unionType->getTypes() as $unionedType) {
|
||||
if ($unionedType instanceof ArrayType) {
|
||||
if ($unionedType->isArray()->yes()) {
|
||||
++$arrayNesting;
|
||||
$this->normalizeArrayOfUnionToUnionArray($unionedType, $arrayNesting);
|
||||
} else {
|
||||
|
|
|
@ -17,12 +17,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'e78e4727d513475187dae0300f78ef70043379f9';
|
||||
public const PACKAGE_VERSION = '04257d3c76ee23722447433f07c8e5678ac9a07b';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-11-15 00:56:37';
|
||||
public const RELEASE_DATE = '2022-11-15 16:18:00';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit80f30366f3ef5661db3ef4c92ea7e59d::getLoader();
|
||||
return ComposerAutoloaderInit7a5c2ce5708b4f9e5bc4336dbe3b529d::getLoader();
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit80f30366f3ef5661db3ef4c92ea7e59d
|
||||
class ComposerAutoloaderInit7a5c2ce5708b4f9e5bc4336dbe3b529d
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInit80f30366f3ef5661db3ef4c92ea7e59d
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit80f30366f3ef5661db3ef4c92ea7e59d', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit7a5c2ce5708b4f9e5bc4336dbe3b529d', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit80f30366f3ef5661db3ef4c92ea7e59d', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit7a5c2ce5708b4f9e5bc4336dbe3b529d', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit80f30366f3ef5661db3ef4c92ea7e59d::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit7a5c2ce5708b4f9e5bc4336dbe3b529d::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit80f30366f3ef5661db3ef4c92ea7e59d::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit7a5c2ce5708b4f9e5bc4336dbe3b529d::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire80f30366f3ef5661db3ef4c92ea7e59d($fileIdentifier, $file);
|
||||
composerRequire7a5c2ce5708b4f9e5bc4336dbe3b529d($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInit80f30366f3ef5661db3ef4c92ea7e59d
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire80f30366f3ef5661db3ef4c92ea7e59d($fileIdentifier, $file)
|
||||
function composerRequire7a5c2ce5708b4f9e5bc4336dbe3b529d($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit80f30366f3ef5661db3ef4c92ea7e59d
|
||||
class ComposerStaticInit7a5c2ce5708b4f9e5bc4336dbe3b529d
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -3032,9 +3032,9 @@ class ComposerStaticInit80f30366f3ef5661db3ef4c92ea7e59d
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit80f30366f3ef5661db3ef4c92ea7e59d::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit80f30366f3ef5661db3ef4c92ea7e59d::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit80f30366f3ef5661db3ef4c92ea7e59d::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit7a5c2ce5708b4f9e5bc4336dbe3b529d::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit7a5c2ce5708b4f9e5bc4336dbe3b529d::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit7a5c2ce5708b4f9e5bc4336dbe3b529d::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user