You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want create Rector that import missed imports for doctrine annotations for example:
declare(strict_types=1);
+use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class Entity
{
}
I found out that I can add new imports via UseNodesToAddCollector. UseNodesToAddCollector can only use FullyQualifiedObjectType as input, but can return AliasedObjectType. Moreover some annotations do not take into account that UseNodesToAddCollector can return AliasedObjectType
I think that UseNodesToAddCollector must be able to accept AliasedObjectType as input.
May be we should introduce interface for FullyQualifiedObjectType and AliasedObjectType.
I think that this code will be more semantic
if ($this->shouldAddUse($phpDocInfo)) {
- $this->useNodesToAddCollector->addUseImport(new FullyQualifiedObjectType('Doctrine\ORM\Mapping as ORM'));+ $this->useNodesToAddCollector->addUseImport(new AliasedObjectType('ORM', 'Doctrine\ORM\Mapping'));
return $node;
}
May be I even could provide PR after some research.
The text was updated successfully, but these errors were encountered:
Feature Request
I want create Rector that import missed imports for doctrine annotations for example:
declare(strict_types=1); +use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity */ class Entity { }
I found out that I can add new imports via
UseNodesToAddCollector
.UseNodesToAddCollector
can only useFullyQualifiedObjectType
as input, but can returnAliasedObjectType
. Moreover some annotations do not take into account thatUseNodesToAddCollector
can returnAliasedObjectType
I think that UseNodesToAddCollector must be able to accept
AliasedObjectType
as input.May be we should introduce interface for
FullyQualifiedObjectType
andAliasedObjectType
.I think that this code will be more semantic
May be I even could provide PR after some research.
The text was updated successfully, but these errors were encountered: