Skip to content

Commit

Permalink
Printer: fixed use statements generation
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 27, 2018
1 parent 7984eca commit 1da768f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/PhpGenerator/PhpNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ public function __toString(): string
{
$uses = [];
foreach ($this->uses as $alias => $original) {
$useNamespace = Helpers::extractNamespace($original);

if ($this->name !== $useNamespace) {
if ($original !== ($this->name ? $this->name . '\\' . $alias : $alias)) {
if ($alias === $original || substr($original, -(strlen($alias) + 1)) === '\\' . $alias) {
$uses[] = "use $original;";
} else {
Expand Down

0 comments on commit 1da768f

Please sign in to comment.