mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-30 04:29:15 +01:00
parent
0cd7207ca6
commit
2f67429ec9
@ -8,6 +8,11 @@ Version 4.0.4-dev
|
||||
* `useConst()`
|
||||
* `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.
|
||||
|
||||
Version 4.0.3 (2018-07-15)
|
||||
--------------------------
|
||||
|
@ -222,6 +222,10 @@ 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)) {
|
||||
|
@ -155,6 +155,14 @@ 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);
|
||||
|
Loading…
Reference in New Issue
Block a user