mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-10 00:22:48 +08:00
注释规范
This commit is contained in:
@@ -522,7 +522,7 @@ class Route
|
|||||||
/**
|
/**
|
||||||
* 检测子域名部署
|
* 检测子域名部署
|
||||||
* @access public
|
* @access public
|
||||||
* @param \think\Request $request Request请求对象
|
* @param Request $request Request请求对象
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function checkDomain($request)
|
public static function checkDomain($request)
|
||||||
@@ -615,7 +615,7 @@ class Route
|
|||||||
/**
|
/**
|
||||||
* 检测URL路由
|
* 检测URL路由
|
||||||
* @access public
|
* @access public
|
||||||
* @param \think\Request $request Request请求对象
|
* @param Request $request Request请求对象
|
||||||
* @param string $url URL地址
|
* @param string $url URL地址
|
||||||
* @param string $depr URL分隔符
|
* @param string $depr URL分隔符
|
||||||
* @param bool $checkDomain 是否检测域名规则
|
* @param bool $checkDomain 是否检测域名规则
|
||||||
@@ -861,7 +861,7 @@ class Route
|
|||||||
* @access private
|
* @access private
|
||||||
* @param array $option 路由参数
|
* @param array $option 路由参数
|
||||||
* @param string $url URL地址
|
* @param string $url URL地址
|
||||||
* @param \think\Request $request Request对象
|
* @param Request $request Request对象
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function checkOption($option, $url, $request)
|
private static function checkOption($option, $url, $request)
|
||||||
|
|||||||
2
library/think/cache/driver/Lite.php
vendored
2
library/think/cache/driver/Lite.php
vendored
@@ -81,7 +81,7 @@ class Lite
|
|||||||
* @access public
|
* @access public
|
||||||
* @param string $name 缓存变量名
|
* @param string $name 缓存变量名
|
||||||
* @param mixed $value 存储数据
|
* @param mixed $value 存储数据
|
||||||
* @internal param int $expire 有效时间 0为永久
|
* @param int $expire 有效时间 0为永久
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function set($name, $value, $expire = null)
|
public function set($name, $value, $expire = null)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
namespace think\controller;
|
namespace think\controller;
|
||||||
|
|
||||||
use think\App;
|
use think\App;
|
||||||
|
use think\Loader;
|
||||||
/**
|
/**
|
||||||
* ThinkPHP Hprose控制器类
|
* ThinkPHP Hprose控制器类
|
||||||
*/
|
*/
|
||||||
@@ -37,14 +37,14 @@ abstract class Hprose
|
|||||||
}
|
}
|
||||||
|
|
||||||
//导入类库
|
//导入类库
|
||||||
\think\Loader::import('vendor.Hprose.HproseHttpServer');
|
Loader::import('vendor.Hprose.HproseHttpServer');
|
||||||
//实例化HproseHttpServer
|
//实例化HproseHttpServer
|
||||||
$server = new \HproseHttpServer();
|
$server = new \HproseHttpServer();
|
||||||
if ($this->allowMethodList) {
|
if ($this->allowMethodList) {
|
||||||
$methods = $this->allowMethodList;
|
$methods = $this->allowMethodList;
|
||||||
} else {
|
} else {
|
||||||
$methods = get_class_methods($this);
|
$methods = get_class_methods($this);
|
||||||
$methods = array_diff($methods, array('__construct', '__call', '_initialize'));
|
$methods = array_diff($methods, ['__construct', '__call', '_initialize']);
|
||||||
}
|
}
|
||||||
$server->addMethods($methods, $this);
|
$server->addMethods($methods, $this);
|
||||||
if (App::$debug || $this->debug) {
|
if (App::$debug || $this->debug) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace think\controller;
|
namespace think\controller;
|
||||||
|
|
||||||
|
use think\Loader;
|
||||||
/**
|
/**
|
||||||
* ThinkPHP JsonRPC控制器类
|
* ThinkPHP JsonRPC控制器类
|
||||||
*/
|
*/
|
||||||
@@ -29,7 +30,7 @@ abstract class Jsonrpc
|
|||||||
}
|
}
|
||||||
|
|
||||||
//导入类库
|
//导入类库
|
||||||
\think\Loader::import('vendor.jsonrpc.jsonRPCServer');
|
Loader::import('vendor.jsonrpc.jsonRPCServer');
|
||||||
// 启动server
|
// 启动server
|
||||||
\jsonRPCServer::handle($this);
|
\jsonRPCServer::handle($this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ use think\Request;
|
|||||||
abstract class Rest
|
abstract class Rest
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $_method = ''; // 当前请求类型
|
protected $method; // 当前请求类型
|
||||||
protected $_type = ''; // 当前资源类型
|
protected $type; // 当前资源类型
|
||||||
// 输出类型
|
// 输出类型
|
||||||
protected $restMethodList = 'get|post|put|delete';
|
protected $restMethodList = 'get|post|put|delete';
|
||||||
protected $restDefaultMethod = 'get';
|
protected $restDefaultMethod = 'get';
|
||||||
@@ -41,12 +41,12 @@ abstract class Rest
|
|||||||
$ext = $request->ext();
|
$ext = $request->ext();
|
||||||
if ('' == $ext) {
|
if ('' == $ext) {
|
||||||
// 自动检测资源类型
|
// 自动检测资源类型
|
||||||
$this->_type = $this->getAcceptType();
|
$this->type = $request->type();
|
||||||
} elseif (!preg_match('/\(' . $this->restTypeList . '\)$/i', $ext)) {
|
} elseif (!preg_match('/\(' . $this->restTypeList . '\)$/i', $ext)) {
|
||||||
// 资源类型非法 则用默认资源类型访问
|
// 资源类型非法 则用默认资源类型访问
|
||||||
$this->_type = $this->restDefaultType;
|
$this->type = $this->restDefaultType;
|
||||||
} else {
|
} else {
|
||||||
$this->_type = $ext;
|
$this->type = $ext;
|
||||||
}
|
}
|
||||||
// 请求方式检测
|
// 请求方式检测
|
||||||
$method = strtolower($request->method());
|
$method = strtolower($request->method());
|
||||||
@@ -54,7 +54,7 @@ abstract class Rest
|
|||||||
// 请求方式非法 则用默认请求方法
|
// 请求方式非法 则用默认请求方法
|
||||||
$method = $this->restDefaultMethod;
|
$method = $this->restDefaultMethod;
|
||||||
}
|
}
|
||||||
$this->_method = $method;
|
$this->method = $method;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,13 +67,13 @@ abstract class Rest
|
|||||||
*/
|
*/
|
||||||
public function _empty($method, $args)
|
public function _empty($method, $args)
|
||||||
{
|
{
|
||||||
if (method_exists($this, $method . '_' . $this->_method . '_' . $this->_type)) {
|
if (method_exists($this, $method . '_' . $this->method . '_' . $this->type)) {
|
||||||
// RESTFul方法支持
|
// RESTFul方法支持
|
||||||
$fun = $method . '_' . $this->_method . '_' . $this->_type;
|
$fun = $method . '_' . $this->method . '_' . $this->type;
|
||||||
} elseif ($this->_method == $this->restDefaultMethod && method_exists($this, $method . '_' . $this->_type)) {
|
} elseif ($this->_method == $this->restDefaultMethod && method_exists($this, $method . '_' . $this->type)) {
|
||||||
$fun = $method . '_' . $this->_type;
|
$fun = $method . '_' . $this->type;
|
||||||
} elseif ($this->_type == $this->restDefaultType && method_exists($this, $method . '_' . $this->_method)) {
|
} elseif ($this->type == $this->restDefaultType && method_exists($this, $method . '_' . $this->method)) {
|
||||||
$fun = $method . '_' . $this->_method;
|
$fun = $method . '_' . $this->method;
|
||||||
}
|
}
|
||||||
if (isset($fun)) {
|
if (isset($fun)) {
|
||||||
return $this->$fun();
|
return $this->$fun();
|
||||||
@@ -88,7 +88,7 @@ abstract class Rest
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @param mixed $data 要返回的数据
|
* @param mixed $data 要返回的数据
|
||||||
* @param String $type 返回类型 JSON XML
|
* @param String $type 返回类型 JSON XML
|
||||||
* @param integer $code HTTP状态
|
* @param integer $code HTTP状态码
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
protected function response($data, $type = 'json', $code = 200)
|
protected function response($data, $type = 'json', $code = 200)
|
||||||
@@ -96,42 +96,4 @@ abstract class Rest
|
|||||||
return Response::create($data, $type)->code($code);
|
return Response::create($data, $type)->code($code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前请求的Accept头信息
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getAcceptType()
|
|
||||||
{
|
|
||||||
if (!isset($_SERVER['HTTP_ACCEPT'])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$type = [
|
|
||||||
'html' => 'text/html,application/xhtml+xml,*/*',
|
|
||||||
'xml' => 'application/xml,text/xml,application/x-xml',
|
|
||||||
'json' => 'application/json,text/x-json,application/jsonrequest,text/json',
|
|
||||||
'js' => 'text/javascript,application/javascript,application/x-javascript',
|
|
||||||
'css' => 'text/css',
|
|
||||||
'rss' => 'application/rss+xml',
|
|
||||||
'yaml' => 'application/x-yaml,text/yaml',
|
|
||||||
'atom' => 'application/atom+xml',
|
|
||||||
'pdf' => 'application/pdf',
|
|
||||||
'text' => 'text/plain',
|
|
||||||
'png' => 'image/png',
|
|
||||||
'jpg' => 'image/jpg,image/jpeg,image/pjpeg',
|
|
||||||
'gif' => 'image/gif',
|
|
||||||
'csv' => 'text/csv',
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($type as $key => $val) {
|
|
||||||
$array = explode(',', $val);
|
|
||||||
foreach ($array as $k => $v) {
|
|
||||||
if (stristr($_SERVER['HTTP_ACCEPT'], $v)) {
|
|
||||||
return $key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
namespace think\controller;
|
namespace think\controller;
|
||||||
|
|
||||||
use think\App;
|
use think\App;
|
||||||
|
use think\Loader;
|
||||||
/**
|
/**
|
||||||
* ThinkPHP RPC控制器类
|
* ThinkPHP RPC控制器类
|
||||||
*/
|
*/
|
||||||
@@ -33,14 +34,14 @@ abstract class Rpc
|
|||||||
}
|
}
|
||||||
|
|
||||||
//导入类库
|
//导入类库
|
||||||
\think\Loader::import('vendor.phprpc.phprpc_server');
|
Loader::import('vendor.phprpc.phprpc_server');
|
||||||
//实例化phprpc
|
//实例化phprpc
|
||||||
$server = new \PHPRPC_Server();
|
$server = new \PHPRPC_Server();
|
||||||
if ($this->allowMethodList) {
|
if ($this->allowMethodList) {
|
||||||
$methods = $this->allowMethodList;
|
$methods = $this->allowMethodList;
|
||||||
} else {
|
} else {
|
||||||
$methods = get_class_methods($this);
|
$methods = get_class_methods($this);
|
||||||
$methods = array_diff($methods, array('__construct', '__call', '_initialize'));
|
$methods = array_diff($methods, ['__construct', '__call', '_initialize']);
|
||||||
}
|
}
|
||||||
$server->add($methods, $this);
|
$server->add($methods, $this);
|
||||||
|
|
||||||
|
|||||||
@@ -214,6 +214,7 @@ abstract class Builder
|
|||||||
* 生成查询条件SQL
|
* 生成查询条件SQL
|
||||||
* @access public
|
* @access public
|
||||||
* @param mixed $where
|
* @param mixed $where
|
||||||
|
* @param string $table
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function buildWhere($where, $table)
|
public function buildWhere($where, $table)
|
||||||
|
|||||||
@@ -1043,8 +1043,8 @@ class Query
|
|||||||
/**
|
/**
|
||||||
* 查询缓存
|
* 查询缓存
|
||||||
* @access public
|
* @access public
|
||||||
* @param mixed $key
|
* @param mixed $key 缓存key
|
||||||
* @param integer $expire
|
* @param integer $expire 缓存有效期
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function cache($key = true, $expire = null)
|
public function cache($key = true, $expire = null)
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ class Relation
|
|||||||
* @param Model $result 数据对象
|
* @param Model $result 数据对象
|
||||||
* @param string $relation 关联名
|
* @param string $relation 关联名
|
||||||
* @param string $class 数据集对象名 为空表示数组
|
* @param string $class 数据集对象名 为空表示数组
|
||||||
* @return \think\Model
|
* @return Model
|
||||||
*/
|
*/
|
||||||
public function eagerlyResult($result, $relation, $class = '')
|
public function eagerlyResult($result, $relation, $class = '')
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ class File
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 写入编译缓存
|
* 写入编译缓存
|
||||||
* @string $cacheFile 缓存的文件名
|
* @param string $cacheFile 缓存的文件名
|
||||||
* @string $content 缓存的内容
|
* @param string $content 缓存的内容
|
||||||
* @return void|array
|
* @return void|array
|
||||||
*/
|
*/
|
||||||
public function write($cacheFile, $content)
|
public function write($cacheFile, $content)
|
||||||
@@ -36,8 +36,8 @@ class File
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取编译编译
|
* 读取编译编译
|
||||||
* @string $cacheFile 缓存的文件名
|
* @param string $cacheFile 缓存的文件名
|
||||||
* @array $vars 变量数组
|
* @param array $vars 变量数组
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function read($cacheFile, $vars = [])
|
public function read($cacheFile, $vars = [])
|
||||||
@@ -52,8 +52,8 @@ class File
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查编译缓存是否有效
|
* 检查编译缓存是否有效
|
||||||
* @string $cacheFile 缓存的文件名
|
* @param string $cacheFile 缓存的文件名
|
||||||
* @int $cacheTime 缓存时间
|
* @param int $cacheTime 缓存时间
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function check($cacheFile, $cacheTime)
|
public function check($cacheFile, $cacheTime)
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ class Sae
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 写入编译缓存
|
* 写入编译缓存
|
||||||
* @string $cacheFile 缓存的文件名
|
* @param string $cacheFile 缓存的文件名
|
||||||
* @string $content 缓存的内容
|
* @param string $content 缓存的内容
|
||||||
* @return void|array
|
* @return void|array
|
||||||
*/
|
*/
|
||||||
public function write($cacheFile, $content)
|
public function write($cacheFile, $content)
|
||||||
@@ -55,8 +55,8 @@ class Sae
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取编译编译
|
* 读取编译编译
|
||||||
* @string $cacheFile 缓存的文件名
|
* @param string $cacheFile 缓存的文件名
|
||||||
* @array $vars 变量数组
|
* @param array $vars 变量数组
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function read($cacheFile, $vars = [])
|
public function read($cacheFile, $vars = [])
|
||||||
@@ -69,8 +69,8 @@ class Sae
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查编译缓存是否有效
|
* 检查编译缓存是否有效
|
||||||
* @string $cacheFile 缓存的文件名
|
* @param string $cacheFile 缓存的文件名
|
||||||
* @int $cacheTime 缓存时间
|
* @param int $cacheTime 缓存时间
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function check($cacheFile, $cacheTime)
|
public function check($cacheFile, $cacheTime)
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ class Php
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.');
|
return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user