Merge branch '1.x'

This commit is contained in:
Nikita Popov 2015-07-12 22:12:28 +02:00
commit ebeeae19a6
3 changed files with 18 additions and 2 deletions

View File

@ -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));
}
/**

View File

@ -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();
}
}

View File

@ -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')