diff --git a/rules-tests/Php80/Rector/Property/NestedAnnotationToAttributeRector/Fixture/doctrine_join_column_nested_in_join_table.php.inc b/rules-tests/Php80/Rector/Property/NestedAnnotationToAttributeRector/Fixture/doctrine_join_column_nested_in_join_table.php.inc index f26552de233..1c6a5a2eb21 100644 --- a/rules-tests/Php80/Rector/Property/NestedAnnotationToAttributeRector/Fixture/doctrine_join_column_nested_in_join_table.php.inc +++ b/rules-tests/Php80/Rector/Property/NestedAnnotationToAttributeRector/Fixture/doctrine_join_column_nested_in_join_table.php.inc @@ -21,14 +21,13 @@ final class DoctrineJoinColumnNestedInJoinTable namespace Rector\Tests\Php80\Rector\Property\NestedAnnotationToAttributeRector\Fixture; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; final class DoctrineJoinColumnNestedInJoinTable { #[JoinTable(name: 'lemma_type')] - #[InverseJoinColumn(name: 'lemma_id', referencedColumnName: 'lemma_id')] + #[\Doctrine\ORM\Mapping\InverseJoinColumn(name: 'lemma_id', referencedColumnName: 'lemma_id')] private iterable $lemmas; } diff --git a/rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php b/rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php index 2de4cc0b888..34205f90beb 100644 --- a/rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php +++ b/rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php @@ -19,14 +19,11 @@ use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\Naming\Naming\UseImportsResolver; -use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Php80\NodeFactory\NestedAttrGroupsFactory; use Rector\Php80\ValueObject\AnnotationPropertyToAttributeClass; use Rector\Php80\ValueObject\NestedAnnotationToAttribute; use Rector\Php80\ValueObject\NestedDoctrineTagAndAnnotationToAttribute; -use Rector\PhpParser\Node\FileNode; use Rector\Rector\AbstractRector; -use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\ValueObject\PhpVersion; use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; @@ -125,7 +122,6 @@ public function refactor(Node $node): ?Node $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node); $node->attrGroups = array_merge($node->attrGroups, $attributeGroups); - $this->completeExtraUseImports($attributeGroups); return $node; } @@ -205,28 +201,4 @@ private function matchAnnotationToAttribute( return null; } - - /** - * @param AttributeGroup[] $attributeGroups - */ - private function completeExtraUseImports(array $attributeGroups): void - { - $fileNode = $this->file->getFileNode(); - if (! $fileNode instanceof FileNode) { - return; - } - - $pendingImports = $fileNode->getPendingImports(); - - foreach ($attributeGroups as $attributeGroup) { - foreach ($attributeGroup->attrs as $attr) { - $namespacedAttrName = $attr->name->getAttribute(AttributeKey::EXTRA_USE_IMPORT); - if (! is_string($namespacedAttrName)) { - continue; - } - - $pendingImports->addUseImport(new FullyQualifiedObjectType($namespacedAttrName)); - } - } - } } diff --git a/src/NodeTypeResolver/Node/AttributeKey.php b/src/NodeTypeResolver/Node/AttributeKey.php index c902a3ae221..a8d933970b0 100644 --- a/src/NodeTypeResolver/Node/AttributeKey.php +++ b/src/NodeTypeResolver/Node/AttributeKey.php @@ -75,8 +75,6 @@ final class AttributeKey */ public const string PHP_ATTRIBUTE_NAME = 'php_attribute_name'; - public const string EXTRA_USE_IMPORT = 'extra_use_import'; - /** * Used internally by php-parser */ diff --git a/src/PhpAttribute/NodeFactory/PhpNestedAttributeGroupFactory.php b/src/PhpAttribute/NodeFactory/PhpNestedAttributeGroupFactory.php index ad24174e6c5..16344e4e599 100644 --- a/src/PhpAttribute/NodeFactory/PhpNestedAttributeGroupFactory.php +++ b/src/PhpAttribute/NodeFactory/PhpNestedAttributeGroupFactory.php @@ -22,7 +22,6 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode; use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; use Rector\Exception\ShouldNotHappenException; -use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Php80\ValueObject\AnnotationPropertyToAttributeClass; use Rector\Php80\ValueObject\NestedAnnotationToAttribute; use Rector\PhpAttribute\AnnotationToAttributeMapper; @@ -254,10 +253,7 @@ private function createFromExplicitProperties( if ($annotationPropertyToAttributeClass->doesNeedNewImport() && count( $attributeName->getParts() ) === 1) { - $attributeName->setAttribute( - AttributeKey::EXTRA_USE_IMPORT, - $annotationPropertyToAttributeClass->getAttributeClass() - ); + $attributeName = new FullyQualified($annotationPropertyToAttributeClass->getAttributeClass()); } $attribute = new Attribute($attributeName, $attributeArgs);