读取字典内容
@param $dictname
353230
static function get($dictname)
	{
		if(!\Swoole::$php->cache) Error::info('SiteDict Cache Error','Please load Cache!');
		$cache_key = 'sitedict_'.$dictname;
		$$dictname = \Swoole::$php->cache->get($cache_key);
		if(empty($$dictname))
		{
			$data_file = self::$data_dir.'/'.$dictname.'.php';
			if(!file_exists($data_file)) Error::info('SiteDict dict file not found!',"File <b>$data_file</b> not found!");
			require($data_file);
			\Swoole::$php->cache->set($cache_key,$$dictname,self::$cache_life);
		}
		return $$dictname;
	}
851713
private function load_dict()
    {
        if (is_array($this->dict)) {
            return $this->dict;
        }

        if (strcasecmp($this->options['dictionary'], 'shared') != 0) {
            $userid = $this->rc->get_user_id();
        }

        $plugin = $this->rc->plugins->exec_hook('spell_dictionary_get', array(
            'userid' => $userid, 'language' => $this->lang, 'dictionary' => array()));

        if (empty($plugin['abort'])) {
            $dict = array();
            $sql_result = $this->rc->db->query(
                "SELECT `data` FROM " . $this->rc->db->table_name('dictionary', true)
                ." WHERE `user_id` ". ($plugin['userid'] ? "= ".$this->rc->db->quote($plugin['userid']) : "IS NULL")
                    ." AND `language` = ?",
                $plugin['language']);

            if ($sql_arr = $this->rc->db->fetch_assoc($sql_result)) {
                $this->have_dict = true;
                if (!empty($sql_arr['data'])) {
                    $dict = explode(' ', $sql_arr['data']);
                }
            }

            $plugin['dictionary'] = array_merge((array)$plugin['dictionary'], $dict);
        }

        if (!empty($plugin['dictionary']) && is_array($plugin['dictionary'])) {
            $this->dict = $plugin['dictionary'];
        }
        else {
            $this->dict = array();
        }

        return $this->dict;
    }
402641
public function delete($key)
    {
        $keys = explode('.', $key);
        $key_string = '';
        foreach ($keys as $i => $_key) {
            $key_string = $key_string . ((is_numeric($_key) || $_key === '') ? "[{$_key}]" : "['{$_key}']");
        }
        $script = sprintf('unset($this->_params%s);', $key_string);
        eval($script);
    }
33987
public function get($name) {
        N('cache_read',1);
        $value = $this->handler->get($this->options['prefix'].$name);
        $jsonData  = json_decode( $value, true );
        return ($jsonData === NULL) ? $value : $jsonData;	//检测是否为JSON数据 true 返回JSON解析数组, false返回源数据
    }
1362664
public function loadJson($filename)
  {
    $result = false;
    if (file_exists($filename) && is_file($filename)) {
      $json = file_get_contents($filename);
      $data = json_decode($json, true);
      if (is_array($data)) {
        foreach ($data as $name => $value) {
          $this->__set($name, $value);
        }
        $result = true;
      }
    }
    return $result;
  }
1176687
private static function readFile(string $fileName): ?array
    {
        //配置文件名
        $fullName = $fileName . '.config.php';

        //逐个配置文件目录查找
        foreach (self::$dirs as $dir) {
            try {
                $content = requireFile($dir . DIRECTORY_SEPARATOR . $fullName);
            } catch (RequireFileException $e) {
                continue;
            }
            if ($content) {
                if (!is_array($content)) {
                    throw new ConfigException('配置文件内容必须是数组', ConfigException::CONTENT_NOT_ARRAY);
                }
                return $content;
            }
        }

        //未找到
        return null;
    }
987862
public function configure($name)
    {
        if (isset($this->loadedConfigurations[$name])) {
            return;
        }
        //标记为已加载
        $this->loadedConfigurations[$name] = true;
        $path = $this->getConfigurationPath($name);
        if ($path) {
            $this->make('config')->set($name, require $path);
        }
    }
447945
protected function init($serverName, $DriverOrIndex, $configIndex)
    {
        $this->serverName = $serverName;

        //1.外部指定实例
        if (is_object($DriverOrIndex)) {
            $this->rwDriver['r'] = $this->rwDriver['w'] = $DriverOrIndex;
            $this->rwIndex['r']  = $this->rwIndex['w']  = 'user'; //标记为用户指定的驱动
            $this->index         = $this->rwIndex['r'];
            $this->Driver        = $this->rwDriver['r']; //默认使用读
            return;
        }

        //2.获得指定服务器索引
        if (is_string($DriverOrIndex) || is_int($DriverOrIndex)) {
            $configIndex = $DriverOrIndex; //优先级更高
        }
        if (!isset(self::$cacheIndex[$serverName][$configIndex])) {
            $this->parseServerIndex($configIndex); //解析可使用的服务器索引
        }

        //3.设置驱动
        $indexWeight = self::$cacheIndex[$serverName][$configIndex];
        if (!empty($indexWeight['r'])) {
            $this->rwIndex['r']  = $this->chooseDriver($indexWeight['r']);
            $this->rwDriver['r'] = self::$servers[$serverName][$this->rwIndex['r']];
        }
        if (!empty($indexWeight['w'])) {
            $this->rwIndex['w']  = $this->chooseDriver($indexWeight['w']);
            $this->rwDriver['w'] = self::$servers[$serverName][$this->rwIndex['w']];
        }

        //4.选择服务器，读优先
        if ($this->rwDriver['r']) {
            $this->index  = $this->rwIndex['r'];
            $this->Driver = $this->rwDriver['r'];
        } else if ($this->rwDriver['w']) {
            $this->index  = $this->rwIndex['w'];
            $this->Driver = $this->rwDriver['w'];
        } else {
            $this->exception('服务器连接失败', 'r: ' . $this->rwDriver['r'] . '; w: ' . $this->$this->rwDriver['w']);
        }

    }
1189387
public function load($filename)
    {
        $json = file_get_contents($filename);
        if (false === $json) {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException("Unable to load file {$filename}");
            // @codeCoverageIgnoreEnd
        }

        $data = Utils::jsonDecode($json, true);
        if (is_array($data)) {
            foreach (Utils::jsonDecode($json, true) as $cookie) {
                $this->setCookie(new SetCookie($cookie));
            }
        } elseif (strlen($data)) {
            throw new \RuntimeException("Invalid cookie file: {$filename}");
        }
    }
52853
public function __isset($name)
    {
        // 存在字段映射，则被映射的对象属性必能访问
        if($this->columnMap && key_exists($name, $this->columnMap)) {
            // 显式声明属性名
            $attr = $this->columnMap[$name];
            return !is_null($this->$attr);
        }

        return key_exists($name, $this->attrs);
    }
383328
public function setFromName($fieldName)
    {
        if (empty($this->name)) {
            $this->name = $fieldName;
        }
        $this->attrName = $this->getAttrName();
        $this->concrete = false === empty($this->getColumnName());

        if (empty($this->verboseName)) {
            $this->verboseName = ucwords(
                str_replace(
                    '_',
                    ' ',
                    $this->name
                )
            );
        }
    }
769131
function fetch_object($sql)
    {
        $rs   = $this->query($sql);
        $data = $rs->fetch_object();

        $rs->free(); //释放内存
        return $data;
    }
102594
private function ensuredEraseDir($dirname)
    {
        try
        {
            $listing = $this->fs->listContents($dirname, false);

            foreach ($listing as $item)
            {
                if ($item['type'] === 'dir')
                {
                    $this->fs->deleteDir($item['path']);
                }
                else
                {
                    $this->fs->delete($item['path']);
                }
            }

            return;
        }
        catch (Error $ex)
        {}
        catch (Exception $ex)
        {}

        throw new WriteException("Directory $dirname could not be erased.", 0, $ex);
    }
767430
protected function checkFileSize($filename) {

        if ( filesize($filename) > $this->config['max_size'] ) {
            $this->errNum = 1;
        }

        //如果是图片还要检查图片的宽度和高度是否超标
        $size = getimagesize($filename);
        if ( $size != false ) {

            $this->fileInfo['is_image'] = 1;
            if ( ($this->config['max_width'] > 0 && $size[0] > $this->config['max_width'])
                || ($this->config['max_height'] > 0 && $size[1] > $this->config['max_height']) )  {
                $this->errNum = 9;
            }
            $this->fileInfo['image_width'] = $size[0];
            $this->fileInfo['image_height'] = $size[1];

        } else {

            $this->fileInfo['is_image'] = 0;

        }

	}
1264533
protected function serializeIndexNameToAttribute($indexName)
    {
        if (strtolower($indexName) === 'primary') {
            $indexName = 'prim';
        }
        $indexName = str_replace(['ID'], ['Id'], $indexName);

        return '\'' . snake_case($indexName) . '\'';
    }
905278
public function enableShardingForDbByDocumentName(string $documentName) : void
    {
        $dbName  = $this->dm->getDocumentDatabase($documentName)->getDatabaseName();
        $adminDb = $this->dm->getClient()->selectDatabase('admin');

        try {
            $adminDb->command(['enableSharding' => $dbName]);
        } catch (ServerException $e) {
            // Don't throw an exception if sharding is already enabled; there's just no other way to check this
            if ($e->getCode() !== self::CODE_SHARDING_ALREADY_INITIALIZED) {
                throw MongoDBException::failedToEnableSharding($dbName, $e->getMessage());
            }
        } catch (RuntimeException $e) {
            throw MongoDBException::failedToEnableSharding($dbName, $e->getMessage());
        }
    }
989559
public function get_config_json( $filename ) {
		if ( isset( $this->loaded[ $filename ] ) ) {
			return $this->loaded[ $filename ];
		}

		$config = $this->path . 'config/' . $filename . '.json';

		if ( ! file_exists( $config ) ) {
			return null;
		}

		$contents = file_get_contents( $config );

		if ( false === $contents ) {
			return null;
		}

		return $this->loaded[ $filename ] = json_decode( $contents, true );
	}