Skip to content

Conversation

@maximecaze
Copy link

  • bug fix
  • BC break? no
  • doc PR: -

Do not print uses for namespace uses issued from the same namespace

@dg
Copy link
Member

dg commented Nov 12, 2021

Can you add a test to see what it does?

@maximecaze
Copy link
Author

After consideration, I am not sure this change is legitimate, but I am curious of this change 0e283d9#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...

@dg
Copy link
Member

dg commented Nov 16, 2021

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants