mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2025-01-21 21:01:15 +01:00
Add support for global namespace in NS builder
NULL argument can now be used to create a global namespace {} block.
This commit is contained in:
parent
a2d7e8977a
commit
f9fc2fc9ee
@ -14,10 +14,10 @@ class Namespace_ extends PhpParser\BuilderAbstract
|
||||
/**
|
||||
* Creates a namespace builder.
|
||||
*
|
||||
* @param Node\Name|string $name Name of the namespace
|
||||
* @param Node\Name|string|null $name Name of the namespace
|
||||
*/
|
||||
public function __construct($name) {
|
||||
$this->name = $this->normalizeName($name);
|
||||
$this->name = null !== $name ? $this->normalizeName($name) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,5 +33,9 @@ class NamespaceTest extends \PHPUnit_Framework_TestCase
|
||||
->getNode()
|
||||
;
|
||||
$this->assertEquals($expected, $node);
|
||||
|
||||
$node = $this->createNamespaceBuilder(null)->getNode();
|
||||
$this->assertNull($node->name);
|
||||
$this->assertEmpty($node->stmts);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user