/** * Build callback for method signature * * @param Reflection\AbstractFunction $reflection * @return Method\Callback */ protected function _buildCallback(Reflection\AbstractFunction $reflection) { $callback = new Method\Callback(); if ($reflection instanceof Reflection\ReflectionMethod) { $callback->setType($reflection->isStatic() ? 'static' : 'instance')->setClass($reflection->getDeclaringClass()->getName())->setMethod($reflection->getName()); } elseif ($reflection instanceof Reflection\ReflectionFunction) { $callback->setType('function')->setFunction($reflection->getName()); } return $callback; }
public function testConstructorShouldSetStateFromOptions() { $options = array('type' => 'static', 'class' => 'Foo', 'method' => 'bar'); $callback = new Method\Callback($options); $test = $callback->toArray(); $this->assertSame($options, $test); }