Closed maximecaze closed 2 years ago
Can you add a test to see what it does?
After consideration, I am not sure this change is legitimate, but I am curious of this change https://github.com/nette/php-generator/commit/0e283d971b31b10167bd9807c64a43e0aac29ba9#diff-d20ef32e1a8b64805a08e16ce09ecafc0eb6487be1c47b8bd0766857b596244b. Before that, when we add uses of the same namespace than the generated class, the use does not appear, because there is no need.
Ex with a generated class FooBar:
$extends = Foo\Bar::class;
$file = new \Nette\PhpGenerator\PhpFile();
$namespace = $file->addNamespace('Foo')->addUse($extends);
$class = $namespace->addClass('FooBar');
$class->setExtends($extends);
...
<?php
namespace Foo;
use Foo/Bar; // no need of that because of Bar class has same namespace than FooBar class
class FooBar extends Bar {}
What do you think ? I am sorry, I am not confortable with these tests yet, I did not succeed to write the correct test...
Fixed
Do not print uses for namespace uses issued from the same namespace