Updated Rector to commit dbaf0da38ac23091d39d4df71749da474e8df8ac

dbaf0da38a [TypeMapper] Use Identifier instead of Name on non-object types (#3375)
This commit is contained in:
Tomas Votruba 2023-02-13 14:43:04 +00:00
parent 51f97eb7a9
commit e946e57476
18 changed files with 59 additions and 60 deletions

View File

@ -4,7 +4,7 @@ declare (strict_types=1);
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\CallableType;
@ -56,6 +56,6 @@ final class CallableTypeMapper implements TypeMapperInterface
if ($typeKind === TypeKind::PROPERTY) {
return null;
}
return new Name('callable');
return new Identifier('callable');
}
}

View File

@ -4,7 +4,7 @@ declare (strict_types=1);
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\FloatType;
@ -48,6 +48,6 @@ final class FloatTypeMapper implements TypeMapperInterface
if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::SCALAR_TYPES)) {
return null;
}
return new Name('float');
return new Identifier('float');
}
}

View File

@ -4,7 +4,7 @@ declare (strict_types=1);
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\MixedType;
@ -51,6 +51,6 @@ final class MixedTypeMapper implements TypeMapperInterface
if (!$type->isExplicitMixed()) {
return null;
}
return new Name('mixed');
return new Identifier('mixed');
}
}

View File

@ -4,7 +4,7 @@ declare (strict_types=1);
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\NullType;
@ -46,6 +46,6 @@ final class NullTypeMapper implements TypeMapperInterface
if ($typeKind === TypeKind::RETURN) {
return null;
}
return new Name('null');
return new Identifier('null');
}
}

View File

@ -88,19 +88,7 @@ final class ObjectTypeMapper implements TypeMapperInterface
if ($type instanceof NonExistingObjectType) {
return null;
}
if (!$type instanceof GenericObjectType) {
// fallback
return new FullyQualified($type->getClassName());
}
if ($type->getClassName() === 'iterable') {
// fallback
return new Name('iterable');
}
if ($type->getClassName() !== 'object') {
// fallback
return new FullyQualified($type->getClassName());
}
return new Name('object');
return new FullyQualified($type->getClassName());
}
/**
* @required

View File

@ -4,7 +4,7 @@ declare (strict_types=1);
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\StrictMixedType;
@ -38,6 +38,6 @@ final class StrictMixedTypeMapper implements TypeMapperInterface
*/
public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
{
return new Name(self::MIXED);
return new Identifier(self::MIXED);
}
}

View File

@ -226,7 +226,7 @@ final class UnionTypeMapper implements TypeMapperInterface
return $unionTypeAnalysis->hasArray();
}
/**
* @return \PhpParser\Node\Name|\PhpParser\Node\NullableType|PhpParserUnionType|null
* @return \PhpParser\Node\Identifier|\PhpParser\Node\NullableType|PhpParserUnionType|null
*/
private function matchArrayTypes(UnionType $unionType)
{
@ -238,7 +238,7 @@ final class UnionTypeMapper implements TypeMapperInterface
if ($unionTypeAnalysis->isNullableType()) {
return $this->resolveNullableType(new NullableType($type));
}
return new Name($type);
return new Identifier($type);
}
private function resolveUnionTypes(PhpParserUnionType $phpParserUnionType) : ?PhpParserUnionType
{

View File

@ -4,7 +4,7 @@ declare (strict_types=1);
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\Type;
@ -57,6 +57,6 @@ final class VoidTypeMapper implements TypeMapperInterface
if (\in_array($typeKind, [TypeKind::PARAM, TypeKind::PROPERTY], \true)) {
return null;
}
return new Name(self::VOID);
return new Identifier(self::VOID);
}
}

View File

@ -6,7 +6,7 @@ namespace Rector\Php80\Rector\Class_;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Cast\String_ as CastString_;
use PhpParser\Node\Name;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Class_;
@ -112,7 +112,7 @@ CODE_SAMPLE
$node->implements[] = new FullyQualified(self::STRINGABLE);
// add return type
if ($toStringClassMethod->returnType === null) {
$toStringClassMethod->returnType = new Name('string');
$toStringClassMethod->returnType = new Identifier('string');
}
return $node;
}

View File

@ -6,7 +6,7 @@ namespace Rector\TypeDeclaration\Rector\ClassMethod;
use PhpParser\Node;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\Yield_;
use PhpParser\Node\Name;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
@ -92,7 +92,7 @@ CODE_SAMPLE
}
if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::NEVER_TYPE)) {
// never-type supported natively
$node->returnType = new Name('never');
$node->returnType = new Identifier('never');
} else {
// static anlysis based never type
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '7f9704010043e95a107d2a5fd5112fcfc2c2990b';
public const PACKAGE_VERSION = 'dbaf0da38ac23091d39d4df71749da474e8df8ac';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-02-13 16:40:01';
public const RELEASE_DATE = '2023-02-13 14:38:25';
/**
* @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 ComposerAutoloaderInit5e5f692b9734123f7d83eca9c7e54e68::getLoader();
return ComposerAutoloaderInit0f082724dd1f330f7743b697dfe202a2::getLoader();

View File

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

View File

@ -1982,12 +1982,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "c7bd7e5f22f38e585d57dbb6eb73941b8beafed6"
"reference": "13e842b8c9edc12c0aca1c6341d7860aab523fef"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/c7bd7e5f22f38e585d57dbb6eb73941b8beafed6",
"reference": "c7bd7e5f22f38e585d57dbb6eb73941b8beafed6",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/13e842b8c9edc12c0aca1c6341d7860aab523fef",
"reference": "13e842b8c9edc12c0aca1c6341d7860aab523fef",
"shasum": ""
},
"require": {
@ -2016,7 +2016,7 @@
"tomasvotruba\/type-coverage": "^0.0.9",
"tomasvotruba\/unused-public": "^0.0.34"
},
"time": "2023-02-11T12:06:37+00:00",
"time": "2023-02-13T12:48:08+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main ea9cf46'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main fc1c39f'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main c7bd7e5'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 60b36cc'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main ea9cf46'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main fc1c39f'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 13e842b'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 60b36cc'));
private function __construct()
{
}

View File

@ -55,6 +55,26 @@ final class DataProviderClassMethodFinder
}
return $dataProviderClassMethods;
}
/**
* @api
* @return string[]
*/
public function findDataProviderNamesForClassMethod(ClassMethod $classMethod) : array
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);
$dataProviderTagValueNodes = $phpDocInfo->getTagsByName('dataProvider');
if ($dataProviderTagValueNodes === []) {
return [];
}
$dataProviderMethodNames = [];
foreach ($dataProviderTagValueNodes as $dataProviderTagValueNode) {
if (!$dataProviderTagValueNode->value instanceof GenericTagValueNode) {
continue;
}
$dataProviderMethodNames[] = $this->resolveMethodName($dataProviderTagValueNode->value);
}
return $dataProviderMethodNames;
}
/**
* @return string[]
*/
@ -62,17 +82,8 @@ final class DataProviderClassMethodFinder
{
$dataProviderMethodNames = [];
foreach ($class->getMethods() as $classMethod) {
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);
$dataProviderTagValueNodes = $phpDocInfo->getTagsByName('dataProvider');
if ($dataProviderTagValueNodes === []) {
continue;
}
foreach ($dataProviderTagValueNodes as $dataProviderTagValueNode) {
if (!$dataProviderTagValueNode->value instanceof GenericTagValueNode) {
continue;
}
$dataProviderMethodNames[] = $this->resolveMethodName($dataProviderTagValueNode->value);
}
$currentDataProviderMethodNames = $this->findDataProviderNamesForClassMethod($classMethod);
$dataProviderMethodNames = \array_merge($dataProviderMethodNames, $currentDataProviderMethodNames);
}
return $dataProviderMethodNames;
}