Updated Rector to commit 6c7caa63c4025b47a382cd2e28b6f05fbcb55e71

6c7caa63c4 Reverts Use MethodCallRename directly (#3080)
This commit is contained in:
Tomas Votruba 2022-11-19 11:50:17 +00:00
parent 141dc65509
commit 75e646ce54
14 changed files with 123 additions and 31 deletions

View File

@ -3,22 +3,22 @@
declare (strict_types=1);
namespace Rector\Renaming\Collector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Rector\Renaming\Contract\MethodCallRenameInterface;
final class MethodCallRenameCollector
{
/**
* @var MethodCallRename[]
* @var MethodCallRenameInterface[]
*/
private $methodCallRenames = [];
/**
* @param MethodCallRename[] $methodCallRenames
* @param MethodCallRenameInterface[] $methodCallRenames
*/
public function addMethodCallRenames(array $methodCallRenames) : void
{
$this->methodCallRenames = \array_merge($this->methodCallRenames, $methodCallRenames);
}
/**
* @return MethodCallRename[]
* @return MethodCallRenameInterface[]
*/
public function getMethodCallRenames() : array
{

View File

@ -0,0 +1,13 @@
<?php
declare (strict_types=1);
namespace Rector\Renaming\Contract;
use PHPStan\Type\ObjectType;
interface MethodCallRenameInterface
{
public function getClass() : string;
public function getObjectType() : ObjectType;
public function getOldMethod() : string;
public function getNewMethod() : string;
}

View File

@ -3,7 +3,9 @@
declare (strict_types=1);
namespace Rector\Renaming\Rector\MethodCall;
use PhpParser\BuilderHelpers;
use PhpParser\Node;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Identifier;
@ -17,7 +19,9 @@ use Rector\Core\NodeManipulator\ClassManipulator;
use Rector\Core\Rector\AbstractScopeAwareRector;
use Rector\Core\Reflection\ReflectionResolver;
use Rector\Renaming\Collector\MethodCallRenameCollector;
use Rector\Renaming\Contract\MethodCallRenameInterface;
use Rector\Renaming\ValueObject\MethodCallRename;
use Rector\Renaming\ValueObject\MethodCallRenameWithArrayKey;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use RectorPrefix202211\Webmozart\Assert\Assert;
@ -27,7 +31,7 @@ use RectorPrefix202211\Webmozart\Assert\Assert;
final class RenameMethodRector extends AbstractScopeAwareRector implements ConfigurableRectorInterface
{
/**
* @var MethodCallRename[]
* @var MethodCallRenameInterface[]
*/
private $methodCallRenames = [];
/**
@ -96,6 +100,9 @@ CODE_SAMPLE
continue;
}
$node->name = new Identifier($methodCallRename->getNewMethod());
if ($methodCallRename instanceof MethodCallRenameWithArrayKey && !$node instanceof ClassMethod) {
return new ArrayDimFetch($node, BuilderHelpers::normalizeValue($methodCallRename->getArrayKey()));
}
return $node;
}
return null;
@ -105,14 +112,14 @@ CODE_SAMPLE
*/
public function configure(array $configuration) : void
{
Assert::allIsAOf($configuration, MethodCallRename::class);
Assert::allIsAOf($configuration, MethodCallRenameInterface::class);
$this->methodCallRenames = $configuration;
$this->methodCallRenameCollector->addMethodCallRenames($configuration);
}
/**
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Stmt\ClassMethod $node
*/
private function shouldSkipClassMethod($node, MethodCallRename $methodCallRename) : bool
private function shouldSkipClassMethod($node, MethodCallRenameInterface $methodCallRename) : bool
{
if (!$node instanceof ClassMethod) {
$classReflection = $this->reflectionResolver->resolveClassReflectionSourceObject($node);
@ -135,7 +142,7 @@ CODE_SAMPLE
}
return $this->shouldSkipForAlreadyExistingClassMethod($node, $methodCallRename);
}
private function shouldSkipForAlreadyExistingClassMethod(ClassMethod $classMethod, MethodCallRename $methodCallRename) : bool
private function shouldSkipForAlreadyExistingClassMethod(ClassMethod $classMethod, MethodCallRenameInterface $methodCallRename) : bool
{
$classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class);
if (!$classLike instanceof ClassLike) {
@ -146,7 +153,7 @@ CODE_SAMPLE
/**
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $node
*/
private function shouldKeepForParentInterface(MethodCallRename $methodCallRename, $node, ?ClassReflection $classReflection) : bool
private function shouldKeepForParentInterface(MethodCallRenameInterface $methodCallRename, $node, ?ClassReflection $classReflection) : bool
{
if (!$node instanceof ClassMethod) {
return \false;

View File

@ -5,7 +5,8 @@ namespace Rector\Renaming\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class MethodCallRename
use Rector\Renaming\Contract\MethodCallRenameInterface;
final class MethodCallRename implements MethodCallRenameInterface
{
/**
* @readonly

View File

@ -0,0 +1,67 @@
<?php
declare (strict_types=1);
namespace Rector\Renaming\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
use Rector\Renaming\Contract\MethodCallRenameInterface;
final class MethodCallRenameWithArrayKey implements MethodCallRenameInterface
{
/**
* @readonly
* @var string
*/
private $class;
/**
* @readonly
* @var string
*/
private $oldMethod;
/**
* @readonly
* @var string
*/
private $newMethod;
/**
* @readonly
* @var mixed
*/
private $arrayKey;
/**
* @param mixed $arrayKey
*/
public function __construct(string $class, string $oldMethod, string $newMethod, $arrayKey)
{
$this->class = $class;
$this->oldMethod = $oldMethod;
$this->newMethod = $newMethod;
$this->arrayKey = $arrayKey;
RectorAssert::className($class);
RectorAssert::methodName($oldMethod);
RectorAssert::methodName($newMethod);
}
public function getClass() : string
{
return $this->class;
}
public function getObjectType() : ObjectType
{
return new ObjectType($this->class);
}
public function getOldMethod() : string
{
return $this->oldMethod;
}
public function getNewMethod() : string
{
return $this->newMethod;
}
/**
* @return mixed
*/
public function getArrayKey()
{
return $this->arrayKey;
}
}

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '24b9eb7a4cf97a05b66163545a9d315e0f15d7f5';
public const PACKAGE_VERSION = '6c7caa63c4025b47a382cd2e28b6f05fbcb55e71';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-11-19 14:43:58';
public const RELEASE_DATE = '2022-11-19 12:44:29';
/**
* @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 ComposerAutoloaderInit0a4ebefb5579274df6d9b429a62144d3::getLoader();
return ComposerAutoloaderInit85146f7d3092bca839516053c0716b51::getLoader();

View File

@ -2340,6 +2340,7 @@ return array(
'Rector\\Removing\\ValueObject\\ArgumentRemover' => $baseDir . '/rules/Removing/ValueObject/ArgumentRemover.php',
'Rector\\Removing\\ValueObject\\RemoveFuncCallArg' => $baseDir . '/rules/Removing/ValueObject/RemoveFuncCallArg.php',
'Rector\\Renaming\\Collector\\MethodCallRenameCollector' => $baseDir . '/rules/Renaming/Collector/MethodCallRenameCollector.php',
'Rector\\Renaming\\Contract\\MethodCallRenameInterface' => $baseDir . '/rules/Renaming/Contract/MethodCallRenameInterface.php',
'Rector\\Renaming\\Contract\\RenameAnnotationInterface' => $baseDir . '/rules/Renaming/Contract/RenameAnnotationInterface.php',
'Rector\\Renaming\\Contract\\RenameClassConstFetchInterface' => $baseDir . '/rules/Renaming/Contract/RenameClassConstFetchInterface.php',
'Rector\\Renaming\\NodeManipulator\\ClassRenamer' => $baseDir . '/rules/Renaming/NodeManipulator/ClassRenamer.php',
@ -2356,6 +2357,7 @@ return array(
'Rector\\Renaming\\Rector\\StaticCall\\RenameStaticMethodRector' => $baseDir . '/rules/Renaming/Rector/StaticCall/RenameStaticMethodRector.php',
'Rector\\Renaming\\Rector\\String_\\RenameStringRector' => $baseDir . '/rules/Renaming/Rector/String_/RenameStringRector.php',
'Rector\\Renaming\\ValueObject\\MethodCallRename' => $baseDir . '/rules/Renaming/ValueObject/MethodCallRename.php',
'Rector\\Renaming\\ValueObject\\MethodCallRenameWithArrayKey' => $baseDir . '/rules/Renaming/ValueObject/MethodCallRenameWithArrayKey.php',
'Rector\\Renaming\\ValueObject\\PseudoNamespaceToNamespace' => $baseDir . '/rules/Renaming/ValueObject/PseudoNamespaceToNamespace.php',
'Rector\\Renaming\\ValueObject\\RenameAnnotation' => $baseDir . '/rules/Renaming/ValueObject/RenameAnnotation.php',
'Rector\\Renaming\\ValueObject\\RenameAnnotationByType' => $baseDir . '/rules/Renaming/ValueObject/RenameAnnotationByType.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit0a4ebefb5579274df6d9b429a62144d3
class ComposerAutoloaderInit85146f7d3092bca839516053c0716b51
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit0a4ebefb5579274df6d9b429a62144d3
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit0a4ebefb5579274df6d9b429a62144d3', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit85146f7d3092bca839516053c0716b51', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit0a4ebefb5579274df6d9b429a62144d3', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit85146f7d3092bca839516053c0716b51', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit85146f7d3092bca839516053c0716b51::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit85146f7d3092bca839516053c0716b51::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire0a4ebefb5579274df6d9b429a62144d3($fileIdentifier, $file);
composerRequire85146f7d3092bca839516053c0716b51($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit0a4ebefb5579274df6d9b429a62144d3
* @param string $file
* @return void
*/
function composerRequire0a4ebefb5579274df6d9b429a62144d3($fileIdentifier, $file)
function composerRequire85146f7d3092bca839516053c0716b51($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 ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3
class ComposerStaticInit85146f7d3092bca839516053c0716b51
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -2585,6 +2585,7 @@ class ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3
'Rector\\Removing\\ValueObject\\ArgumentRemover' => __DIR__ . '/../..' . '/rules/Removing/ValueObject/ArgumentRemover.php',
'Rector\\Removing\\ValueObject\\RemoveFuncCallArg' => __DIR__ . '/../..' . '/rules/Removing/ValueObject/RemoveFuncCallArg.php',
'Rector\\Renaming\\Collector\\MethodCallRenameCollector' => __DIR__ . '/../..' . '/rules/Renaming/Collector/MethodCallRenameCollector.php',
'Rector\\Renaming\\Contract\\MethodCallRenameInterface' => __DIR__ . '/../..' . '/rules/Renaming/Contract/MethodCallRenameInterface.php',
'Rector\\Renaming\\Contract\\RenameAnnotationInterface' => __DIR__ . '/../..' . '/rules/Renaming/Contract/RenameAnnotationInterface.php',
'Rector\\Renaming\\Contract\\RenameClassConstFetchInterface' => __DIR__ . '/../..' . '/rules/Renaming/Contract/RenameClassConstFetchInterface.php',
'Rector\\Renaming\\NodeManipulator\\ClassRenamer' => __DIR__ . '/../..' . '/rules/Renaming/NodeManipulator/ClassRenamer.php',
@ -2601,6 +2602,7 @@ class ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3
'Rector\\Renaming\\Rector\\StaticCall\\RenameStaticMethodRector' => __DIR__ . '/../..' . '/rules/Renaming/Rector/StaticCall/RenameStaticMethodRector.php',
'Rector\\Renaming\\Rector\\String_\\RenameStringRector' => __DIR__ . '/../..' . '/rules/Renaming/Rector/String_/RenameStringRector.php',
'Rector\\Renaming\\ValueObject\\MethodCallRename' => __DIR__ . '/../..' . '/rules/Renaming/ValueObject/MethodCallRename.php',
'Rector\\Renaming\\ValueObject\\MethodCallRenameWithArrayKey' => __DIR__ . '/../..' . '/rules/Renaming/ValueObject/MethodCallRenameWithArrayKey.php',
'Rector\\Renaming\\ValueObject\\PseudoNamespaceToNamespace' => __DIR__ . '/../..' . '/rules/Renaming/ValueObject/PseudoNamespaceToNamespace.php',
'Rector\\Renaming\\ValueObject\\RenameAnnotation' => __DIR__ . '/../..' . '/rules/Renaming/ValueObject/RenameAnnotation.php',
'Rector\\Renaming\\ValueObject\\RenameAnnotationByType' => __DIR__ . '/../..' . '/rules/Renaming/ValueObject/RenameAnnotationByType.php',
@ -3034,9 +3036,9 @@ class ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit85146f7d3092bca839516053c0716b51::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit85146f7d3092bca839516053c0716b51::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit85146f7d3092bca839516053c0716b51::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2061,12 +2061,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "695c960e7713438ef1077bebcbc6d298a95020d1"
"reference": "0a9fcc8a01a30eb3f0d9c34fcd927750ae501b68"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/695c960e7713438ef1077bebcbc6d298a95020d1",
"reference": "695c960e7713438ef1077bebcbc6d298a95020d1",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/0a9fcc8a01a30eb3f0d9c34fcd927750ae501b68",
"reference": "0a9fcc8a01a30eb3f0d9c34fcd927750ae501b68",
"shasum": ""
},
"require": {
@ -2097,7 +2097,7 @@
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
},
"time": "2022-11-14T14:41:53+00:00",
"time": "2022-11-19T11:42:30+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 da1013f'), '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 769064f'), '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 695c960'));
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 da1013f'), '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 769064f'), '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 0a9fcc8'));
private function __construct()
{
}

View File

@ -132,7 +132,7 @@ CODE_SAMPLE
*/
private function splitProcessCommandToItems(string $process) : array
{
$privatesCaller = new PrivatesCaller();
$privatesCaller = new \Rector\Core\Util\Reflection\PrivatesAccessor();
return $privatesCaller->callPrivateMethod(new StringInput(''), 'tokenize', [$process]);
}
private function processPreviousAssign(Node $node, Expr $firstArgumentExpr) : void