mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-27 04:24:43 +01:00
Merge branch '1.x'
This commit is contained in:
commit
ebeeae19a6
@ -36,8 +36,12 @@ class Use_ extends BuilderAbstract {
|
||||
$this->alias = $alias;
|
||||
return $this;
|
||||
}
|
||||
public function __call($method, $args) {
|
||||
return call_user_func_array(array($this, $method . '_'), $args);
|
||||
public function __call($name, $args) {
|
||||
if (method_exists($this, $name . '_')) {
|
||||
return call_user_func_array(array($this, $name . '_'), $args);
|
||||
}
|
||||
|
||||
throw new \LogicException(sprintf('Method "%s" does not exist', $name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,4 +26,10 @@ class UseTest extends \PHPUnit_Framework_TestCase
|
||||
new Stmt\UseUse(new Name('foo\bar'), 'foo')
|
||||
), Stmt\Use_::TYPE_FUNCTION), $node);
|
||||
}
|
||||
|
||||
public function testNonExistingMethod() {
|
||||
$this->setExpectedException('LogicException', 'Method "foo" does not exist');
|
||||
$builder = $this->createUseBuilder('Test');
|
||||
$builder->foo();
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,12 @@ class BuilderFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testNonExistingMethod() {
|
||||
$this->setExpectedException('LogicException', 'Method "foo" does not exist');
|
||||
$factory = new BuilderFactory();
|
||||
$factory->foo();
|
||||
}
|
||||
|
||||
public function testIntegration() {
|
||||
$factory = new BuilderFactory;
|
||||
$node = $factory->namespace('Name\Space')
|
||||
|
Loading…
Reference in New Issue
Block a user