mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit 54cc8e7a839343023a10a4ee230b9973dd03c376
54cc8e7a83
[CodeQuality] Skip nullable mixed on ReturnTypeFromStrictScalarReturnExprRector (#2947)
This commit is contained in:
parent
9fc996728a
commit
465ae70f0e
@ -140,6 +140,13 @@ final class UnionTypeMapper implements TypeMapperInterface
|
||||
// use first unioned type in case of unioned object types
|
||||
return $this->matchTypeForUnionedObjectTypes($type, $typeKind);
|
||||
}
|
||||
return $this->mapNullabledType($nullabledType, $typeKind);
|
||||
}
|
||||
/**
|
||||
* @param TypeKind::* $typeKind
|
||||
*/
|
||||
private function mapNullabledType(Type $nullabledType, string $typeKind) : ?Node
|
||||
{
|
||||
// void cannot be nullable
|
||||
if ($nullabledType instanceof VoidType) {
|
||||
return null;
|
||||
@ -152,7 +159,7 @@ final class UnionTypeMapper implements TypeMapperInterface
|
||||
return $nullabledTypeNode;
|
||||
}
|
||||
/** @var Name $nullabledTypeNode */
|
||||
if (!$this->nodeNameResolver->isName($nullabledTypeNode, 'false')) {
|
||||
if (!$this->nodeNameResolver->isNames($nullabledTypeNode, ['false', 'mixed'])) {
|
||||
return new NullableType($nullabledTypeNode);
|
||||
}
|
||||
return null;
|
||||
|
@ -17,6 +17,7 @@ use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\Native\NativeFunctionReflection;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use PHPStan\Type\BooleanType;
|
||||
use PHPStan\Type\Constant\ConstantStringType;
|
||||
use PHPStan\Type\FloatType;
|
||||
use PHPStan\Type\IntegerType;
|
||||
use PHPStan\Type\NullType;
|
||||
@ -51,10 +52,33 @@ final class AlwaysStrictScalarExprAnalyzer
|
||||
return null;
|
||||
}
|
||||
if ($expr instanceof FuncCall) {
|
||||
return $this->resolveFuncCallType($expr);
|
||||
$returnType = $this->resolveFuncCallType($expr);
|
||||
if ($returnType === null) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isScalarType($returnType)) {
|
||||
return null;
|
||||
}
|
||||
return $returnType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private function isScalarType(Type $type) : bool
|
||||
{
|
||||
if ($type instanceof StringType && !$type instanceof ConstantStringType) {
|
||||
return \true;
|
||||
}
|
||||
if ($type instanceof FloatType) {
|
||||
return \true;
|
||||
}
|
||||
if ($type instanceof IntegerType) {
|
||||
return \true;
|
||||
}
|
||||
if ($type instanceof BooleanType) {
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
private function resolveTypeFromScalar(Scalar $scalar) : ?\PHPStan\Type\Type
|
||||
{
|
||||
if ($scalar instanceof String_) {
|
||||
|
@ -17,12 +17,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'df36e385def96b447520c35e341e46e16cbffb56';
|
||||
public const PACKAGE_VERSION = '54cc8e7a839343023a10a4ee230b9973dd03c376';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-09-23 10:40:42';
|
||||
public const RELEASE_DATE = '2022-09-23 14:59:11';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderIniteb1a4d23182d7d3e5a5f84f5ed6003ab::getLoader();
|
||||
return ComposerAutoloaderInita2b31b9158f64e76ddef912f18cd5d8a::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 ComposerAutoloaderIniteb1a4d23182d7d3e5a5f84f5ed6003ab
|
||||
class ComposerAutoloaderInita2b31b9158f64e76ddef912f18cd5d8a
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,19 +22,19 @@ class ComposerAutoloaderIniteb1a4d23182d7d3e5a5f84f5ed6003ab
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderIniteb1a4d23182d7d3e5a5f84f5ed6003ab', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInita2b31b9158f64e76ddef912f18cd5d8a', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderIniteb1a4d23182d7d3e5a5f84f5ed6003ab', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInita2b31b9158f64e76ddef912f18cd5d8a', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticIniteb1a4d23182d7d3e5a5f84f5ed6003ab::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInita2b31b9158f64e76ddef912f18cd5d8a::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticIniteb1a4d23182d7d3e5a5f84f5ed6003ab::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInita2b31b9158f64e76ddef912f18cd5d8a::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequireeb1a4d23182d7d3e5a5f84f5ed6003ab($fileIdentifier, $file);
|
||||
composerRequirea2b31b9158f64e76ddef912f18cd5d8a($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -46,7 +46,7 @@ class ComposerAutoloaderIniteb1a4d23182d7d3e5a5f84f5ed6003ab
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequireeb1a4d23182d7d3e5a5f84f5ed6003ab($fileIdentifier, $file)
|
||||
function composerRequirea2b31b9158f64e76ddef912f18cd5d8a($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 ComposerStaticIniteb1a4d23182d7d3e5a5f84f5ed6003ab
|
||||
class ComposerStaticInita2b31b9158f64e76ddef912f18cd5d8a
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3107,9 +3107,9 @@ class ComposerStaticIniteb1a4d23182d7d3e5a5f84f5ed6003ab
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticIniteb1a4d23182d7d3e5a5f84f5ed6003ab::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticIniteb1a4d23182d7d3e5a5f84f5ed6003ab::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticIniteb1a4d23182d7d3e5a5f84f5ed6003ab::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInita2b31b9158f64e76ddef912f18cd5d8a::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInita2b31b9158f64e76ddef912f18cd5d8a::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInita2b31b9158f64e76ddef912f18cd5d8a::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user