Updated Rector to commit 076642f73eee5814a096552c33b28740fbbd48ce

076642f73e [Scoper] Remove manual register DowngradeEnumToConstantListClassRector on config-downgrade.php (#3138)
This commit is contained in:
Tomas Votruba 2022-12-02 12:41:23 +00:00
parent 91f18482f3
commit 9181dd5876
8 changed files with 47 additions and 25 deletions

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit55970196bbd8338c66afbe01bdac3ec6::getLoader();
return ComposerAutoloaderInitbf8a8e464cc895d60afec03925ee6642::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit55970196bbd8338c66afbe01bdac3ec6
class ComposerAutoloaderInitbf8a8e464cc895d60afec03925ee6642
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit55970196bbd8338c66afbe01bdac3ec6
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit55970196bbd8338c66afbe01bdac3ec6', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitbf8a8e464cc895d60afec03925ee6642', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit55970196bbd8338c66afbe01bdac3ec6', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitbf8a8e464cc895d60afec03925ee6642', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit55970196bbd8338c66afbe01bdac3ec6::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitbf8a8e464cc895d60afec03925ee6642::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit55970196bbd8338c66afbe01bdac3ec6::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInitbf8a8e464cc895d60afec03925ee6642::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire55970196bbd8338c66afbe01bdac3ec6($fileIdentifier, $file);
composerRequirebf8a8e464cc895d60afec03925ee6642($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit55970196bbd8338c66afbe01bdac3ec6
* @param string $file
* @return void
*/
function composerRequire55970196bbd8338c66afbe01bdac3ec6($fileIdentifier, $file)
function composerRequirebf8a8e464cc895d60afec03925ee6642($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 ComposerStaticInit55970196bbd8338c66afbe01bdac3ec6
class ComposerStaticInitbf8a8e464cc895d60afec03925ee6642
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3047,9 +3047,9 @@ class ComposerStaticInit55970196bbd8338c66afbe01bdac3ec6
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit55970196bbd8338c66afbe01bdac3ec6::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit55970196bbd8338c66afbe01bdac3ec6::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit55970196bbd8338c66afbe01bdac3ec6::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitbf8a8e464cc895d60afec03925ee6642::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitbf8a8e464cc895d60afec03925ee6642::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitbf8a8e464cc895d60afec03925ee6642::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1849,12 +1849,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "d64a1239d1b151ab4f3705eeaec42e24f080ef34"
"reference": "24f2eaebcf6e0ea5ebe2842c212a98b6dfd2d449"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/d64a1239d1b151ab4f3705eeaec42e24f080ef34",
"reference": "d64a1239d1b151ab4f3705eeaec42e24f080ef34",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/24f2eaebcf6e0ea5ebe2842c212a98b6dfd2d449",
"reference": "24f2eaebcf6e0ea5ebe2842c212a98b6dfd2d449",
"shasum": ""
},
"require": {
@ -1880,7 +1880,7 @@
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
},
"time": "2022-12-02T12:14:30+00:00",
"time": "2022-12-02T12:35:58+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 bf394ee'), '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 d64a123'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9ea5f62'), '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 e646c56'), '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 caa1373'));
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 bf394ee'), '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 24f2eae'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9ea5f62'), '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 e646c56'), '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 caa1373'));
private function __construct()
{
}

View File

@ -4,7 +4,9 @@ declare (strict_types=1);
namespace Rector\DowngradePhp80\Rector\Enum_;
use PhpParser\Node;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\NullableType;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
@ -12,6 +14,7 @@ use PhpParser\Node\Stmt\Enum_;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\ConstTypeNode;
use PHPStan\PhpDocParser\Ast\Type\NullableTypeNode;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
@ -85,11 +88,18 @@ CODE_SAMPLE
$hasChanged = \false;
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
foreach ($node->params as $param) {
if (!$param->type instanceof Name) {
if ($param->type instanceof Name) {
$paramType = $param->type;
$isNullable = \false;
} elseif ($param->type instanceof NullableType) {
$paramType = $param->type->type;
$isNullable = \true;
} else {
continue;
}
// is enum type?
$typeName = $this->getName($param->type);
/** @var string $typeName */
$typeName = $this->getName($paramType);
if (!$this->reflectionProvider->hasClass($typeName)) {
continue;
}
@ -97,21 +107,32 @@ CODE_SAMPLE
if (!$classLikeReflection->isEnum()) {
continue;
}
$param->type = $this->enumAnalyzer->resolveType($classLikeReflection);
$this->refactorParamType($classLikeReflection, $isNullable, $param);
$hasChanged = \true;
$this->decorateParamDocType($classLikeReflection, $param, $phpDocInfo);
$this->decorateParamDocType($classLikeReflection, $param, $phpDocInfo, $isNullable);
}
if ($hasChanged) {
return $node;
}
return null;
}
private function decorateParamDocType(ClassReflection $classReflection, Param $param, PhpDocInfo $phpDocInfo) : void
private function decorateParamDocType(ClassReflection $classReflection, Param $param, PhpDocInfo $phpDocInfo, bool $isNullable) : void
{
$constFetchNode = new ConstFetchNode('\\' . $classReflection->getName(), '*');
$constTypeNode = new ConstTypeNode($constFetchNode);
$paramName = '$' . $this->getName($param);
$paramTagValueNode = new ParamTagValueNode($constTypeNode, \false, $paramName, '');
$paramTypeNode = $isNullable ? new NullableTypeNode($constTypeNode) : $constTypeNode;
$paramTagValueNode = new ParamTagValueNode($paramTypeNode, \false, $paramName, '');
$phpDocInfo->addTagValueNode($paramTagValueNode);
}
private function refactorParamType(ClassReflection $classReflection, bool $isNullable, Param $param) : void
{
$identifier = $this->enumAnalyzer->resolveType($classReflection);
if ($identifier instanceof Identifier) {
$param->type = $isNullable ? new NullableType($identifier) : new Name($identifier->name);
} else {
// remove type as ambiguous
$param->type = null;
}
}
}

View File

@ -69,8 +69,9 @@ class Terminal
}
/**
* Force a terminal color mode rendering.
* @param ?\Symfony\Component\Console\Output\AnsiColorMode::* $colorMode
*/
public static function setColorMode(?AnsiColorMode $colorMode) : void
public static function setColorMode(?string $colorMode) : void
{
self::$colorMode = $colorMode;
}