We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a2d7e89 commit f9fc2fcCopy full SHA for f9fc2fc
2 files changed
lib/PhpParser/Builder/Namespace_.php
@@ -14,10 +14,10 @@ class Namespace_ extends PhpParser\BuilderAbstract
14
/**
15
* Creates a namespace builder.
16
*
17
- * @param Node\Name|string $name Name of the namespace
+ * @param Node\Name|string|null $name Name of the namespace
18
*/
19
public function __construct($name) {
20
- $this->name = $this->normalizeName($name);
+ $this->name = null !== $name ? $this->normalizeName($name) : null;
21
}
22
23
test/PhpParser/Builder/NamespaceTest.php
@@ -33,5 +33,9 @@ public function testCreation() {
33
->getNode()
34
;
35
$this->assertEquals($expected, $node);
36
+
37
+ $node = $this->createNamespaceBuilder(null)->getNode();
38
+ $this->assertNull($node->name);
39
+ $this->assertEmpty($node->stmts);
40
41
0 commit comments