示例#1
0
 /**
  * 
  * @param string|object $class
  */
 function __construct($class)
 {
     $this->initFieldsAndPks($class);
     $comment = new \PhpComment\Comment($class);
     $tag = $comment->getClassTag();
     $table_info = explode(' ', $tag->get('table')[0]);
     $this->table_name = $table_info[0];
     $this->alias_name = isset($table_info[1]) ? $table_info[1] : '';
 }
示例#2
0
 function testComment()
 {
     $obj = new ClassWithComment();
     $comment = new \PhpComment\Comment($obj);
     $prop_tags = $comment->getAttributeTags();
     $this->assertArrayHasKey('prop1', $prop_tags);
     $this->assertEquals(["var" => ["string"]], $prop_tags['prop1']->get());
     $func_tags = $comment->getMethodTags();
     $this->assertArrayHasKey('func1', $func_tags);
     $this->assertEquals(['return' => ['boolean']], $func_tags['func1']->get());
     $class_tag = $comment->getClassTag();
     $this->assertEquals(['author' => ['kasonyang']], $class_tag->get());
 }
示例#3
0
文件: App.php 项目: kasonyang/hiano
 /**
  * 
  * @param \Hiano\Controller\Controller $controller
  * @param string $action_name
  */
 private static function dispatchAction($controller, $action_name)
 {
     $phpcomment = new \PhpComment\Comment($controller);
     $action_method_name = Controller\Controller::getActionMethodName($action_name);
     $tag = $phpcomment->getMethodTags()[$action_method_name];
     /* @var $tag \PhpComment\Tags */
     $request = self::getRequest();
     if ($request->isPost()) {
         $validate_tags = $tag->get('hiano-validate');
         if ($validate_tags) {
             foreach ($validate_tags as $v) {
                 $validate_info = explode(' ', $v, 2);
                 $validate_value = self::getRequest()->getPost($validate_info[0]);
                 $validate_validator_names = explode(',', $validate_info[1]);
                 foreach ($validate_validator_names as $vvn) {
                     $validate_ret = \Hiano\Validator\Validator::validate($validate_value, $vvn);
                     $validate_ret or \Hiano\Exception::validateFailed($validate_info[0], $validate_value, $vvn);
                 }
             }
         }
     }
     return $action_ret = $controller->dispatch($action_name);
 }