Updated Rector to commit a6ca5a0e8429d8c1423916c07ba5e72efdeafd44

a6ca5a0e84 Re-apply isVoid() (#3574) (#3586)
This commit is contained in:
Tomas Votruba 2023-04-08 14:00:36 +00:00
parent cfc4527dfc
commit 470e7f2c55
11 changed files with 25 additions and 24 deletions

View File

@ -204,7 +204,7 @@ final class UnionTypeMapper implements TypeMapperInterface
private function mapNullabledType(Type $nullabledType, string $typeKind) : ?Node
{
// void cannot be nullable
if ($nullabledType instanceof VoidType) {
if ($nullabledType->isVoid()->yes()) {
return null;
}
$nullabledTypeNode = $this->phpStanStaticTypeMapper->mapToPhpParserNode($nullabledType, $typeKind);

View File

@ -13,7 +13,6 @@ use PHPStan\Reflection\FunctionVariantWithPhpDocs;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\MixedType;
use PHPStan\Type\VoidType;
use Rector\Core\FileSystem\FilePathHelper;
use Rector\Core\PhpParser\AstResolver;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
@ -186,9 +185,13 @@ final class ClassMethodReturnTypeOverrideGuard
return \true;
}
$childReturnType = $this->returnTypeInferer->inferFunctionLike($method);
if ($returnType instanceof VoidType && !$childReturnType instanceof VoidType) {
return \true;
if (!$returnType->isVoid()->yes()) {
continue;
}
if ($childReturnType->isVoid()->yes()) {
continue;
}
return \true;
}
return \false;
}

View File

@ -360,7 +360,7 @@ final class AnonymousFunctionFactory
*/
private function resolveStmts(FunctionVariantWithPhpDocs $functionVariantWithPhpDocs, $innerMethodCall) : array
{
if ($functionVariantWithPhpDocs->getReturnType() instanceof VoidType) {
if ($functionVariantWithPhpDocs->getReturnType()->isVoid()->yes()) {
return [new Expression($innerMethodCall)];
}
return [new Return_($innerMethodCall)];

View File

@ -5,7 +5,6 @@ namespace Rector\TypeDeclaration\Rector\ArrowFunction;
use PhpParser\Node;
use PhpParser\Node\Expr\ArrowFunction;
use PHPStan\Type\VoidType;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
@ -43,7 +42,7 @@ CODE_SAMPLE
return null;
}
$type = $this->getType($node->expr);
if ($type instanceof VoidType) {
if ($type->isVoid()->yes()) {
return null;
}
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::RETURN);

View File

@ -19,7 +19,6 @@ use PhpParser\Node\UnionType as PhpParserUnionType;
use PHPStan\Type\NullType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\UnionType;
use PHPStan\Type\VoidType;
use Rector\Core\Php\PhpVersionProvider;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
@ -153,7 +152,7 @@ CODE_SAMPLE
{
$resolvedType = $this->nodeTypeResolver->getType($arrowFunction->expr);
// void type is not accepted for arrow functions - https://www.php.net/manual/en/functions.arrow.php#125673
if ($resolvedType instanceof VoidType) {
if ($resolvedType->isVoid()->yes()) {
return null;
}
$returnType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($resolvedType, TypeKind::RETURN);
@ -171,7 +170,7 @@ CODE_SAMPLE
$inferReturnType = $this->returnTypeInferer->inferFunctionLike($node);
if ($inferReturnType instanceof UnionType) {
foreach ($inferReturnType->getTypes() as $type) {
if ($type instanceof VoidType) {
if ($type->isVoid()->yes()) {
return \true;
}
}

View File

@ -146,7 +146,7 @@ final class ReturnTypeInferer
*/
private function resolveTypeWithVoidHandling($functionLike, Type $resolvedType) : Type
{
if ($resolvedType instanceof VoidType) {
if ($resolvedType->isVoid()->yes()) {
if ($functionLike instanceof ArrowFunction) {
return new MixedType();
}

View File

@ -188,7 +188,7 @@ final class ReturnedNodesReturnTypeInfererTypeInferer
if ($resolvedType instanceof MixedType || $this->isArrayTypeMixed($resolvedType)) {
$correctedType = $this->inferFromReturnedMethodCall($return, $functionLike);
// override only if has some extra value
if (!$correctedType instanceof MixedType && !$correctedType instanceof VoidType) {
if (!$correctedType instanceof MixedType && !$correctedType->isVoid()->yes()) {
return $correctedType;
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '77a3c02e661dfd842550aa0597f871bd76e57a13';
public const PACKAGE_VERSION = 'a6ca5a0e8429d8c1423916c07ba5e72efdeafd44';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-04-08 13:28:10';
public const RELEASE_DATE = '2023-04-08 20:56:34';
/**
* @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 ComposerAutoloaderInit51babc95d519dc65fb38446d8e6b76c5::getLoader();
return ComposerAutoloaderInitae801d21aa72af266cc7eac6f82f933f::getLoader();

View File

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