/** * * @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] : ''; }
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()); }