Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
28 changes: 0 additions & 28 deletions rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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));
}
}
}
}
2 changes: 0 additions & 2 deletions src/NodeTypeResolver/Node/AttributeKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Loading