Updated Rector to commit 474b3a222684b9c343ba6b43ea5bd39b78fbef2a

474b3a2226 Faster name resolving (#4955)
This commit is contained in:
Tomas Votruba 2023-09-09 18:18:18 +00:00
parent 81d65055b2
commit 6adcb19ec9
14 changed files with 66 additions and 39 deletions

View File

@ -196,7 +196,7 @@ final class NodeNameResolver
if ($desiredName === 'Object') {
return $desiredName === $resolvedName;
}
return \strtolower($resolvedName) === \strtolower($desiredName);
return \strcasecmp($resolvedName, $desiredName) === 0;
}
/**
* @param string|\PhpParser\Node\Identifier $resolvedName

View File

@ -282,8 +282,12 @@ CODE_SAMPLE
*/
private function refactorCall($call) : void
{
$callName = $this->getName($call->name);
if ($callName === null) {
return;
}
foreach ($this->addedArguments as $addedArgument) {
if (!$this->isName($call->name, $addedArgument->getMethod())) {
if (!$this->nodeNameResolver->isStringName($callName, $addedArgument->getMethod())) {
continue;
}
if (!$this->isObjectTypeMatch($call, $addedArgument->getObjectType())) {

View File

@ -64,8 +64,12 @@ CODE_SAMPLE
if ($node instanceof New_) {
return $this->refactorNew($node);
}
$nodeName = $this->getName($node->name);
if ($nodeName === null) {
return null;
}
foreach ($this->replaceArgumentDefaultValues as $replaceArgumentDefaultValue) {
if (!$this->isName($node->name, $replaceArgumentDefaultValue->getMethod())) {
if (!$this->nodeNameResolver->isStringName($nodeName, $replaceArgumentDefaultValue->getMethod())) {
continue;
}
if (!$this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, $replaceArgumentDefaultValue->getObjectType())) {

View File

@ -144,17 +144,12 @@ CODE_SAMPLE
$classReflection = $scope->getClassReflection();
$hasChanged = \false;
foreach ($classOrInterface->getMethods() as $classMethod) {
$methodName = $this->getName($classMethod->name);
if ($methodName === null) {
continue;
}
foreach ($this->methodCallRenames as $methodCallRename) {
if (!$this->isName($classMethod->name, $methodCallRename->getOldMethod())) {
continue;
}
if (!$this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($classMethod, $methodCallRename->getObjectType())) {
continue;
}
if ($this->shouldKeepForParentInterface($methodCallRename, $classReflection)) {
continue;
}
if ($this->hasClassNewClassMethod($classOrInterface, $methodCallRename)) {
if ($this->shouldSkipRename($methodName, $classMethod, $methodCallRename, $classReflection, $classOrInterface)) {
continue;
}
$classMethod->name = new Identifier($methodCallRename->getNewMethod());
@ -166,14 +161,37 @@ CODE_SAMPLE
}
return null;
}
/**
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_ $classOrInterface
*/
private function shouldSkipRename(string $methodName, Node\Stmt\ClassMethod $classMethod, MethodCallRenameInterface $methodCallRename, ClassReflection $classReflection, $classOrInterface) : bool
{
if (!$this->nodeNameResolver->isStringName($methodName, $methodCallRename->getOldMethod())) {
return \true;
}
if (!$this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($classMethod, $methodCallRename->getObjectType())) {
return \true;
}
if ($this->shouldKeepForParentInterface($methodCallRename, $classReflection)) {
return \true;
}
if ($this->hasClassNewClassMethod($classOrInterface, $methodCallRename)) {
return \true;
}
return \false;
}
/**
* @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $call
* @return \PhpParser\Node\Expr\ArrayDimFetch|null|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall
*/
private function refactorMethodCallAndStaticCall($call)
{
$callName = $this->getName($call->name);
if ($callName === null) {
return null;
}
foreach ($this->methodCallRenames as $methodCallRename) {
if (!$this->isName($call->name, $methodCallRename->getOldMethod())) {
if (!$this->nodeNameResolver->isStringName($callName, $methodCallRename->getOldMethod())) {
continue;
}
if (!$this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($call, $methodCallRename->getObjectType())) {

View File

@ -86,8 +86,9 @@ CODE_SAMPLE
if ($this->shouldSkip($node, $classMethod)) {
continue;
}
$methodName = $this->getName($classMethod);
foreach ($this->addParamTypeDeclarations as $addParamTypeDeclaration) {
if (!$this->isName($classMethod, $addParamTypeDeclaration->getMethodName())) {
if (!$this->nodeNameResolver->isStringName($methodName, $addParamTypeDeclaration->getMethodName())) {
continue;
}
if (!$this->isObjectType($node, $addParamTypeDeclaration->getObjectType())) {

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '2d5d72f3ba66a63acb991107ba763e147c9840f4';
public const PACKAGE_VERSION = '474b3a222684b9c343ba6b43ea5bd39b78fbef2a';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-09-09 16:17:08';
public const RELEASE_DATE = '2023-09-10 01:14:55';
/**
* @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 ComposerAutoloaderInit44a71667671e232b128ccd6eb6cb8d26::getLoader();
return ComposerAutoloaderInit31466462ced114eb17fecf6cacaa533e::getLoader();

View File

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

View File

@ -1872,12 +1872,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "7b173b9417ff63b709a6e06d9fa9fcf2e972f472"
"reference": "f07d7f02e44488a9b022c561623686c460e62002"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/7b173b9417ff63b709a6e06d9fa9fcf2e972f472",
"reference": "7b173b9417ff63b709a6e06d9fa9fcf2e972f472",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/f07d7f02e44488a9b022c561623686c460e62002",
"reference": "f07d7f02e44488a9b022c561623686c460e62002",
"shasum": ""
},
"require": {
@ -1907,7 +1907,7 @@
"tomasvotruba\/unused-public": "^0.3",
"tracy\/tracy": "^2.10"
},
"time": "2023-09-09T13:48:11+00:00",
"time": "2023-09-09T14:19:47+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -1943,12 +1943,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "1a713897eb0998232c3182a1165c0f6f337ec32a"
"reference": "b9303b57a4076721d9f83f1ab75e3949c66e7fad"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/1a713897eb0998232c3182a1165c0f6f337ec32a",
"reference": "1a713897eb0998232c3182a1165c0f6f337ec32a",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/b9303b57a4076721d9f83f1ab75e3949c66e7fad",
"reference": "b9303b57a4076721d9f83f1ab75e3949c66e7fad",
"shasum": ""
},
"require": {
@ -1981,7 +1981,7 @@
"tomasvotruba\/unused-public": "^0.2",
"tracy\/tracy": "^2.10"
},
"time": "2023-09-09T14:02:57+00:00",
"time": "2023-09-09T14:18:29+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' => NULL, 'version' => 'dev-main aecc9c7'), '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' => NULL, 'version' => 'dev-main fa41cc7'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 7b173b9'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 1a71389'));
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' => NULL, 'version' => 'dev-main aecc9c7'), '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' => NULL, 'version' => 'dev-main fa41cc7'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main f07d7f0'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main b9303b5'));
private function __construct()
{
}

View File

@ -82,7 +82,7 @@ CODE_SAMPLE
if (!$this->isObjectType($node->var, new ObjectType('PHPUnit\\Framework\\TestCase'))) {
return null;
}
if (!$this->nodeNameResolver->matchesStringName($methodName, 'assert*')) {
if (!$this->nodeNameResolver->startsWith($node->name, 'assert')) {
return null;
}
$hasChanged = \true;

View File

@ -100,7 +100,7 @@ CODE_SAMPLE
}
private function processMethodCall(MethodCall $methodCall) : ?\PhpParser\Node\Expr\CallLike
{
if ($methodCall->name instanceof Identifier && $this->nodeNameResolver->matchesStringName($methodCall->name, 'assert*')) {
if ($this->nodeNameResolver->startsWith($methodCall->name, 'assert')) {
return $this->processAssertMethodCall($methodCall);
}
if ($this->isName($methodCall->name, 'redirect')) {