nette/php-generator

class names resolving in use as

zengbo opened this issue · 0 comments

Version: 4.0.6

Bug Description

When I use a trait method in a class by use as, the trait will use the full name.

Steps To Reproduce

  1. The origin PHP file d.php
<?php

use A\B\C

class D
{
    use C {
       C::abc as acd;
    }
}
  1. Use Phpfile to parse the PHP file and print it
<?php

$php = PhpFile::fromCode(file_get_contents('d.php'));
(new PsrPrinter())->printFile($php);
  1. output:
<?php

use A\B\C

class D
{
    use C {
       \A\B\C::abc as acd;
    }
}

Expected Behavior

<?php

use A\B\C

class D
{
    use C {
       C::abc as acd;
    }
}

Possible Solution

... Only if you have suggestions on a fix for the bug