Skip to content

Commit

Permalink
Updated Rector to commit 54cc8e7a839343023a10a4ee230b9973dd03c376
Browse files Browse the repository at this point in the history
rectorphp/rector-src@54cc8e7 [CodeQuality] Skip nullable mixed on ReturnTypeFromStrictScalarReturnExprRector (#2947)
  • Loading branch information
TomasVotruba committed Sep 23, 2022
1 parent 9fc9967 commit 465ae70
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
// 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;
Expand All @@ -152,7 +159,7 @@ public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
return $nullabledTypeNode;
}
/** @var Name $nullabledTypeNode */
if (!$this->nodeNameResolver->isName($nullabledTypeNode, 'false')) {
if (!$this->nodeNameResolver->isNames($nullabledTypeNode, ['false', 'mixed'])) {
return new NullableType($nullabledTypeNode);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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;
Expand Down Expand Up @@ -51,10 +52,33 @@ public function matchStrictScalarExpr(Expr $expr) : ?Type
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_) {
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderIniteb1a4d23182d7d3e5a5f84f5ed6003ab::getLoader();
return ComposerAutoloaderInita2b31b9158f64e76ddef912f18cd5d8a::getLoader();
14 changes: 7 additions & 7 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderIniteb1a4d23182d7d3e5a5f84f5ed6003ab
class ComposerAutoloaderInita2b31b9158f64e76ddef912f18cd5d8a
{
private static $loader;

Expand All @@ -22,19 +22,19 @@ public static function getLoader()
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;
Expand All @@ -46,7 +46,7 @@ public static function getLoader()
* @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;
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticIniteb1a4d23182d7d3e5a5f84f5ed6003ab
class ComposerStaticInita2b31b9158f64e76ddef912f18cd5d8a
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 465ae70

Please sign in to comment.