phprs\util\MetaInfo::get PHP Method

get() static public method

获取元信息
static public get ( object | class $inst, boolean $record_doc = false, $select = null ) : array
$inst object | class
$record_doc boolean 是否加载注释文本, 如果是
return array
    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;
    }