Updated Rector to commit 38b1d4d192

38b1d4d192 Implement DowngradeAbstractPrivateMethodInTrait (#615)
This commit is contained in:
Tomas Votruba 2021-08-08 16:58:46 +00:00
parent 71c00f366f
commit 73fdd01a3b
9 changed files with 95 additions and 19 deletions

View File

@ -9,6 +9,7 @@ use Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector;
use Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector;
use Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector;
use Rector\DowngradePhp80\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector;
use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeAbstractPrivateMethodInTraitRector;
use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector;
use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeTrailingCommasInParamUseRector;
use Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector;
@ -45,6 +46,7 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
$services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector::class);
$services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector::class);
$services->set(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector::class);
$services->set(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeAbstractPrivateMethodInTraitRector::class);
$services->set(\Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector::class);
$services->set(\Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector::class);
$services->set(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrContainsRector::class);

View File

@ -0,0 +1,68 @@
<?php
declare (strict_types=1);
namespace Rector\DowngradePhp80\Rector\ClassMethod;
use PhpParser\Node;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Trait_;
use Rector\Core\Rector\AbstractRector;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\DowngradePhp80\Rector\ClassMethod\DowngradeAbstractPrivateMethodInTraitRector\DowngradeAbstractPrivateMethodInTraitRectorTest
*/
final class DowngradeAbstractPrivateMethodInTraitRector extends \Rector\Core\Rector\AbstractRector
{
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove "abstract" from private methods in traits and adds an empty function body', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
trait SomeTrait
{
abstract private function someAbstractPrivateFunction();
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
trait SomeTrait
{
private function someAbstractPrivateFunction() {}
}
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [\PhpParser\Node\Stmt\ClassMethod::class];
}
/**
* @param ClassMethod $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
if ($this->shouldSkip($node)) {
return null;
}
$this->visibilityManipulator->removeAbstract($node);
// Add empty array for stmts to generate empty function body
$node->stmts = [];
return $node;
}
private function shouldSkip(\PhpParser\Node\Stmt\ClassMethod $node) : bool
{
if (!$node->isAbstract()) {
return \true;
}
if (!$node->isPrivate()) {
return \true;
}
$parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
if (!$parent instanceof \PhpParser\Node\Stmt\Trait_) {
return \true;
}
return \false;
}
}

View File

@ -116,6 +116,10 @@ final class VisibilityManipulator
{
$node->flags -= \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL;
}
public function removeAbstract(\PhpParser\Node\Stmt\ClassMethod $node) : void
{
$node->flags -= \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT;
}
/**
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $node
*/

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'e3f20c1fb6665e7f0f6f84ced015f9eff86b6834';
public const PACKAGE_VERSION = '38b1d4d1927acafada9e04b2998987eaacd32c7e';
/**
* @var string
*/
public const RELEASE_DATE = '2021-08-08 18:42:15';
public const RELEASE_DATE = '2021-08-08 18:46:47';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20210808\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

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

View File

@ -2162,6 +2162,7 @@ return array(
'Rector\\DowngradePhp80\\NodeAnalyzer\\UnnamedArgumentResolver' => $baseDir . '/rules/DowngradePhp80/NodeAnalyzer/UnnamedArgumentResolver.php',
'Rector\\DowngradePhp80\\Rector\\Catch_\\DowngradeNonCapturingCatchesRector' => $baseDir . '/rules/DowngradePhp80/Rector/Catch_/DowngradeNonCapturingCatchesRector.php',
'Rector\\DowngradePhp80\\Rector\\ClassConstFetch\\DowngradeClassOnObjectToGetClassRector' => $baseDir . '/rules/DowngradePhp80/Rector/ClassConstFetch/DowngradeClassOnObjectToGetClassRector.php',
'Rector\\DowngradePhp80\\Rector\\ClassMethod\\DowngradeAbstractPrivateMethodInTraitRector' => $baseDir . '/rules/DowngradePhp80/Rector/ClassMethod/DowngradeAbstractPrivateMethodInTraitRector.php',
'Rector\\DowngradePhp80\\Rector\\ClassMethod\\DowngradeStaticTypeDeclarationRector' => $baseDir . '/rules/DowngradePhp80/Rector/ClassMethod/DowngradeStaticTypeDeclarationRector.php',
'Rector\\DowngradePhp80\\Rector\\ClassMethod\\DowngradeTrailingCommasInParamUseRector' => $baseDir . '/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php',
'Rector\\DowngradePhp80\\Rector\\Class_\\DowngradeAttributeToAnnotationRector' => $baseDir . '/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitd68240002bad7ce1a50ee6dd5c914b1b
class ComposerAutoloaderInit431f1307a662f129c3d7fcb373049a79
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInitd68240002bad7ce1a50ee6dd5c914b1b
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitd68240002bad7ce1a50ee6dd5c914b1b', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit431f1307a662f129c3d7fcb373049a79', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInitd68240002bad7ce1a50ee6dd5c914b1b', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit431f1307a662f129c3d7fcb373049a79', '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\ComposerStaticInitd68240002bad7ce1a50ee6dd5c914b1b::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit431f1307a662f129c3d7fcb373049a79::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInitd68240002bad7ce1a50ee6dd5c914b1b
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitd68240002bad7ce1a50ee6dd5c914b1b::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit431f1307a662f129c3d7fcb373049a79::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequired68240002bad7ce1a50ee6dd5c914b1b($fileIdentifier, $file);
composerRequire431f1307a662f129c3d7fcb373049a79($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequired68240002bad7ce1a50ee6dd5c914b1b($fileIdentifier, $file)
function composerRequire431f1307a662f129c3d7fcb373049a79($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitd68240002bad7ce1a50ee6dd5c914b1b
class ComposerStaticInit431f1307a662f129c3d7fcb373049a79
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -2522,6 +2522,7 @@ class ComposerStaticInitd68240002bad7ce1a50ee6dd5c914b1b
'Rector\\DowngradePhp80\\NodeAnalyzer\\UnnamedArgumentResolver' => __DIR__ . '/../..' . '/rules/DowngradePhp80/NodeAnalyzer/UnnamedArgumentResolver.php',
'Rector\\DowngradePhp80\\Rector\\Catch_\\DowngradeNonCapturingCatchesRector' => __DIR__ . '/../..' . '/rules/DowngradePhp80/Rector/Catch_/DowngradeNonCapturingCatchesRector.php',
'Rector\\DowngradePhp80\\Rector\\ClassConstFetch\\DowngradeClassOnObjectToGetClassRector' => __DIR__ . '/../..' . '/rules/DowngradePhp80/Rector/ClassConstFetch/DowngradeClassOnObjectToGetClassRector.php',
'Rector\\DowngradePhp80\\Rector\\ClassMethod\\DowngradeAbstractPrivateMethodInTraitRector' => __DIR__ . '/../..' . '/rules/DowngradePhp80/Rector/ClassMethod/DowngradeAbstractPrivateMethodInTraitRector.php',
'Rector\\DowngradePhp80\\Rector\\ClassMethod\\DowngradeStaticTypeDeclarationRector' => __DIR__ . '/../..' . '/rules/DowngradePhp80/Rector/ClassMethod/DowngradeStaticTypeDeclarationRector.php',
'Rector\\DowngradePhp80\\Rector\\ClassMethod\\DowngradeTrailingCommasInParamUseRector' => __DIR__ . '/../..' . '/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php',
'Rector\\DowngradePhp80\\Rector\\Class_\\DowngradeAttributeToAnnotationRector' => __DIR__ . '/../..' . '/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php',
@ -3846,9 +3847,9 @@ class ComposerStaticInitd68240002bad7ce1a50ee6dd5c914b1b
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitd68240002bad7ce1a50ee6dd5c914b1b::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd68240002bad7ce1a50ee6dd5c914b1b::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd68240002bad7ce1a50ee6dd5c914b1b::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit431f1307a662f129c3d7fcb373049a79::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit431f1307a662f129c3d7fcb373049a79::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit431f1307a662f129c3d7fcb373049a79::$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('RectorPrefix20210808\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitd68240002bad7ce1a50ee6dd5c914b1b', false) && !interface_exists('ComposerAutoloaderInitd68240002bad7ce1a50ee6dd5c914b1b', false) && !trait_exists('ComposerAutoloaderInitd68240002bad7ce1a50ee6dd5c914b1b', false)) {
spl_autoload_call('RectorPrefix20210808\ComposerAutoloaderInitd68240002bad7ce1a50ee6dd5c914b1b');
if (!class_exists('ComposerAutoloaderInit431f1307a662f129c3d7fcb373049a79', false) && !interface_exists('ComposerAutoloaderInit431f1307a662f129c3d7fcb373049a79', false) && !trait_exists('ComposerAutoloaderInit431f1307a662f129c3d7fcb373049a79', false)) {
spl_autoload_call('RectorPrefix20210808\ComposerAutoloaderInit431f1307a662f129c3d7fcb373049a79');
}
if (!class_exists('AjaxLogin', false) && !interface_exists('AjaxLogin', false) && !trait_exists('AjaxLogin', false)) {
spl_autoload_call('RectorPrefix20210808\AjaxLogin');
@ -3305,9 +3305,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210808\print_node(...func_get_args());
}
}
if (!function_exists('composerRequired68240002bad7ce1a50ee6dd5c914b1b')) {
function composerRequired68240002bad7ce1a50ee6dd5c914b1b() {
return \RectorPrefix20210808\composerRequired68240002bad7ce1a50ee6dd5c914b1b(...func_get_args());
if (!function_exists('composerRequire431f1307a662f129c3d7fcb373049a79')) {
function composerRequire431f1307a662f129c3d7fcb373049a79() {
return \RectorPrefix20210808\composerRequire431f1307a662f129c3d7fcb373049a79(...func_get_args());
}
}
if (!function_exists('parseArgs')) {