mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 17:00:51 +00:00
Updated Rector to commit 3c526c91f05faf276fb08bedb31bc1dc19cfb678
3c526c91f0
[AutoImport] Handle AnnotationToAttributeRector + RenameClassRector then enable auto import (#5213)
This commit is contained in:
parent
20e5da8be0
commit
685f0bab53
|
@ -20,6 +20,7 @@ use Rector\CodingStyle\Node\NameImporter;
|
|||
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\Configuration\Parameter\SimpleParameterProvider;
|
||||
use Rector\Core\Configuration\RenamedClassesDataCollector;
|
||||
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
||||
use Rector\Core\Provider\CurrentFileProvider;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
|
@ -69,7 +70,12 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo
|
|||
* @var \Rector\Comments\NodeDocBlock\DocBlockUpdater
|
||||
*/
|
||||
private $docBlockUpdater;
|
||||
public function __construct(NameImporter $nameImporter, DocBlockNameImporter $docBlockNameImporter, ClassNameImportSkipper $classNameImportSkipper, PhpDocInfoFactory $phpDocInfoFactory, CurrentFileProvider $currentFileProvider, UseImportsResolver $useImportsResolver, AliasNameResolver $aliasNameResolver, DocBlockUpdater $docBlockUpdater)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Configuration\RenamedClassesDataCollector
|
||||
*/
|
||||
private $renamedClassesDataCollector;
|
||||
public function __construct(NameImporter $nameImporter, DocBlockNameImporter $docBlockNameImporter, ClassNameImportSkipper $classNameImportSkipper, PhpDocInfoFactory $phpDocInfoFactory, CurrentFileProvider $currentFileProvider, UseImportsResolver $useImportsResolver, AliasNameResolver $aliasNameResolver, DocBlockUpdater $docBlockUpdater, RenamedClassesDataCollector $renamedClassesDataCollector)
|
||||
{
|
||||
$this->nameImporter = $nameImporter;
|
||||
$this->docBlockNameImporter = $docBlockNameImporter;
|
||||
|
@ -79,6 +85,7 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo
|
|||
$this->useImportsResolver = $useImportsResolver;
|
||||
$this->aliasNameResolver = $aliasNameResolver;
|
||||
$this->docBlockUpdater = $docBlockUpdater;
|
||||
$this->renamedClassesDataCollector = $renamedClassesDataCollector;
|
||||
}
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
|
@ -94,6 +101,7 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo
|
|||
return null;
|
||||
}
|
||||
if ($node instanceof Name) {
|
||||
$node = $this->resolveNameFromAttribute($node);
|
||||
return $this->processNodeName($node, $file);
|
||||
}
|
||||
if (!$node instanceof Stmt && !$node instanceof Param) {
|
||||
|
@ -114,6 +122,22 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo
|
|||
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node);
|
||||
return $node;
|
||||
}
|
||||
private function resolveNameFromAttribute(Name $name) : Name
|
||||
{
|
||||
if ($name instanceof FullyQualified) {
|
||||
return $name;
|
||||
}
|
||||
if ($name->hasAttribute(AttributeKey::PHP_ATTRIBUTE_NAME)) {
|
||||
$oldToNewClasses = $this->renamedClassesDataCollector->getOldToNewClasses();
|
||||
$phpAttributeName = $name->getAttribute(AttributeKey::PHP_ATTRIBUTE_NAME);
|
||||
foreach ($oldToNewClasses as $oldName => $newName) {
|
||||
if ($oldName === $phpAttributeName) {
|
||||
return new FullyQualified($newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
private function processNodeName(Name $name, File $file) : ?Node
|
||||
{
|
||||
if ($name->isSpecialClassName()) {
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'c1657f00d185b8a300909affbb30081aa7a407fc';
|
||||
public const PACKAGE_VERSION = '3c526c91f05faf276fb08bedb31bc1dc19cfb678';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-10-29 00:26:14';
|
||||
public const RELEASE_DATE = '2023-10-29 18:08:10';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
|
@ -1879,12 +1879,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||
"reference": "fdf9e75fa1c18baa8ff100f642dc600c85f192dd"
|
||||
"reference": "38014d41e7ccddfdc4c9c839931c68a57d931f63"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/fdf9e75fa1c18baa8ff100f642dc600c85f192dd",
|
||||
"reference": "fdf9e75fa1c18baa8ff100f642dc600c85f192dd",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/38014d41e7ccddfdc4c9c839931c68a57d931f63",
|
||||
"reference": "38014d41e7ccddfdc4c9c839931c68a57d931f63",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1917,7 +1917,7 @@
|
|||
"tomasvotruba\/unused-public": "^0.2",
|
||||
"tracy\/tracy": "^2.10"
|
||||
},
|
||||
"time": "2023-10-25T15:34:03+00:00",
|
||||
"time": "2023-10-29T11:07:39+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
|
@ -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/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 9de7d58'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 2d20783'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main a58bdca'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main fdf9e75'));
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 9de7d58'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 2d20783'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main a58bdca'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 38014d4'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -14,8 +14,21 @@ use Rector\Symfony\Symfony62\Rector\Class_\MessageSubscriberInterfaceToAttribute
|
|||
use Rector\Symfony\Symfony62\Rector\ClassMethod\ClassMethod\ArgumentValueResolverToValueResolverRector;
|
||||
use Rector\Symfony\Symfony62\Rector\ClassMethod\ParamConverterAttributeToMapEntityAttributeRector;
|
||||
use Rector\Symfony\Symfony62\Rector\MethodCall\SimplifyFormRenderingRector;
|
||||
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
|
||||
use Rector\Php80\ValueObject\AnnotationToAttribute;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rule(SimplifyFormRenderingRector::class);
|
||||
// change to attribute before rename
|
||||
// https://symfony.com/blog/new-in-symfony-6-2-built-in-cache-security-template-and-doctrine-attributes
|
||||
// @see https://github.com/rectorphp/rector-symfony/issues/535#issuecomment-1783983383
|
||||
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [
|
||||
// @see https://github.com/symfony/symfony/pull/46907
|
||||
new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\IsGranted'),
|
||||
// @see https://github.com/symfony/symfony/pull/46880
|
||||
new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Cache'),
|
||||
// @see https://github.com/symfony/symfony/pull/46906
|
||||
new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Template'),
|
||||
]);
|
||||
// https://symfony.com/blog/new-in-symfony-6-2-built-in-cache-security-template-and-doctrine-attributes
|
||||
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
|
||||
// @see https://github.com/symfony/symfony/pull/46907
|
||||
|
|
Loading…
Reference in New Issue
Block a user