Updated Rector to commit 26b32be535516bf80da94b85b2172b2ac64f9a7c

26b32be535 Remove PARENT_NODE from StringClassNameToClassConstantRector (#3928)
This commit is contained in:
Tomas Votruba 2023-05-22 13:58:34 +00:00
parent 96fc00fd8e
commit ed0c750f6e
5 changed files with 18 additions and 28 deletions

View File

@ -8,15 +8,14 @@ use PhpParser\Node\Arg;
use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\ClassConst;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ReflectionProvider;
use Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\Rector\AbstractScopeAwareRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\Naming\Naming\AliasNameResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
@ -27,7 +26,7 @@ use RectorPrefix202305\Webmozart\Assert\Assert;
*
* @see \Rector\Tests\Php55\Rector\String_\StringClassNameToClassConstantRector\StringClassNameToClassConstantRectorTest
*/
final class StringClassNameToClassConstantRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface, MinPhpVersionInterface
final class StringClassNameToClassConstantRector extends AbstractScopeAwareRector implements AllowEmptyConfigurableRectorInterface, MinPhpVersionInterface
{
/**
* @var string[]
@ -38,15 +37,9 @@ final class StringClassNameToClassConstantRector extends AbstractRector implemen
* @var \PHPStan\Reflection\ReflectionProvider
*/
private $reflectionProvider;
/**
* @readonly
* @var \Rector\Naming\Naming\AliasNameResolver
*/
private $aliasNameResolver;
public function __construct(ReflectionProvider $reflectionProvider, AliasNameResolver $aliasNameResolver)
public function __construct(ReflectionProvider $reflectionProvider)
{
$this->reflectionProvider = $reflectionProvider;
$this->aliasNameResolver = $aliasNameResolver;
}
public function getRuleDefinition() : RuleDefinition
{
@ -88,7 +81,7 @@ CODE_SAMPLE
/**
* @param String_ $node
*/
public function refactor(Node $node) : ?Node
public function refactorWithScope(Node $node, Scope $scope) : ?Node
{
$classLikeName = $node->value;
// remove leading slash
@ -100,10 +93,7 @@ CODE_SAMPLE
return null;
}
$fullyQualified = new FullyQualified($classLikeName);
$name = clone $fullyQualified;
$name->setAttribute(AttributeKey::PARENT_NODE, $node->getAttribute(AttributeKey::PARENT_NODE));
$aliasName = $this->aliasNameResolver->resolveByName($name);
$fullyQualifiedOrAliasName = \is_string($aliasName) ? new Name($aliasName) : $fullyQualified;
$fullyQualifiedOrAliasName = new FullyQualified($scope->resolveName($fullyQualified));
if ($classLikeName !== $node->value) {
$preSlashCount = \strlen($node->value) - \strlen($classLikeName);
$preSlash = \str_repeat('\\', $preSlashCount);

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '3c69a0f9d7b075cef7e0e382eee94234f3629efa';
public const PACKAGE_VERSION = '26b32be535516bf80da94b85b2172b2ac64f9a7c';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-05-22 14:39:32';
public const RELEASE_DATE = '2023-05-22 13:53:32';
/**
* @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 ComposerAutoloaderInit4f487b52f549de690671cbbde29f649c::getLoader();
return ComposerAutoloaderInitf4f87a222c2fea7e474c3b0896bc69ba::getLoader();

View File

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