diff --git a/CHANGELOG.md b/CHANGELOG.md index 1011f17..bee2cf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,11 +11,6 @@ Version 4.0.4-dev * `var()` * `propertyFetch()` -### Changed - -* Passing a string with a leading backslash to the `Name` constructor will now throw an exception. - Most likely a use of `Name\FullyQualified` was intended. - ### Deprecated * `Builder\Param::setTypeHint()` has been deprecated in favor of the newly introduced diff --git a/lib/PhpParser/Node/Name.php b/lib/PhpParser/Node/Name.php index 32ca723..5d923d0 100644 --- a/lib/PhpParser/Node/Name.php +++ b/lib/PhpParser/Node/Name.php @@ -222,10 +222,6 @@ class Name extends NodeAbstract throw new \InvalidArgumentException('Name cannot be empty'); } - if ('\\' === $name[0]) { - throw new \InvalidArgumentException('Name cannot start with backslash. Did you mean to use Name\FullyQualified?'); - } - return explode('\\', $name); } elseif (\is_array($name)) { if (empty($name)) { diff --git a/test/PhpParser/Node/NameTest.php b/test/PhpParser/Node/NameTest.php index a035b79..8fe9ed6 100644 --- a/test/PhpParser/Node/NameTest.php +++ b/test/PhpParser/Node/NameTest.php @@ -155,14 +155,6 @@ class NameTest extends TestCase new Name([]); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Name cannot start with backslash. Did you mean to use Name\FullyQualified? - */ - public function testInvalidLeadingBackslash() { - new Name('\Foo'); - } - /** @dataProvider provideTestIsSpecialClassName */ public function testIsSpecialClassName($name, $expected) { $name = new Name($name);