From 1da768f28362933ba6ffa2d9650a1ae74f6b5759 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 27 Nov 2018 19:52:40 +0100 Subject: [PATCH] Printer: fixed use statements generation --- src/PhpGenerator/PhpNamespace.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/PhpGenerator/PhpNamespace.php b/src/PhpGenerator/PhpNamespace.php index 8de17c84..c4031106 100644 --- a/src/PhpGenerator/PhpNamespace.php +++ b/src/PhpGenerator/PhpNamespace.php @@ -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 {