Updated Rector to commit d916d486bc

d916d486bc [DowngradePhp54] Add DowngradeStaticClosureRector (#1037)
This commit is contained in:
Tomas Votruba 2021-10-21 18:43:06 +00:00
parent 81b8ebf250
commit f3927bad9a
11 changed files with 102 additions and 20 deletions

View File

@ -9,7 +9,7 @@ use Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$parameters = $containerConfigurator->parameters();
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_53);
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_52);
$services = $containerConfigurator->services();
$services->set(\Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector::class);
};

View File

@ -0,0 +1,15 @@
<?php
declare (strict_types=1);
namespace RectorPrefix20211021;
use Rector\Core\Configuration\Option;
use Rector\Core\ValueObject\PhpVersion;
use Rector\DowngradePhp54\Rector\Closure\DowngradeStaticClosureRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$parameters = $containerConfigurator->parameters();
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_53);
$services = $containerConfigurator->services();
$services->set(\Rector\DowngradePhp54\Rector\Closure\DowngradeStaticClosureRector::class);
};

View File

@ -10,6 +10,10 @@ final class DowngradeSetList implements \Rector\Set\Contract\SetListInterface
* @var string
*/
public const PHP_53 = __DIR__ . '/../../../config/set/downgrade-php53.php';
/**
* @var string
*/
public const PHP_54 = __DIR__ . '/../../../config/set/downgrade-php54.php';
/**
* @var string
*/

View File

@ -0,0 +1,60 @@
<?php
declare (strict_types=1);
namespace Rector\DowngradePhp54\Rector\Closure;
use PhpParser\Node;
use PhpParser\Node\Expr\Closure;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\DowngradePhp54\Rector\Closure\DowngradeStaticClosureRector\DowngradeStaticClosureRectorTest
*/
final class DowngradeStaticClosureRector extends \Rector\Core\Rector\AbstractRector
{
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove static from closure', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
final class SomeClass
{
public function run()
{
return static function () {
return true;
};
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
final class SomeClass
{
public function run()
{
return function () {
return true;
};
}
}
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [\PhpParser\Node\Expr\Closure::class];
}
/**
* @param Closure $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
if (!$node->static) {
return null;
}
$node->static = \false;
return $node;
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '831aca46a3bfc6d4d937746aac50361f40e64db3';
public const PACKAGE_VERSION = 'd916d486bc7da8f8d7593b33f8a1c59cac78c31c';
/**
* @var string
*/
public const RELEASE_DATE = '2021-10-22 00:40:24';
public const RELEASE_DATE = '2021-10-21 20:29:05';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211021\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

View File

@ -9,6 +9,7 @@ use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\Property;
use PHPStan\Reflection\ReflectionProvider;
use Rector\Core\NodeAnalyzer\ClassAnalyzer;

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit62a37ef5dc803d3cf5b56df3615322b2::getLoader();
return ComposerAutoloaderInit3992ef5d303d6b8c9a359940bbf283f2::getLoader();

View File

@ -2148,6 +2148,7 @@ return array(
'Rector\\Doctrine\\ValueObject\\PropertyNameAndPhpDocInfo' => $vendorDir . '/rector/rector-doctrine/src/ValueObject/PropertyNameAndPhpDocInfo.php',
'Rector\\Doctrine\\ValueObject\\PropertyNamesAndPhpDocInfos' => $vendorDir . '/rector/rector-doctrine/src/ValueObject/PropertyNamesAndPhpDocInfos.php',
'Rector\\DowngradePhp53\\Rector\\Dir\\DirConstToFileConstRector' => $baseDir . '/rules/DowngradePhp53/Rector/Dir/DirConstToFileConstRector.php',
'Rector\\DowngradePhp54\\Rector\\Closure\\DowngradeStaticClosureRector' => $baseDir . '/rules/DowngradePhp54/Rector/Closure/DowngradeStaticClosureRector.php',
'Rector\\DowngradePhp70\\NodeFactory\\ClassFromAnonymousFactory' => $baseDir . '/rules/DowngradePhp70/NodeFactory/ClassFromAnonymousFactory.php',
'Rector\\DowngradePhp70\\Rector\\ClassMethod\\DowngradeParentTypeDeclarationRector' => $baseDir . '/rules/DowngradePhp70/Rector/ClassMethod/DowngradeParentTypeDeclarationRector.php',
'Rector\\DowngradePhp70\\Rector\\ClassMethod\\DowngradeSelfTypeDeclarationRector' => $baseDir . '/rules/DowngradePhp70/Rector/ClassMethod/DowngradeSelfTypeDeclarationRector.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit62a37ef5dc803d3cf5b56df3615322b2
class ComposerAutoloaderInit3992ef5d303d6b8c9a359940bbf283f2
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit62a37ef5dc803d3cf5b56df3615322b2
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit62a37ef5dc803d3cf5b56df3615322b2', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit3992ef5d303d6b8c9a359940bbf283f2', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit62a37ef5dc803d3cf5b56df3615322b2', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit3992ef5d303d6b8c9a359940bbf283f2', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit62a37ef5dc803d3cf5b56df3615322b2::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit3992ef5d303d6b8c9a359940bbf283f2::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit62a37ef5dc803d3cf5b56df3615322b2
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit62a37ef5dc803d3cf5b56df3615322b2::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit3992ef5d303d6b8c9a359940bbf283f2::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire62a37ef5dc803d3cf5b56df3615322b2($fileIdentifier, $file);
composerRequire3992ef5d303d6b8c9a359940bbf283f2($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire62a37ef5dc803d3cf5b56df3615322b2($fileIdentifier, $file)
function composerRequire3992ef5d303d6b8c9a359940bbf283f2($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit62a37ef5dc803d3cf5b56df3615322b2
class ComposerStaticInit3992ef5d303d6b8c9a359940bbf283f2
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -2508,6 +2508,7 @@ class ComposerStaticInit62a37ef5dc803d3cf5b56df3615322b2
'Rector\\Doctrine\\ValueObject\\PropertyNameAndPhpDocInfo' => __DIR__ . '/..' . '/rector/rector-doctrine/src/ValueObject/PropertyNameAndPhpDocInfo.php',
'Rector\\Doctrine\\ValueObject\\PropertyNamesAndPhpDocInfos' => __DIR__ . '/..' . '/rector/rector-doctrine/src/ValueObject/PropertyNamesAndPhpDocInfos.php',
'Rector\\DowngradePhp53\\Rector\\Dir\\DirConstToFileConstRector' => __DIR__ . '/../..' . '/rules/DowngradePhp53/Rector/Dir/DirConstToFileConstRector.php',
'Rector\\DowngradePhp54\\Rector\\Closure\\DowngradeStaticClosureRector' => __DIR__ . '/../..' . '/rules/DowngradePhp54/Rector/Closure/DowngradeStaticClosureRector.php',
'Rector\\DowngradePhp70\\NodeFactory\\ClassFromAnonymousFactory' => __DIR__ . '/../..' . '/rules/DowngradePhp70/NodeFactory/ClassFromAnonymousFactory.php',
'Rector\\DowngradePhp70\\Rector\\ClassMethod\\DowngradeParentTypeDeclarationRector' => __DIR__ . '/../..' . '/rules/DowngradePhp70/Rector/ClassMethod/DowngradeParentTypeDeclarationRector.php',
'Rector\\DowngradePhp70\\Rector\\ClassMethod\\DowngradeSelfTypeDeclarationRector' => __DIR__ . '/../..' . '/rules/DowngradePhp70/Rector/ClassMethod/DowngradeSelfTypeDeclarationRector.php',
@ -3909,9 +3910,9 @@ class ComposerStaticInit62a37ef5dc803d3cf5b56df3615322b2
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit62a37ef5dc803d3cf5b56df3615322b2::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit62a37ef5dc803d3cf5b56df3615322b2::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit62a37ef5dc803d3cf5b56df3615322b2::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit3992ef5d303d6b8c9a359940bbf283f2::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit3992ef5d303d6b8c9a359940bbf283f2::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit3992ef5d303d6b8c9a359940bbf283f2::$classMap;
}, null, ClassLoader::class);
}

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20211021\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit62a37ef5dc803d3cf5b56df3615322b2', false) && !interface_exists('ComposerAutoloaderInit62a37ef5dc803d3cf5b56df3615322b2', false) && !trait_exists('ComposerAutoloaderInit62a37ef5dc803d3cf5b56df3615322b2', false)) {
spl_autoload_call('RectorPrefix20211021\ComposerAutoloaderInit62a37ef5dc803d3cf5b56df3615322b2');
if (!class_exists('ComposerAutoloaderInit3992ef5d303d6b8c9a359940bbf283f2', false) && !interface_exists('ComposerAutoloaderInit3992ef5d303d6b8c9a359940bbf283f2', false) && !trait_exists('ComposerAutoloaderInit3992ef5d303d6b8c9a359940bbf283f2', false)) {
spl_autoload_call('RectorPrefix20211021\ComposerAutoloaderInit3992ef5d303d6b8c9a359940bbf283f2');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20211021\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -3306,9 +3306,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20211021\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire62a37ef5dc803d3cf5b56df3615322b2')) {
function composerRequire62a37ef5dc803d3cf5b56df3615322b2() {
return \RectorPrefix20211021\composerRequire62a37ef5dc803d3cf5b56df3615322b2(...func_get_args());
if (!function_exists('composerRequire3992ef5d303d6b8c9a359940bbf283f2')) {
function composerRequire3992ef5d303d6b8c9a359940bbf283f2() {
return \RectorPrefix20211021\composerRequire3992ef5d303d6b8c9a359940bbf283f2(...func_get_args());
}
}
if (!function_exists('parseArgs')) {