数据错误接口
@param  [type] $args [description]
@return [type]       [description]
16681
public static function error($args) {
        if (is_string($args) || is_numeric($args)) {
            return [0, '成功', $args, ''];
        }
        if (is_array($args) && isset($args['__def'])) {
            unset($args['__def']);
            return [0, '成功', $args, ''];
        }
        #根据不同的参数个数进行判断
        switch (count($args)) {
        case 0:
            return [0, '成功', [], ''];
            break;
        case 1:
            $arg1 = reset($args);
            #如果是数字
            if (is_numeric($arg1)) {
                if ($arg1 === 0) {
                    return [0, '成功', [], ''];
                } else {
                    return [$arg1, '错误', [], ''];
                }
            }
            #如果是字符串
            if (is_string($arg1)) {
                return [0, $arg1, [], ''];
            }
            #如果是数组
            if (is_array($arg1)) {
                if (empty($arg1)) {
                    return [-2, '数据为空', [], ''];
                } else {
                    return [0, '成功', $arg1, ''];
                }
            }
            break;
        case 2:
            $arg1 = reset($args);
            $arg2 = next($args);
            if (is_numeric($arg1) && is_string($arg2)) {
                return [$arg1, $arg2, [], ''];
            }
            if (is_string($arg1) && is_array($arg2)) {
                if (empty($arg2)) {
                    return [-2, $arg1, [], ''];
                } else {
                    return [0, '成功', $arg2, ''];
                }
            }
            if (is_array($arg1) && is_array($arg2)) {
                #如果数组为空
                if (empty($arg2) && empty($arg1)) {
                    return [-2, '失败', [], ''];
                }
                #如果第二个参数为空
                elseif (empty($arg2)) {
                    return [-2, reset($arg1), [], ''];
                } else {
                    $arg1 = next($arg1);
                    $arg1 = empty($arg1) ? '成功' : $arg1;
                    return [0, $arg1, $arg2, ''];
                }
            }
            break;
        case 3:
            $arg1 = reset($args);
            $arg2 = next($args);
            $arg3 = next($args);
            if (is_object($arg1) && is_string($arg2) && is_array($arg3)) {
                return [$arg1, $arg2, $arg3, ''];
            }
            if (is_numeric($arg1) && is_string($arg2) && is_array($arg3)) {
                return [$arg1, $arg2, $arg3, ''];
            }
            if (is_numeric($arg1) && is_string($arg2) && is_numeric($arg3)) {
                return [$arg1, $arg2, $arg3, ''];
            }
            if (is_numeric($arg1) && is_string($arg2) && is_string($arg3)) {
                $arg3 = static::params($arg3) ? static::params($arg3) : $arg3;
                return [$arg1, $arg2, [], $arg3];
            }
            if (is_array($arg1) && is_array($arg2) && is_string($arg3)) {
                #如果数组为空
                if (empty($arg2) && empty($arg1)) {
                    return [-2, '失败', [], ''];
                }
                #如果第二个参数为空
                elseif (empty($arg2)) {
                    return [-2, reset($arg1), [], ''];
                } else {
                    $arg1 = next($arg1);
                    $arg1 = empty($arg1) ? '成功' : $arg1;
                    $arg3 = static::params($arg3) ? static::params($arg3) : $arg3;
                    return [0, $arg1, $arg2, $arg3];
                }
            }
            break;
        case 4:
        default:
            $arg1 = reset($args);
            $arg2 = next($args);
            $arg3 = next($args);
            $arg4 = next($args);
            if (is_numeric($arg1) && is_string($arg2) && is_array($arg3) && is_string($arg4)) {
                $arg4 = static::params($arg4) ? static::params($arg4) : $arg4;
                return [$arg1, $arg2, $arg3, $arg4];
            }
            break;
        }
        return [0, '其他', $args, ''];
    }
38825
public function create($args)
    {
        $wpcli_args = buildCLIArgs(
            array(
                'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_date',
                'comment_date_gmt', 'comment_parent', 'comment_post_ID', 'user_id', 'comment_agent', 'comment_author_IP',
                'comment_approved', 'comment_karma', 'comment_type',
            ),
            $args
        );

        array_unshift($wpcli_args, '--porcelain');
        $comment_id = (int) $this->drivers->getDriver()->wpcli('comment', 'create', $wpcli_args)['stdout'];

        return $this->get($comment_id);
    }
1374464
public static function getFirst($arg) {
        $str = iconv('UTF-8', 'gb2312', $arg);//如果程序是gbk的，此行就要注释掉
        if (!preg_match('/^[\x7f-\xff]/', $str)) {
            return strtoupper($str[0]);
        }
        $firstChar=ord($str{0});
        if($firstChar >= ord('A') && $firstChar <= ord('z')) {
            return strtoupper($str{0});
        }
        $a = $str;
        $val = ord($a{0}) * 256 + ord($a{1}) - 65536;
        if ($val >= -20319 && $val <= -20284)  {
            return 'A';
        }
        if ($val >= -20283 && $val <= -19776) {
            return 'B';
        }
        if ($val >= -19775 && $val <= -19219) {
            return 'C';
        }
        if ($val >= -19218 && $val <= -18711) {
            return 'D';
        }
        if ($val >= -18710 && $val <= -18527) {
            return 'E';
        }
        if ($val >= -18526 && $val <= -18240) {
            return 'F';
        }
        if ($val >= -18239 && $val <= -17923) {
            return 'G';
        }
        if ($val >= -17922 && $val <= -17418) {
            return 'H';
        }
        if ($val >= -17417 && $val <= -16475) {
            return 'J';
        }
        if ($val >= -16474 && $val <= -16213) {
            return 'K';
        }
        if ($val >= -16212 && $val <= -15641) {
            return 'L';
        }
        if ($val >= -15640 && $val <= -15166) {
            return 'M';
        }
        if ($val >= -15165 && $val <= -14923) {
            return 'N';
        }
        if ($val >= -14922 && $val <= -14915) {
            return 'O';
        }
        if ($val >= -14914 && $val <= -14631) {
            return 'P';
        }
        if ($val >= -14630 && $val <= -14150) {
            return 'Q';
        }
        if ($val >= -14149 && $val <= -14091) {
            return 'R';
        }
        if ($val >= -14090 && $val <= -13319) {
            return 'S';
        }
        if ($val >= -13318 && $val <= -12839) {
            return 'T';
        }
        if ($val >= -12838 && $val <= -12557) {
            return 'W';
        }
        if ($val >= -12556 && $val <= -11848) {
            return 'X';
        }
        if ($val >= -11847 && $val <= -11056) {
            return 'Y';
        }
        if ($val >= -11055 && $val <= -10247) {
            return 'Z';
        }
        return strtoupper($str[0]);
    }
1050661
public static function cli($args)
    {
        $cwd = getcwd();
        $cli = new self($cwd);

        return $cli->run(array_slice($args, 1));
    }
333652
function get($args)
    {
        $cache = $this->get_cache();
        $data  = $cache->read($args['id']);

        if ($data !== null && $data !== false) {
            $args['data'] = base64_decode($data);
            $args['status'] = true;
        }
        else {
            $args['status'] = false;
        }

        return $args;
    }
919160
public function closeOrder(array $args = array()) {
        $args = $this->getClose()->parameters($this->merge($args))->text();
        if ($args['return_code'] != 'SUCCESS') {
            throw new Exception($args['return_msg']);
        }
        if (!$this->verify($args)) {
            throw new Exception('数据验签失败！');
        }
        return $args;
    }
1263715
public function qrPay(array $args = array()) {
        $url = $this->getPayQr()->parameters($this->merge($args))->getUrl();
        return (new QrCode())->create((string)$url);
    }
1058554
public function optimize($args) {
        $imageModel = new Model_Image();
        $pngs = $imageModel->fetchAll(
            $imageModel->select()
                ->from($imageModel->getName(), array('filename'))
                ->where('filename LIKE ?', '%.png')
        );
        $pngQuant = new Garp_Image_PngQuant();
        if (!$pngQuant->isAvailable()) {
            Garp_Cli::errorOut('I have no business here: pngquant is not available.');
        }
        $gif = new Garp_Image_File();

        foreach ($pngs as $png) {
            $data = $gif->fetch($png->filename);
            $data = $pngQuant->optimizeData($data);
            $gif->store($png->filename, $data, true);
            Garp_Cli::lineOut('Optimized ' . $png->filename);
        }
        Garp_Cli::lineOut('Done.');

        return true;
    }
390186
protected function get($args) {
		$target = $args['target'];
		$volume = $this->volume($target);
		
		if (!$volume || ($file = $volume->file($target)) == false) {
			return array('error' => $this->error(self::ERROR_OPEN, '#'.$target, self::ERROR_FILE_NOT_FOUND));
		}
		
		if (($content = $volume->getContents($target)) === false) {
			return array('error' => $this->error(self::ERROR_OPEN, $volume->path($target), $volume->error()));
		}
		
		if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
			$mime = isset($file['mime'])? $file['mime'] : '';
			if ($mime && strtolower(substr($mime, 0, 4)) === 'text') {
				if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) {
					if (strtolower($enc) !== 'utf-8') {
						$content = mb_convert_encoding($content, 'UTF-8', $enc);
					}
				}
			}
		}
		
		$json = json_encode($content);

		if ($json === false || strlen($json) < strlen($content)) {
			if ($args['conv']) {
				return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target)));
			} else {
				return array('doconv' => true);
			}
		}
		
		return array('content' => $content);
	}
1264723
public function get_by_code( $code, $args = array() ) {

		$this->set_request_args( array(
			'method' => 'GET',
			'path'   => array( 'code', urlencode( $code ) ),
			'params' => $args,
		) );

		return $this->do_request();
	}
171886
public function fetch($sql, ...$args) {
        if (is_null($this->dialect)) {
            return null;
        }
        $dialect = $this->dialect;
        try {
            // 表前缀处理
            $sql = preg_replace_callback('#\{[a-z][a-z0-9_].*\}#i', function ($r) use ($dialect) {
                return $dialect->getTableName($r[0]);
            }, $sql);
            if ($args) {
                $params = 0;
                $sql    = preg_replace_callback('#%(s|d|f)#', function ($r) use (&$params, $args, $dialect, $sql) {
                    if ($r[1] == 'f') {
                        $v = floatval($args[ $params ]);
                    } else if ($r[1] == 'd') {
                        $v = intval($args[ $params ]);
                    } else if (is_null($args[ $params ])) {
                        $v = null;
                    } else {
                        $v = $dialect->quote($args[ $params ], \PDO::PARAM_STR);
                    }
                    $params++;

                    return $v;
                }, $sql);
            }
            //查询
            $rst = $this->dialect->query($sql);
            if ($rst) {
                return $rst;
            }
        } catch (\Exception $e) {
            $this->error = $e->getMessage();
        }

        return null;
    }
317631
public static function make_request( array $args = [] ){
		$args = wp_parse_args([
			'blog' => get_option( 'home' ),
			'blog_lang' => get_locale(),
			'blog_charset' => get_option( 'blog_charset' ),
			'user_ip' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '',
			'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '',
			'referrer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
		], $args);
		// Add server variables
		foreach ( $_SERVER as $key => $value ) {
			switch( $key ){
				case 'REMOTE_ADDR':
				case 'HTTP_USER_AGENT':
				case 'HTTP_REFERER':
				case 'HTTP_COOKIE':
				case 'HTTP_COOKIE2':
				case 'PHP_AUTH_PW':
					// Ignore
					break;
				default:
					$args[$key] = $value;
					break;
			}
		}
		return http_build_query($args);
	}
754704
public function args(array $arguments)
    {
        // provide a new instance of the scheduler class if this
        // is the first method that was called.  This allows for
        // $scheduler->opts() to return a new instance of the
        // scheduler when it's first called
        if (count($this->options) == 0) {
            $scheduler = App::make(get_called_class());
            $scheduler->setArguments($arguments);

            return $scheduler;
        }

        $this->setArguments($arguments);

        return $this;
    }
887192
public function passthru(array $arguments = [])
    {
        passthru($this->getBin() . $this->prepareCommand($arguments), $exitCode);
        return $exitCode;
    }
258632
public function order(array $args = array()) {
        $args = $this->getOrder()->parameters($this->merge($args))->text();
        if ($args['return_code'] != 'SUCCESS') {
            throw new Exception($args['return_msg']);
        }
        if ($args['result_code'] != 'SUCCESS') {
            throw new Exception($args['err_code_des']);
        }
        if (!$this->verify($args)) {
            throw new Exception('数据验签失败！');
        }
        $this->set($args);
        return $args;
    }
307858
public static function instance( $args = array() ) {
		if ( is_null( self::$instance ) ) {
			self::$instance = new self( $args );
		}

		return self::$instance;
	}
882669
public static function url( array $args = [], string $url = null ) {
		if ( is_null( $url ) ) {
			$url = $_SERVER['REQUEST_URI'];
		}

		return add_query_arg( $args, $url );
	}