map转换为数据模型
@param string $class
@param array $map
@return object|void
@throws HeroException
15241
public static function map2Model($class, $map) {
        if( !$map ) return;
        //字符串类路径
        if( is_string($class) ) {
            $refClass = new \ReflectionClass($class);
            $obj = $refClass->newInstance();
        } else {    //安装对象
            $obj = $class;
            $refClass = new ReflectionClass($obj);
        }
        $methodName = NULL;
        $method = NULL;
        foreach( $map as $key => $value ) {
            $methodName = "set" . ucwords(StringUtils::underline2hump($key));
            if( $refClass->hasMethod($methodName )){
                $method = $refClass->getMethod($methodName);
                try {
                    $method->invoke($obj, $map[$key]);
                } catch (\Exception $e) {
                    throw new HeroException($e->getMessage());
                }
            }
        }
        return $obj;
    }
361132
public function mapField(array $mapping)
    {
        if (isset($this->fieldMappings[$mapping['fieldName']])) {
            throw MappingException::duplicateFieldMapping($this->className, $mapping['fieldName']);
        }
        $this->fieldMappings[$mapping['fieldName']] = $mapping;
    }
921233
protected static function loadMappings(/*# string */ $class)
    {
        // mapping status changed ?
        if (self::isStatusUpdated()) {
            self::resetMappings();
            self::setStatus(false);
        }

        // $class' mapping loaded already
        if ($class::hasMappings()) {
            return;
        }

        // load $class mapping
        $loadedClass = $class::hasLoader();
        if ($loadedClass) {
            // loader found
            $class::setMappings(
                $loadedClass::getLoader()->loadMessages($class)
            );
        } else {
            // no loader found
            $class::setMappings([]);
        }
    }
816262
public function save($data, $map)
    {
        is_array($map) || $map = [
            'id' => $map
        ];
        
        // 修改时间
        if ($this->autoWriteTimestamp && ! (isset($data[$this->updateTime]) && $data[$this->updateTime])) {
            $data[$this->updateTime] = time();
        }
        
        return $this->where($map)->update($data);
    }
932171
function map(classMap) {
		if (typeof classMap === 'function') {
			options.classMap = classMap;
		} else {
			options.classMap = function (className) {
				return classMap[className] || className;
			};
		}
	}
1067878
private function getObjectMapping(string $class): NormalizationObjectMappingInterface
    {
        try {
            return $this->normalizerObjectMappingRegistry->getObjectMapping($class);
        } catch (SerializerLogicException $exception) {
            $this->logger->error('serialize: {exception}', ['exception' => $exception->getMessage()]);

            throw $exception;
        }
    }
818856
public function map($class, $presenter = null)
    {
        if (is_array($class)) {
            foreach ($class as $model => $present) {
                $this->mappings->put($model, $present);
            }
        } else {
            $this->mappings->put($class, $presenter);
        }
    }
1261283
protected function registerClassMap(array $classMap)
    {
        foreach ($classMap as $file) {
            $arrClasses = require $file;
            if (!ArrayUtils::isHashTable($arrClasses, true)) {
                throw new Exception\RuntimeException('Config autoload for classmap is invalid');
            }

            if (!empty($arrClasses)) {
                $this->loader->registerClasses($arrClasses);
            }
        }
    }
803790
protected function build(array $map) {
		$overrides = [];
		foreach ($map as $method => $array) {
			$mapDefinitions = $this->buildMapDefinitions($array);

			$overrides[] = <<<TXT
	override(
		$method,
		map([
$mapDefinitions
		])
	);
TXT;

		}
		$overrides = implode(PHP_EOL . PHP_EOL, $overrides);

		$template = <<<TXT
<?php
// @link https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata
namespace PHPSTORM_META {

$overrides

}

TXT;

		return $template;
	}
1003543
public function setDiscriminatorMap(array $map) : void
    {
        if ($this->isFile) {
            throw MappingException::discriminatorNotAllowedForGridFS($this->name);
        }

        $this->subClasses         = [];
        $this->discriminatorMap   = [];
        $this->discriminatorValue = null;

        foreach ($map as $value => $className) {
            $this->discriminatorMap[$value] = $className;
            if ($this->name === $className) {
                $this->discriminatorValue = $value;
            } else {
                if (! class_exists($className)) {
                    throw MappingException::invalidClassInDiscriminatorMap($className, $this->name);
                }
                if (is_subclass_of($className, $this->name)) {
                    $this->subClasses[] = $className;
                }
            }
        }
    }
268456
protected function typeMapReducer(array $map, $type)
    {
        if ($type instanceof ModifierInterface) {
            return $this->typeMapReducer($map, $type->getWrappedType());
        }

        if (!$type instanceof TypeInterface) {
            return $map;
        }

        if (!empty($map[$type->getName()])) {
            if ($type instanceof ObjectType || $type instanceof InterfaceType) {
                $type->setFields($map[$type->getName()]->getFields());
            }

            return $map;
        }

        $reducedMap = array_merge($map, [$type->getName() => $type]);
        if ($type instanceof InterfaceType || $type instanceof UnionType) {
            $reducedMap = array_reduce(
                $type->getPossibleTypes(), [$this, 'typeMapReducer'], $reducedMap
            );
        }

        if ($type instanceof ObjectType) {
            $reducedMap = array_reduce(
                $type->getInterfaces(), [$this, 'typeMapReducer'], $reducedMap
            );
        }

        if ($type instanceof ObjectType || $type instanceof InterfaceType) {
            foreach ($type->getFields() as $fieldName => $field) {
                $args = $field->getArguments();
                $reducedMap = array_reduce(array_map(function (FieldArgument $arg) {
                    return $arg->getType();
                }, $args), [$this, 'typeMapReducer'], $reducedMap);

                $reducedMap = $this->typeMapReducer($reducedMap, $field->getType());
            }
        }

        return $reducedMap;
    }
561098
public static function setApiClass($class = '', $action = '') {
        try {
            $file = ROOT_DIR . "/api/" . $class . ".php";
            $new  = ROOT_DIR . "/server/controllers/" . $class . md5($class) . ".php";
            if (!is_file($file) && is_file($new)) {
                return;
            }
            #如果文件不存在 提示创建
            if (!is_file($file)) {
                $name = md5($class);
                if (isset($_GET['key']) && $_GET['key'] == $name) {
                    $php = <<<PHP
<?php
class $class {
    public function index() {
        echo "欢迎访问API";
    }
}
PHP;
                    to_mkdir($file, $php, true, true);
                    redirect("api/" . $class . '/index');
                } else {
                    throw new Exception("您访问的Api控制器类不存在", ErrorCode::$ClassDoesNotExist);
                }
            }
            #执行编译
            $status = DEBUG || !file_exists($new) || !is_file($new) || (filemtime($file) > filemtime($new));
            if ($status) {
                #修改命名空间
                $content   = file_get_contents($file);
                $namespace = '<?php
namespace server\controllers;
use \Exception;';
                $content = preg_replace('/^\<\?php/is', $namespace, $content);
                #解析类名称
                $content = preg_replace('/class\s?(' . $class . ')/is', 'class ' . $class . md5($class), $content);
                #解析变量数集
                $content = preg_replace("/R\s*\(\s*function\s*\(([\w\$]*)\)\s*\{/is", 'return R(function (\1){extract(\1);', $content);
                $content = preg_replace("/callFunc\s*\(\s*function\s*\(([\w\$]*)\)\s*\{/is", 'callFunc(function (\1){extract(\1);', $content);
                to_mkdir($new, $content, true, true);
                #压缩PHP代码
                $content = DEBUG ? $content : php_strip_whitespace($new);
                to_mkdir($new, $content, true, true);
            }
        } catch (Exception $e) {
            ERRORCODE($e);
        }
    }
1211194
public <K, V> Map<K, V> asMap(@NonNull Class<?> mapClass, @NonNull Class<K> keyClass, @NonNull Class<V> valueClass) {
      return convert(toConvert, mapClass, keyClass, valueClass);
   }
113
public function register_action_map($map)
    {
        if (is_array($map)) {
            foreach ($map as $idx => $val) {
                $this->action_map[$idx] = $val;
            }
        }
    }
29610
public function xor(Map $map): Map
    {
        return $this->merge($map)->filter(function($key) use ($map) {
            return $this->hasKey($key) ^ $map->hasKey($key);
        });
    }
547962
@SuppressWarnings("unchecked")
    public static <K, V> K[] mapKeyToArray(Map<K, V> map, Class<K> clazz) {
        if (Checker.isNotEmpty(map)) {
            K[] array = (K[]) Array.newInstance(clazz, map.size());
            int i = 0;
            for (K k : map.keySet()) {
                array[i++] = k;
            }
            return array;
        }
        return null;
    }
380891
public function mapManyReference(ClassMetadata $class, $type = Type::LIST_)
    {
        $this->reference = true;
        $this->type      = $type;

        $this->mapAttribute($class);
    }