Updated Rector to commit 3bd0e9faa5e015df82ccf511e248b5ca3d168b33

3bd0e9faa5  [DeadCode] Skip used as closure on RemoveUnusedPrivateMethodRector  (#4413)
This commit is contained in:
Tomas Votruba 2023-07-03 16:48:28 +00:00
parent f40dc9ec2a
commit d16d5ab29c
5 changed files with 36 additions and 17 deletions

View File

@ -6,7 +6,9 @@ namespace Rector\DeadCode\NodeAnalyzer;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PHPStan\Type\TypeWithClassName;
use Rector\Core\Enum\ObjectReference;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\NodeTypeResolver;
final class CallCollectionAnalyzer
@ -37,17 +39,34 @@ final class CallCollectionAnalyzer
if (!$callerType instanceof TypeWithClassName) {
continue;
}
if ($this->isSelfStatic($call) && $this->shouldSkip($call, $classMethodName)) {
return \true;
}
if ($callerType->getClassName() !== $className) {
continue;
}
if (!$call->name instanceof Identifier) {
return \true;
}
// the method is used
if ($this->nodeNameResolver->isName($call->name, $classMethodName)) {
if ($this->shouldSkip($call, $classMethodName)) {
return \true;
}
}
return \false;
}
/**
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $call
*/
private function isSelfStatic($call) : bool
{
return $call instanceof StaticCall && $call->class instanceof Name && \in_array($call->class->toString(), [ObjectReference::SELF, ObjectReference::STATIC], \true);
}
/**
* @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $call
*/
private function shouldSkip($call, string $classMethodName) : bool
{
if (!$call->name instanceof Identifier) {
return \true;
}
// the method is used
return $this->nodeNameResolver->isName($call->name, $classMethodName);
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '3aed20ef6677602ae7a5d164be8bbdee291da4ce';
public const PACKAGE_VERSION = '3bd0e9faa5e015df82ccf511e248b5ca3d168b33';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-07-03 15:03:14';
public const RELEASE_DATE = '2023-07-03 23:43:30';
/**
* @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 ComposerAutoloaderInitd4343ddd8a7351669bde1fa73a7abb9a::getLoader();
return ComposerAutoloaderInit6704315a9914fcf658bd4a71cc3cdd21::getLoader();

View File

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