Is it possible to use imported namespaces with AttributeKeyToClassConstFetchRector? #7934
-
Bug Report/Feature request
Minimal PHP Code Causing IssueSee https://getrector.com/demo/a460202b-0782-4844-b547-14f975bbc2b2 <?php
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
class DemoFile
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private int $id;
#[ORM\Column(type: 'string')]
private string $name;
} Responsible rules
Expected BehaviorCurrently, both columns are changed so that they use the FQCN <?php
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
class DemoFile
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private int $id;
#[ORM\Column(type: Types::STRING)]
private string $name;
} alternatively, this would also work (only touch changed lines, i.e. lines that use a literal instead of a class-constant): <?php
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
class DemoFile
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private int $id;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
private string $name;
} I know that I could use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can create custom rule for only import specific fqcn, not all of fqcn, so you need to replace FullyQualied to Name on specific node if exists on use statement. |
Beta Was this translation helpful? Give feedback.
You can create custom rule for only import specific fqcn, not all of fqcn, so you need to replace FullyQualied to Name on specific node if exists on use statement.