注释规范

This commit is contained in:
thinkphp
2016-06-20 17:34:54 +08:00
parent 940ed22965
commit a032828d5c
48 changed files with 724 additions and 760 deletions

View File

@@ -522,7 +522,7 @@ class Route
/**
* 检测子域名部署
* @access public
* @param \think\Request $request Request请求对象
* @param Request $request Request请求对象
* @return void
*/
public static function checkDomain($request)
@@ -615,7 +615,7 @@ class Route
/**
* 检测URL路由
* @access public
* @param \think\Request $request Request请求对象
* @param Request $request Request请求对象
* @param string $url URL地址
* @param string $depr URL分隔符
* @param bool $checkDomain 是否检测域名规则
@@ -861,7 +861,7 @@ class Route
* @access private
* @param array $option 路由参数
* @param string $url URL地址
* @param \think\Request $request Request对象
* @param Request $request Request对象
* @return bool
*/
private static function checkOption($option, $url, $request)

View File

@@ -81,7 +81,7 @@ class Lite
* @access public
* @param string $name 缓存变量名
* @param mixed $value 存储数据
* @internal param int $expire 有效时间 0为永久
* @param int $expire 有效时间 0为永久
* @return bool
*/
public function set($name, $value, $expire = null)

View File

@@ -12,7 +12,7 @@
namespace think\controller;
use think\App;
use think\Loader;
/**
* ThinkPHP Hprose控制器类
*/
@@ -37,14 +37,14 @@ abstract class Hprose
}
//导入类库
\think\Loader::import('vendor.Hprose.HproseHttpServer');
Loader::import('vendor.Hprose.HproseHttpServer');
//实例化HproseHttpServer
$server = new \HproseHttpServer();
if ($this->allowMethodList) {
$methods = $this->allowMethodList;
} else {
$methods = get_class_methods($this);
$methods = array_diff($methods, array('__construct', '__call', '_initialize'));
$methods = array_diff($methods, ['__construct', '__call', '_initialize']);
}
$server->addMethods($methods, $this);
if (App::$debug || $this->debug) {

View File

@@ -11,6 +11,7 @@
namespace think\controller;
use think\Loader;
/**
* ThinkPHP JsonRPC控制器类
*/
@@ -29,7 +30,7 @@ abstract class Jsonrpc
}
//导入类库
\think\Loader::import('vendor.jsonrpc.jsonRPCServer');
Loader::import('vendor.jsonrpc.jsonRPCServer');
// 启动server
\jsonRPCServer::handle($this);
}

View File

@@ -17,8 +17,8 @@ use think\Request;
abstract class Rest
{
protected $_method = ''; // 当前请求类型
protected $_type = ''; // 当前资源类型
protected $method; // 当前请求类型
protected $type; // 当前资源类型
// 输出类型
protected $restMethodList = 'get|post|put|delete';
protected $restDefaultMethod = 'get';
@@ -41,12 +41,12 @@ abstract class Rest
$ext = $request->ext();
if ('' == $ext) {
// 自动检测资源类型
$this->_type = $this->getAcceptType();
$this->type = $request->type();
} elseif (!preg_match('/\(' . $this->restTypeList . '\)$/i', $ext)) {
// 资源类型非法 则用默认资源类型访问
$this->_type = $this->restDefaultType;
$this->type = $this->restDefaultType;
} else {
$this->_type = $ext;
$this->type = $ext;
}
// 请求方式检测
$method = strtolower($request->method());
@@ -54,7 +54,7 @@ abstract class Rest
// 请求方式非法 则用默认请求方法
$method = $this->restDefaultMethod;
}
$this->_method = $method;
$this->method = $method;
}
/**
@@ -67,13 +67,13 @@ abstract class Rest
*/
public function _empty($method, $args)
{
if (method_exists($this, $method . '_' . $this->_method . '_' . $this->_type)) {
if (method_exists($this, $method . '_' . $this->method . '_' . $this->type)) {
// RESTFul方法支持
$fun = $method . '_' . $this->_method . '_' . $this->_type;
} elseif ($this->_method == $this->restDefaultMethod && method_exists($this, $method . '_' . $this->_type)) {
$fun = $method . '_' . $this->_type;
} elseif ($this->_type == $this->restDefaultType && method_exists($this, $method . '_' . $this->_method)) {
$fun = $method . '_' . $this->_method;
$fun = $method . '_' . $this->method . '_' . $this->type;
} elseif ($this->_method == $this->restDefaultMethod && method_exists($this, $method . '_' . $this->type)) {
$fun = $method . '_' . $this->type;
} elseif ($this->type == $this->restDefaultType && method_exists($this, $method . '_' . $this->method)) {
$fun = $method . '_' . $this->method;
}
if (isset($fun)) {
return $this->$fun();
@@ -88,7 +88,7 @@ abstract class Rest
* @access protected
* @param mixed $data 要返回的数据
* @param String $type 返回类型 JSON XML
* @param integer $code HTTP状态
* @param integer $code HTTP状态
* @return Response
*/
protected function response($data, $type = 'json', $code = 200)
@@ -96,42 +96,4 @@ abstract class Rest
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;
}
}

View File

@@ -12,6 +12,7 @@
namespace think\controller;
use think\App;
use think\Loader;
/**
* ThinkPHP RPC控制器类
*/
@@ -33,14 +34,14 @@ abstract class Rpc
}
//导入类库
\think\Loader::import('vendor.phprpc.phprpc_server');
Loader::import('vendor.phprpc.phprpc_server');
//实例化phprpc
$server = new \PHPRPC_Server();
if ($this->allowMethodList) {
$methods = $this->allowMethodList;
} else {
$methods = get_class_methods($this);
$methods = array_diff($methods, array('__construct', '__call', '_initialize'));
$methods = array_diff($methods, ['__construct', '__call', '_initialize']);
}
$server->add($methods, $this);

View File

@@ -214,6 +214,7 @@ abstract class Builder
* 生成查询条件SQL
* @access public
* @param mixed $where
* @param string $table
* @return string
*/
public function buildWhere($where, $table)

View File

@@ -1043,8 +1043,8 @@ class Query
/**
* 查询缓存
* @access public
* @param mixed $key
* @param integer $expire
* @param mixed $key 缓存key
* @param integer $expire 缓存有效期
* @return $this
*/
public function cache($key = true, $expire = null)

View File

@@ -236,7 +236,7 @@ class Relation
* @param Model $result 数据对象
* @param string $relation 关联名
* @param string $class 数据集对象名 为空表示数组
* @return \think\Model
* @return Model
*/
public function eagerlyResult($result, $relation, $class = '')
{

View File

@@ -17,8 +17,8 @@ class File
{
/**
* 写入编译缓存
* @string $cacheFile 缓存的文件名
* @string $content 缓存的内容
* @param string $cacheFile 缓存的文件名
* @param string $content 缓存的内容
* @return void|array
*/
public function write($cacheFile, $content)
@@ -36,8 +36,8 @@ class File
/**
* 读取编译编译
* @string $cacheFile 缓存的文件名
* @array $vars 变量数组
* @param string $cacheFile 缓存的文件名
* @param array $vars 变量数组
* @return void
*/
public function read($cacheFile, $vars = [])
@@ -52,8 +52,8 @@ class File
/**
* 检查编译缓存是否有效
* @string $cacheFile 缓存的文件名
* @int $cacheTime 缓存时间
* @param string $cacheFile 缓存的文件名
* @param int $cacheTime 缓存时间
* @return boolean
*/
public function check($cacheFile, $cacheTime)

View File

@@ -37,8 +37,8 @@ class Sae
/**
* 写入编译缓存
* @string $cacheFile 缓存的文件名
* @string $content 缓存的内容
* @param string $cacheFile 缓存的文件名
* @param string $content 缓存的内容
* @return void|array
*/
public function write($cacheFile, $content)
@@ -55,8 +55,8 @@ class Sae
/**
* 读取编译编译
* @string $cacheFile 缓存的文件名
* @array $vars 变量数组
* @param string $cacheFile 缓存的文件名
* @param array $vars 变量数组
* @return void
*/
public function read($cacheFile, $vars = [])
@@ -69,8 +69,8 @@ class Sae
/**
* 检查编译缓存是否有效
* @string $cacheFile 缓存的文件名
* @int $cacheTime 缓存时间
* @param string $cacheFile 缓存的文件名
* @param int $cacheTime 缓存时间
* @return boolean
*/
public function check($cacheFile, $cacheTime)

View File

@@ -117,7 +117,6 @@ class Php
}
}
return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.');
}
}