Updated Rector to commit 135483f78fb5d4191190453b762906097024aa98

135483f78f [Privatization] Skip used by heredoc on ChangeReadOnlyVariableWithDefaultValueToConstantRector (#3216)
This commit is contained in:
Tomas Votruba 2022-12-18 16:21:48 +00:00
parent e1a1e9af63
commit cc9debaefb
6 changed files with 42 additions and 19 deletions

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\Renaming\Helper;
use PhpParser\Node;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\NodeVisitorAbstract;
use PHPStan\Reflection\ReflectionProvider;
@ -61,17 +62,17 @@ final class RenameClassCallbackHandler extends NodeVisitorAbstract
/**
* @return array<string, string>
*/
public function handleClassLike(ClassLike $node) : array
public function handleClassLike(ClassLike $classLike) : array
{
$oldToNewClasses = [];
$className = $node->name;
if ($className === null) {
$className = $classLike->name;
if (!$className instanceof Identifier) {
return [];
}
foreach ($this->oldToNewClassCallbacks as $oldToNewClassCallback) {
$newClassName = $oldToNewClassCallback($node, $this->nodeNameResolver, $this->reflectionProvider);
$newClassName = $oldToNewClassCallback($classLike, $this->nodeNameResolver, $this->reflectionProvider);
if ($newClassName !== null) {
$fullyQualifiedClassName = (string) $this->nodeNameResolver->getName($node);
$fullyQualifiedClassName = (string) $this->nodeNameResolver->getName($classLike);
$this->renamedClassesDataCollector->addOldToNewClass($fullyQualifiedClassName, $newClassName);
$oldToNewClasses[$fullyQualifiedClassName] = $newClassName;
}

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'e35497e40a8f71ef8c602759922457289d06821a';
public const PACKAGE_VERSION = '135483f78fb5d4191190453b762906097024aa98';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-12-17 21:44:31';
public const RELEASE_DATE = '2022-12-18 17:17:34';
/**
* @var int
*/

View File

@ -5,6 +5,7 @@ namespace Rector\Core\NodeManipulator;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\ClosureUse;
use PhpParser\Node\Expr\FuncCall;
@ -13,6 +14,7 @@ use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Param;
use PhpParser\Node\Scalar\Encapsed;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Foreach_;
@ -95,6 +97,7 @@ final class ClassMethodAssignManipulator
$readOnlyVariableAssigns = $this->filterOutReferencedVariables($readOnlyVariableAssigns, $classMethod);
$readOnlyVariableAssigns = $this->filterOutMultiAssigns($readOnlyVariableAssigns);
$readOnlyVariableAssigns = $this->filterOutForeachVariables($readOnlyVariableAssigns);
$readOnlyVariableAssigns = $this->filterOutUsedByEncapsed($readOnlyVariableAssigns);
/**
* Remove unused variable assign is task of RemoveUnusedVariableAssignRector
* so no need to move to constant early
@ -112,6 +115,25 @@ final class ClassMethodAssignManipulator
$classMethodHash = \spl_object_hash($classMethod);
$this->alreadyAddedClassMethodNames[$classMethodHash][] = $name;
}
/**
* @param Assign[] $readOnlyVariableAssigns
* @return Assign[]
*/
private function filterOutUsedByEncapsed(array $readOnlyVariableAssigns) : array
{
$callable = function (Assign $readOnlyVariableAssign) : bool {
$variable = $readOnlyVariableAssign->var;
return !(bool) $this->betterNodeFinder->findFirstNext($readOnlyVariableAssign, function (Node $node) use($variable) : bool {
if (!$node instanceof Encapsed) {
return \false;
}
return (bool) \array_filter($node->parts, function (Expr $expr) use($variable) : bool {
return $this->nodeComparator->areNodesEqual($expr, $variable);
});
});
};
return \array_filter($readOnlyVariableAssigns, $callable);
}
/**
* @param Assign[] $readOnlyVariableAssigns
* @return Assign[]

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitf01ea4519dceb00097b8c238dd1eb7f7::getLoader();
return ComposerAutoloaderInita081b5bee227c0bc266abc76901a0827::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitf01ea4519dceb00097b8c238dd1eb7f7
class ComposerAutoloaderInita081b5bee227c0bc266abc76901a0827
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitf01ea4519dceb00097b8c238dd1eb7f7
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitf01ea4519dceb00097b8c238dd1eb7f7', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInita081b5bee227c0bc266abc76901a0827', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitf01ea4519dceb00097b8c238dd1eb7f7', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInita081b5bee227c0bc266abc76901a0827', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitf01ea4519dceb00097b8c238dd1eb7f7::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInita081b5bee227c0bc266abc76901a0827::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitf01ea4519dceb00097b8c238dd1eb7f7::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInita081b5bee227c0bc266abc76901a0827::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequiref01ea4519dceb00097b8c238dd1eb7f7($fileIdentifier, $file);
composerRequirea081b5bee227c0bc266abc76901a0827($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitf01ea4519dceb00097b8c238dd1eb7f7
* @param string $file
* @return void
*/
function composerRequiref01ea4519dceb00097b8c238dd1eb7f7($fileIdentifier, $file)
function composerRequirea081b5bee227c0bc266abc76901a0827($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 ComposerStaticInitf01ea4519dceb00097b8c238dd1eb7f7
class ComposerStaticInita081b5bee227c0bc266abc76901a0827
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3055,9 +3055,9 @@ class ComposerStaticInitf01ea4519dceb00097b8c238dd1eb7f7
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitf01ea4519dceb00097b8c238dd1eb7f7::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf01ea4519dceb00097b8c238dd1eb7f7::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf01ea4519dceb00097b8c238dd1eb7f7::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInita081b5bee227c0bc266abc76901a0827::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInita081b5bee227c0bc266abc76901a0827::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInita081b5bee227c0bc266abc76901a0827::$classMap;
}, null, ClassLoader::class);
}