Updated Rector to commit 2e0ce286cb84cc202d17b293de3d59f89b9c4112

2e0ce286cb Make use of toPhpDocNode() - take #5 (#4567)
This commit is contained in:
Tomas Votruba 2023-07-21 11:06:18 +00:00
parent 2225eba547
commit 62fb16f0e0
11 changed files with 28 additions and 42 deletions

View File

@ -22,7 +22,6 @@ use Rector\Core\ValueObject\Application\File;
use Rector\PhpDocParser\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
use Rector\PostRector\Collector\UseNodesToAddCollector;
use Rector\StaticTypeMapper\PhpDocParser\IdentifierTypeMapper;
use Rector\StaticTypeMapper\StaticTypeMapper;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
final class NameImportingPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
{

View File

@ -44,22 +44,7 @@ final class ObjectWithoutClassTypeMapper implements TypeMapperInterface
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
if ($type instanceof ParentObjectWithoutClassType) {
return new IdentifierTypeNode('parent');
}
if ($type instanceof TemplateObjectWithoutClassType) {
$attributeAwareIdentifierTypeNode = new IdentifierTypeNode($type->getName());
return new EmptyGenericTypeNode($attributeAwareIdentifierTypeNode);
}
// special case for anonymous classes that implement another type
if ($type instanceof ObjectWithoutClassTypeWithParentTypes) {
$parentTypes = $type->getParentTypes();
if (\count($parentTypes) === 1) {
$parentType = $parentTypes[0];
return new FullyQualifiedIdentifierTypeNode($parentType->getClassName());
}
}
return new IdentifierTypeNode('object');
return $type->toPhpDocNode();
}
/**
* @param ObjectWithoutClassType $type

View File

@ -72,16 +72,16 @@ final class IdentifierTypeMapper implements PhpDocTypeMapperInterface
{
return $this->mapIdentifierTypeNode($typeNode, $node);
}
public function mapIdentifierTypeNode(IdentifierTypeNode $typeNode, Node $node) : Type
public function mapIdentifierTypeNode(IdentifierTypeNode $identifierTypeNode, Node $node) : Type
{
$type = $this->scalarStringToTypeMapper->mapScalarStringToType($typeNode->name);
$type = $this->scalarStringToTypeMapper->mapScalarStringToType($identifierTypeNode->name);
if (!$type instanceof MixedType) {
return $type;
}
if ($type->isExplicitMixed()) {
return $type;
}
$loweredName = \strtolower($typeNode->name);
$loweredName = \strtolower($identifierTypeNode->name);
if ($loweredName === ObjectReference::SELF) {
return $this->mapSelf($node);
}
@ -94,16 +94,16 @@ final class IdentifierTypeMapper implements PhpDocTypeMapperInterface
if ($loweredName === 'iterable') {
return new IterableType(new MixedType(), new MixedType());
}
if (\strncmp($typeNode->name, '\\', \strlen('\\')) === 0) {
$typeWithoutPreslash = Strings::substring($typeNode->name, 1);
if (\strncmp($identifierTypeNode->name, '\\', \strlen('\\')) === 0) {
$typeWithoutPreslash = Strings::substring($identifierTypeNode->name, 1);
$objectType = new FullyQualifiedObjectType($typeWithoutPreslash);
} else {
if ($typeNode->name === 'scalar') {
if ($identifierTypeNode->name === 'scalar') {
// pseudo type, see https://www.php.net/manual/en/language.types.intro.php
$scalarTypes = [new BooleanType(), new StringType(), new IntegerType(), new FloatType()];
return new UnionType($scalarTypes);
}
$objectType = new ObjectType($typeNode->name);
$objectType = new ObjectType($identifierTypeNode->name);
}
$scope = $node->getAttribute(AttributeKey::SCOPE);
return $this->objectTypeSpecifier->narrowToFullyQualifiedOrAliasedObjectType($node, $objectType, $scope);

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'efce1c7da2937d77c41a842c64beea88c5336bbe';
public const PACKAGE_VERSION = '2e0ce286cb84cc202d17b293de3d59f89b9c4112';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-07-21 17:09:51';
public const RELEASE_DATE = '2023-07-21 12:01:36';
/**
* @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 ComposerAutoloaderInit243ba83393c3c545edf433d48b181c31::getLoader();
return ComposerAutoloaderInit895486b46c670099b8b791aac58436b0::getLoader();

View File

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

View File

@ -1985,12 +1985,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "04d257db9280e12ca66dc7747134acc43bd81d2d"
"reference": "26e8bb4921fa8685dee87f5bdb8be481961236f3"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/04d257db9280e12ca66dc7747134acc43bd81d2d",
"reference": "04d257db9280e12ca66dc7747134acc43bd81d2d",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/26e8bb4921fa8685dee87f5bdb8be481961236f3",
"reference": "26e8bb4921fa8685dee87f5bdb8be481961236f3",
"shasum": ""
},
"require": {
@ -2010,11 +2010,12 @@
"symplify\/phpstan-rules": "^11.4",
"symplify\/rule-doc-generator": "^11.2",
"symplify\/vendor-patches": "^11.2",
"tomasvotruba\/class-leak": "0.0.22.72",
"tomasvotruba\/cognitive-complexity": "^0.1",
"tomasvotruba\/type-coverage": "^0.2",
"tomasvotruba\/unused-public": "^0.1"
},
"time": "2023-07-20T22:18:50+00:00",
"time": "2023-07-21T10:25:40+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 2d14418'), '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 04d257d'), '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 87b593f'), '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 a0af12a'));
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 2d14418'), '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 26e8bb4'), '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 87b593f'), '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 a0af12a'));
private function __construct()
{
}

View File

@ -20,6 +20,7 @@
"symplify\/phpstan-rules": "^11.4",
"symplify\/rule-doc-generator": "^11.2",
"symplify\/vendor-patches": "^11.2",
"tomasvotruba\/class-leak": "0.0.22.72",
"tomasvotruba\/cognitive-complexity": "^0.1",
"tomasvotruba\/type-coverage": "^0.2",
"tomasvotruba\/unused-public": "^0.1"