static function get($inst, $record_doc = false, $select = null)
{
$reflection = new \ReflectionClass($inst);
$reader = new AnnotationReader($reflection);
$info = array();
if ($record_doc) {
if (false !== ($doc = $reflection->getDocComment())) {
$info['doc'] = $doc;
}
}
if ($select !== null) {
$select = array_flip($select);
}
foreach ($reader->getClassAnnotations($reflection, $record_doc) as $id => $ann) {
if ($select !== null && !array_key_exists($id, $select)) {
continue;
}
$ann = $ann[0];
//可能有多个重名的, 只取第一个
$info[$id] = $ann;
}
foreach ($reflection->getMethods() as $method) {
foreach ($reader->getMethodAnnotations($method, $record_doc) as $id => $ann) {
if ($select !== null && !array_key_exists($id, $select)) {
continue;
}
$ann = $ann[0];
//可能有多个重名的, 只取第一个
$info += array($id => array());
$info[$id][$method->getName()] = $ann;
}
}
foreach ($reflection->getProperties() as $property) {
foreach ($reader->getPropertyAnnotations($property, $record_doc) as $id => $ann) {
if ($select !== null && !array_key_exists($id, $select)) {
continue;
}
$ann = $ann[0];
//可能有多个重名的, 只取第一个
$info += array($id => array());
$info[$id][$property->getName()] = $ann;
}
}
return $info;
}