public function __call($method, $arguments)
 {
     if (is_callable([$this->object, $method])) {
         $annotations = ReflectionHelper::get_method_annotations($this->object, $method);
         if (count($annotations)) {
             $this->handle_annotations($annotations);
         }
         return call_user_func_array([$this->object, $method], $arguments);
     } else {
         $msg = get_class($this->object) . " has no method {$method}";
         throw new NotExistedMethodException($msg);
     }
 }
 /**
  * @covers common\helpers\ReflectionHelper::get_method_annotations
  * @covers common\helpers\ReflectionHelper::parse_doc_comment
  */
 public function test_get_method_annotations()
 {
     self::assertEquals(ReflectionHelper::get_method_annotations(Annotated::class, 'method'), [['name' => 'credentials', 'value' => 'admin']]);
 }
 /**
  * @covers common\decorators\AnnotationsDecorator::handle_annotations
  * @expectedException \common\exceptions\WrongRequestMethodException
  */
 public function test_handle_annotations_not_ajax()
 {
     $method = new ReflectionMethod($this->obj, 'handle_annotations');
     $method->setAccessible(true);
     $annotations = ReflectionHelper::get_method_annotations('ObjToTestAnnotations', 'add_test');
     /**
      * @var $ext User
      */
     $ext = Application::get_class('User');
     $mapper = $ext->get_mapper();
     $user = $mapper->find_where(['credentials' => ['=', User::credentials_admin]])->one();
     if (empty($user)) {
         $user = $mapper->find_where(['credentials' => ['=', User::credentials_super_admin]])->one();
     }
     $_COOKIE['user'] = $user->remember_hash;
     $method->invoke($this->obj, $annotations);
 }