-
-} // namespace hoplite\base
-
-namespace hoplite\base\internal {
-
-/*!
- An encapsulation of a method implementation.
-*/
-class MethodImp
-{
- /*! @var WeakInterface The interface to which this method belongs. */
- private $interface = NULL;
-
- /*! @var ReflectionMethod The method of the actual interface that this is implementing. */
- private $method = NULL;
-
- /*! @var bool Whether or not this is required. */
- private $required = FALSE;
-
- public function __construct(\hoplite\base\WeakInterface $interface,
- \ReflectionMethod $method)
- {
- $this->interface = $interface;
- $this->method = $method;
- $this->required = strpos($this->method->GetDocComment(), '@required') !== FALSE;
- }
-
- /*! Forwards a method call. */
- public function Invoke($reflector, $args)
- {
- try {
- $impl = $reflector->GetMethod($this->method->name);
- } catch (\ReflectionException $e) {
- if ($this->required)
- throw $e;
- return;
- }
- return $impl->InvokeArgs($this->interface->get(), $args);
- }
-
- /*! Performs method signature validation. */
- public function Matches(\ReflectionMethod $method)
- {
- return $method->GetParameters() == $this->method->GetParameters();
- }
-
- /*! Checks if a method is marked as required. */
- public function IsRequired()
- {
- return $this->required;
- }
-}
-
-} // namespace hoplite\base\internal