mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-26 20:04:48 +01:00
Enforce Name|string for names in builders
While array (with name components) could technically be allowed (as they are supported by the Name node itself), more likely than not an array would due to incorrect usage of the API (e.g. array instead of variadics).
This commit is contained in:
parent
ba625063e7
commit
7ab88416ac
@ -48,9 +48,9 @@ abstract class BuilderAbstract implements Builder {
|
||||
} else {
|
||||
return new Name($name);
|
||||
}
|
||||
} else {
|
||||
return new Name($name);
|
||||
}
|
||||
|
||||
throw new \LogicException('Name must be a string or an instance of PhpParser\Node\Name');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,8 +145,17 @@ DOC;
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Name cannot be empty
|
||||
*/
|
||||
public function testInvalidName() {
|
||||
public function testEmptyName() {
|
||||
$this->createClassBuilder('Test')
|
||||
->extend('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Name must be a string or an instance of PhpParser\Node\Name
|
||||
*/
|
||||
public function testInvalidName() {
|
||||
$this->createClassBuilder('Test')
|
||||
->extend(['Foo']);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user