Skip to content

Commit d00eaff

Browse files
committed
PhpFile: bracketed syntax is normalized when namespace is added
1 parent e87187f commit d00eaff

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/PhpGenerator/PhpFile.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public function addNamespace(string $name): PhpNamespace
5858
{
5959
if (!isset($this->namespaces[$name])) {
6060
$this->namespaces[$name] = new PhpNamespace($name);
61+
foreach ($this->namespaces as $namespace) {
62+
$namespace->setBracketedSyntax(count($this->namespaces) > 1 && isset($this->namespaces['']));
63+
}
6164
}
6265
return $this->namespaces[$name];
6366
}
@@ -74,10 +77,6 @@ public function getNamespaces(): array
7477

7578
public function __toString(): string
7679
{
77-
foreach ($this->namespaces as $namespace) {
78-
$namespace->setBracketedSyntax(count($this->namespaces) > 1 && isset($this->namespaces['']));
79-
}
80-
8180
return Strings::normalize(
8281
"<?php\n"
8382
. ($this->comment ? "\n" . Helpers::formatDocComment($this->comment . "\n") . "\n" : '')

0 commit comments

Comments
 (0)