diff --git a/base.php b/base.php index 691bdfe7..2e793cd1 100644 --- a/base.php +++ b/base.php @@ -62,7 +62,7 @@ function C($name = '', $value = null, $range = '') if (is_null($value)) { return think\Config::get($name, $range); } else { - think\Config::set($name, $value, $range); + return think\Config::set($name, $value, $range); } } @@ -100,7 +100,7 @@ function G($start, $end = '', $dec = 6) * @param string $name Model名称 支持指定基础模型 例如 MongoModel:User * @param string $tablePrefix 表前缀 * @param mixed $connection 数据库连接信息 - * @return Model + * @return \Think\Model */ function M($name = '', $tablePrefix = '', $connection = '') { @@ -188,9 +188,11 @@ function T($class, $ext = EXT) /** * 抛出异常处理 - * @param string $msg 异常消息 + * + * @param string $msg 异常消息 * @param integer $code 异常代码 默认为0 - * @return void + * + * @throws \think\Exception */ function E($msg, $code = 0) { @@ -213,7 +215,7 @@ function dump($var, $echo = true, $label = null) * 渲染输出Widget * @param string $name Widget名称 * @param array $data 传人的参数 - * @return void + * @return mixed */ function W($name, $data = []) { @@ -238,7 +240,7 @@ function session($name, $value = '') return think\Session::get($name); } elseif (is_null($value)) { // 删除session - return think\Session::delete($name); + think\Session::delete($name); } else { // 设置session think\Session::set($name, $value); diff --git a/library/behavior/content_replace.php b/library/behavior/content_replace.php index 2a32a302..906f469e 100644 --- a/library/behavior/content_replace.php +++ b/library/behavior/content_replace.php @@ -41,8 +41,8 @@ class ContentReplace $script_name = rtrim($_SERVER['SCRIPT_NAME'],'/'); } define('ROOT_URL', rtrim(dirname(str_replace("\\","\/",$script_name)),'/')); - define('MODULE_URL', ROOT_URL.'/'.(defined('MODULE_ALIAS')?MODULE_ALIAS:MODULE_NAME); - define('CONTROLLER_URL', MODULE_URL.'/'.CONTROLLER_NAME; + define('MODULE_URL', ROOT_URL.'/'.(defined('MODULE_ALIAS')?MODULE_ALIAS:MODULE_NAME)); + define('CONTROLLER_URL', MODULE_URL.'/'.CONTROLLER_NAME); define('ACTION_URL', CONTROLLER_URL.'/'.ACTION_NAME); // 系统默认的特殊变量替换 diff --git a/library/behavior/location_template.php b/library/behavior/location_template.php index a7127714..bd7f3095 100644 --- a/library/behavior/location_template.php +++ b/library/behavior/location_template.php @@ -27,9 +27,12 @@ class LocationTemplate /** * 自动定位模板文件 - * @access private - * @param string $templateFile 文件名 + * @access private + * + * @param $template + * * @return string + * @internal param string $templateFile 文件名 */ private function parseTemplateFile($template) { @@ -39,8 +42,6 @@ class LocationTemplate $template = CONTROLLER_NAME . '/' . ACTION_NAME; } elseif (false === strpos($template, '/')) { $template = CONTROLLER_NAME . '/' . $template; - } elseif (false === strpos($template, '.')) { - $template = $template; } $templateFile = MODULE_PATH . 'view/' . $template . '.html'; return $templateFile; diff --git a/library/behavior/read_html_cache.php b/library/behavior/read_html_cache.php index 55615e3c..8659e236 100644 --- a/library/behavior/read_html_cache.php +++ b/library/behavior/read_html_cache.php @@ -104,7 +104,7 @@ class ReadHtmlCache * @access public * @param string $cacheFile 静态文件名 * @param integer $cacheTime 缓存有效期 - * @return boolen + * @return bool */ public static function checkHTMLCache($cacheFile = '', $cacheTime = '') { diff --git a/library/behavior/token_build.php b/library/behavior/token_build.php index 96fe3674..0c634215 100644 --- a/library/behavior/token_build.php +++ b/library/behavior/token_build.php @@ -8,8 +8,8 @@ // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- - namespace think\behavior; +use think\Behavior; /** * 系统行为扩展:表单令牌生成 diff --git a/library/org/crypt.php b/library/org/crypt.php index cb9f7178..4d536e48 100644 --- a/library/org/crypt.php +++ b/library/org/crypt.php @@ -15,10 +15,14 @@ class Crypt { /** * 加密字符串 - * @access public - * @param string $str 字符串 + * @access public + * + * @param $data * @param string $key 加密key + * @param int $expire + * * @return string + * @internal param string $str 字符串 */ public static function encrypt($data, $key, $expire = 0) { @@ -45,10 +49,13 @@ class Crypt /** * 解密字符串 - * @access public - * @param string $str 字符串 + * @access public + * + * @param $data * @param string $key 加密key + * * @return string + * @internal param string $str 字符串 */ public static function decrypt($data, $key) { diff --git a/library/org/image.php b/library/org/image.php index c34bd165..a6bb34a7 100644 --- a/library/org/image.php +++ b/library/org/image.php @@ -45,7 +45,11 @@ class Image /** * 初始化方法,用于实例化一个图片处理对象 + * * @param string $type 要使用的类库,默认使用GD库 + * @param null $imgname + * + * @return resource */ public static function init($type = 'Gd', $imgname = null) { diff --git a/library/org/image/driver/gd.php b/library/org/image/driver/gd.php index 82a1c624..8424a852 100644 --- a/library/org/image/driver/gd.php +++ b/library/org/image/driver/gd.php @@ -11,6 +11,8 @@ namespace think\image\driver; +use Exception; + class Gd { /** @@ -18,6 +20,9 @@ class Gd * @var resource */ private $im; + /** + * @var $git \think\image\driver\Gif +*/ private $gif; /** * 图像信息,包括width,height,type,mime,size @@ -36,7 +41,11 @@ class Gd /** * 打开一张图像 + * * @param string $imgname 图像路径 + * + * @return $this + * @throws \Exception */ public function open($imgname) { @@ -50,7 +59,7 @@ class Gd //检测图像合法性 if (false === $info || (IMAGETYPE_GIF === $info[2] && empty($info['bits']))) { - throw new \Exception('非法图像文件'); + throw new Exception('非法图像文件'); } //设置图像信息 @@ -78,14 +87,18 @@ class Gd /** * 保存图像 + * * @param string $imgname 图像保存名称 * @param string $type 图像类型 * @param boolean $interlace 是否对JPEG类型图像设置隔行扫描 + * + * @return $this + * @throws Exception */ public function save($imgname, $type = null, $interlace = true) { if (empty($this->im)) { - throw new \Exception('没有可以被保存的图像资源'); + throw new Exception('没有可以被保存的图像资源'); } //自动获取图像类型 @@ -113,12 +126,13 @@ class Gd /** * 返回图像宽度 - * @return integer 图像宽度 + * @return int 图像宽度 + * @throws Exception */ public function width() { if (empty($this->im)) { - throw new \Exception('没有指定图像资源'); + throw new Exception('没有指定图像资源'); } return $this->info['width']; @@ -126,12 +140,13 @@ class Gd /** * 返回图像高度 - * @return integer 图像高度 + * @return int 图像高度 + * @throws Exception */ public function height() { if (empty($this->im)) { - throw new \Exception('没有指定图像资源'); + throw new Exception('没有指定图像资源'); } return $this->info['height']; @@ -140,11 +155,12 @@ class Gd /** * 返回图像类型 * @return string 图像类型 + * @throws Exception */ public function type() { if (empty($this->im)) { - throw new \Exception('没有指定图像资源'); + throw new Exception('没有指定图像资源'); } return $this->info['type']; @@ -153,11 +169,12 @@ class Gd /** * 返回图像MIME类型 * @return string 图像MIME类型 + * @throws Exception */ public function mime() { if (empty($this->im)) { - throw new \Exception('没有指定图像资源'); + throw new Exception('没有指定图像资源'); } return $this->info['mime']; @@ -166,11 +183,12 @@ class Gd /** * 返回图像尺寸数组 0 - 图像宽度,1 - 图像高度 * @return array 图像尺寸 + * @throws Exception */ public function size() { if (empty($this->im)) { - throw new \Exception('没有指定图像资源'); + throw new Exception('没有指定图像资源'); } return [$this->info['width'], $this->info['height']]; @@ -178,17 +196,21 @@ class Gd /** * 裁剪图像 + * * @param integer $w 裁剪区域宽度 * @param integer $h 裁剪区域高度 * @param integer $x 裁剪区域x坐标 * @param integer $y 裁剪区域y坐标 * @param integer $width 图像保存宽度 * @param integer $height 图像保存高度 + * + * @return $this + * @throws Exception */ public function crop($w, $h, $x = 0, $y = 0, $width = null, $height = null) { if (empty($this->im)) { - throw new \Exception('没有可以被裁剪的图像资源'); + throw new Exception('没有可以被裁剪的图像资源'); } //设置保存尺寸 @@ -217,14 +239,18 @@ class Gd /** * 生成缩略图 + * * @param integer $width 缩略图最大宽度 * @param integer $height 缩略图最大高度 - * @param integer $type 缩略图裁剪类型 + * @param int $type 缩略图裁剪类型 + * + * @return $this + * @throws Exception */ - public function thumb($width, $height, $type = THINKIMAGE_THUMB_SCALE) + public function thumb($width, $height, $type = THINKIMAGE_THUMB_SCALING) { if (empty($this->im)) { - throw new \Exception('没有可以被缩略的图像资源'); + throw new Exception('没有可以被缩略的图像资源'); } //原图宽度和高度 @@ -237,7 +263,7 @@ class Gd case THINKIMAGE_THUMB_SCALING: //原图尺寸小于缩略图尺寸则不进行缩略 if ($w < $width && $h < $height) { - return; + return false; } //计算缩放比例 @@ -296,6 +322,8 @@ class Gd //设置缩略图的坐标及宽度和高度 $neww = $w * $scale; $newh = $h * $scale; + $x = $this->info['width'] - $w; + $y = $this->info['height'] - $h; $posx = ($width - $w * $scale) / 2; $posy = ($height - $h * $scale) / 2; @@ -322,7 +350,7 @@ class Gd break; default: - throw new \Exception('不支持的缩略图裁剪类型'); + throw new Exception('不支持的缩略图裁剪类型'); } /* 裁剪图像 */ @@ -332,25 +360,29 @@ class Gd /** * 添加水印 - * @param string $source 水印图片路径 - * @param integer $locate 水印位置 - * @param integer $alpha 水印透明度 + * + * @param string $source 水印图片路径 + * @param int $locate 水印位置 + * + * @return $this + * @throws Exception + * @internal param int $alpha 水印透明度 */ public function water($source, $locate = THINKIMAGE_WATER_SOUTHEAST) { //资源检测 if (empty($this->im)) { - throw new \Exception('没有可以被添加水印的图像资源'); + throw new Exception('没有可以被添加水印的图像资源'); } if (!is_file($source)) { - throw new \Exception('水印图像不存在'); + throw new Exception('水印图像不存在'); } //获取水印图像信息 $info = getimagesize($source); if (false === $info || (IMAGETYPE_GIF === $info[2] && empty($info['bits']))) { - throw new \Exception('非法水印文件'); + throw new Exception('非法水印文件'); } //创建水印图像资源 @@ -420,7 +452,7 @@ class Gd if (is_array($locate)) { list($x, $y) = $locate; } else { - throw new \Exception('不支持的水印位置类型'); + throw new Exception('不支持的水印位置类型'); } } @@ -446,23 +478,27 @@ class Gd /** * 图像添加文字 + * * @param string $text 添加的文字 * @param string $font 字体路径 * @param integer $size 字号 * @param string $color 文字颜色 - * @param integer $locate 文字写入位置 + * @param int $locate 文字写入位置 * @param integer $offset 文字相对当前位置的偏移量 * @param integer $angle 文字倾斜角度 + * + * @return $this + * @throws Exception */ public function text($text, $font, $size, $color = '#00000000', $locate = THINKIMAGE_WATER_SOUTHEAST, $offset = 0, $angle = 0) { //资源检测 if (empty($this->im)) { - throw new \Exception('没有可以被写入文字的图像资源'); + throw new Exception('没有可以被写入文字的图像资源'); } if (!is_file($font)) { - throw new \Exception("不存在的字体文件:{$font}"); + throw new Exception("不存在的字体文件:{$font}"); } //获取文字信息 @@ -536,7 +572,7 @@ class Gd $x += $posx; $y += $posy; } else { - throw new \Exception('不支持的文字位置类型'); + throw new Exception('不支持的文字位置类型'); } } @@ -557,7 +593,7 @@ class Gd $color[3] = 0; } } elseif (!is_array($color)) { - throw new \Exception('错误的颜色值'); + throw new Exception('错误的颜色值'); } do { diff --git a/library/org/image/driver/gif.php b/library/org/image/driver/gif.php index c244ce60..0b50b258 100644 --- a/library/org/image/driver/gif.php +++ b/library/org/image/driver/gif.php @@ -10,9 +10,6 @@ // +---------------------------------------------------------------------- namespace think\image\driver; - -use think\image\driver\GIFDecoder as GIFDecoder; -use think\image\driver\GIFEncoder as GIFEncoder; class Gif { /** @@ -44,7 +41,7 @@ class Gif $de = new GIFDecoder($src); $this->frames = $de->GIFGetFrames(); $this->delays = $de->GIFGetDelays(); - } catch (Exception $e) { + } catch (\Exception $e) { throw new \Exception("解码GIF图片出错"); } } @@ -53,7 +50,7 @@ class Gif /** * 设置或获取当前帧的数据 * @param string $stream 二进制数据流 - * @return boolean 获取到的数据 + * @return mixed 获取到的数据 */ public function image($stream = null) { @@ -85,7 +82,6 @@ class Gif } } - /* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: @@ -110,8 +106,7 @@ class Gif :: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */ - -class GIFEncoder +class GIFEncode { public $GIF = "GIF89a"; /* GIF header 6 bytes */ public $VER = "GIFEncoder V2.05"; /* Encoder version */ @@ -139,14 +134,14 @@ class GIFEncoder $GIF_src, $GIF_dly, $GIF_lop, $GIF_dis, $GIF_red, $GIF_grn, $GIF_blu, $GIF_mod ) { - if (!is_array($GIF_src) && !is_array($GIF_tim)) { + if (!is_array($GIF_src)) { printf("%s: %s", $this->VER, $this->ERR['ERR00']); exit(0); } $this->LOP = ($GIF_lop > -1) ? $GIF_lop : 0; $this->DIS = ($GIF_dis > -1) ? (($GIF_dis < 3) ? $GIF_dis : 3) : 2; $this->COL = ($GIF_red > -1 && $GIF_grn > -1 && $GIF_blu > -1) ? - ($GIF_red | ($GIF_grn << 8) | ($GIF_blu << 16)) : -1; + ($GIF_red | ($GIF_grn << 8) | ($GIF_blu << 16)) : -1; for ($i = 0; $i < count($GIF_src); $i++) { if (strToLower($GIF_mod) == "url") { @@ -163,23 +158,23 @@ class GIFEncoder } for ($j = (13 + 3 * (2 << (ord($this->BUF[$i]{10}) & 0x07))), $k = true; $k; $j++) { switch ($this->BUF[$i]{ $j}) { - case "!": - if ((substr($this->BUF[$i], ($j + 3), 8)) == "NETSCAPE") { - printf("%s: %s ( %s source )!", $this->VER, $this->ERR['ERR03'], ($i + 1)); - exit(0); - } - break; - case ";": - $k = false; - break; + case "!": + if ((substr($this->BUF[$i], ($j + 3), 8)) == "NETSCAPE") { + printf("%s: %s ( %s source )!", $this->VER, $this->ERR['ERR03'], ($i + 1)); + exit(0); + } + break; + case ";": + $k = false; + break; } } } - GIFEncoder::GIFAddHeader(); + self::GIFAddHeader(); for ($i = 0; $i < count($this->BUF); $i++) { - GIFEncoder::GIFAddFrames($i, $GIF_dly[$i]); + self::GIFAddFrames($i, $GIF_dly[$i]); } - GIFEncoder::GIFAddFooter(); + self::GIFAddFooter(); } /* ::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -189,14 +184,13 @@ class GIFEncoder */ public function GIFAddHeader() { - $cmap = 0; if (ord($this->BUF[0]{10}) & 0x80) { $cmap = 3 * (2 << (ord($this->BUF[0]{10}) & 0x07)); $this->GIF .= substr($this->BUF[0], 6, 7); $this->GIF .= substr($this->BUF[0], 13, $cmap); - $this->GIF .= "!\377\13NETSCAPE2.0\3\1" . GIFEncoder::GIFWord($this->LOP) . "\0"; + $this->GIF .= "!\377\13NETSCAPE2.0\3\1" . self::GIFWord($this->LOP) . "\0"; } } /* @@ -207,7 +201,7 @@ class GIFEncoder */ public function GIFAddFrames($i, $d) { - + $Locals_img=''; $Locals_str = 13 + 3 * (2 << (ord($this->BUF[$i]{10}) & 0x07)); $Locals_end = strlen($this->BUF[$i]) - $Locals_str - 1; @@ -217,12 +211,12 @@ class GIFEncoder $Locals_len = 2 << (ord($this->BUF[$i]{10}) & 0x07); $Global_rgb = substr($this->BUF[0], 13, - 3 * (2 << (ord($this->BUF[0]{10}) & 0x07))); + 3 * (2 << (ord($this->BUF[0]{10}) & 0x07))); $Locals_rgb = substr($this->BUF[$i], 13, - 3 * (2 << (ord($this->BUF[$i]{10}) & 0x07))); + 3 * (2 << (ord($this->BUF[$i]{10}) & 0x07))); $Locals_ext = "!\xF9\x04" . chr(($this->DIS << 2) + 0) . - chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . "\x0\x0"; + chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . "\x0\x0"; if ($this->COL > -1 && ord($this->BUF[$i]{10}) & 0x80) { for ($j = 0; $j < (2 << (ord($this->BUF[$i]{10}) & 0x07)); $j++) { @@ -232,24 +226,27 @@ class GIFEncoder ord($Locals_rgb{3 * $j + 2}) == (($this->COL >> 0) & 0xFF) ) { $Locals_ext = "!\xF9\x04" . chr(($this->DIS << 2) + 1) . - chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . chr($j) . "\x0"; + chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . chr($j) . "\x0"; break; } } } switch ($Locals_tmp{0}) { - case "!": - $Locals_img = substr($Locals_tmp, 8, 10); - $Locals_tmp = substr($Locals_tmp, 18, strlen($Locals_tmp) - 18); - break; - case ",": - $Locals_img = substr($Locals_tmp, 0, 10); - $Locals_tmp = substr($Locals_tmp, 10, strlen($Locals_tmp) - 10); - break; + case "!": + /** + * @var string $Locals_img; + */ + $Locals_img = substr($Locals_tmp, 8, 10); + $Locals_tmp = substr($Locals_tmp, 18, strlen($Locals_tmp) - 18); + break; + case ",": + $Locals_img = substr($Locals_tmp, 0, 10); + $Locals_tmp = substr($Locals_tmp, 10, strlen($Locals_tmp) - 10); + break; } if (ord($this->BUF[$i]{10}) & 0x80 && $this->IMG > -1) { if ($Global_len == $Locals_len) { - if (GIFEncoder::GIFBlockCompare($Global_rgb, $Locals_rgb, $Global_len)) { + if (self::GIFBlockCompare($Global_rgb, $Locals_rgb, $Global_len)) { $this->GIF .= ($Locals_ext . $Locals_img . $Locals_tmp); } else { $byte = ord($Locals_img{9}); @@ -460,7 +457,6 @@ class GIFDecoder */ public function GIFReadDescriptor() { - $GIF_screen = array(); GIFDecoder::GIFGetByte(9); $GIF_screen = $this->GIF_buffer; diff --git a/library/org/oauth/driver/baidu.php b/library/org/oauth/driver/baidu.php index d3baedbd..56823f14 100644 --- a/library/org/oauth/driver/baidu.php +++ b/library/org/oauth/driver/baidu.php @@ -38,7 +38,7 @@ class Baidu extends Driver * @param string $api 百度API * @param string $param 调用API的额外参数 * @param string $method HTTP请求方法 默认为GET - * @return json + * @return array */ public function call($api, $param = '', $method = 'GET') { diff --git a/library/org/parser.php b/library/org/parser.php index 8586485c..0928137b 100644 --- a/library/org/parser.php +++ b/library/org/parser.php @@ -15,6 +15,9 @@ namespace think; class Parser { + /** + * @var array $handler + */ private static $handler = []; // 解析内容 diff --git a/library/org/validate.php b/library/org/validate.php index a0d77181..66ad7161 100644 --- a/library/org/validate.php +++ b/library/org/validate.php @@ -34,10 +34,13 @@ class Validate /** * 自动表单验证 - * @access protected + * @access protected + * * @param array $data 创建数据 - * @param string $type 创建类型 - * @return boolean + * @param array $rule + * + * @return bool + * @internal param string $type 创建类型 */ public function valid($data, $rule = []) { @@ -96,7 +99,7 @@ class Validate return false; } } - return; + return true; } /** diff --git a/library/think/app.php b/library/think/app.php index 56a6e7f0..e4546e76 100644 --- a/library/think/app.php +++ b/library/think/app.php @@ -66,8 +66,9 @@ class App // 执行操作 if (!preg_match('/^[A-Za-z](\/|\.|\w)*$/', CONTROLLER_NAME)) { // 安全检测 - $instance = false; - } elseif ($config['action_bind_class']) { + throw new Exception('[ ' . MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . Loader::parseName(str_replace('.', '\\', CONTROLLER_NAME), 1) . ' ] not exists'); + } + if ($config['action_bind_class']) { $class = self::bindActionClass($config['empty_controller']); $instance = new $class; // 操作绑定到类后 固定执行run入口 @@ -77,9 +78,6 @@ class App // 获取当前操作名 $action = ACTION_NAME . $config['action_suffix']; } - if (!$instance) { - throw new Exception('[ ' . MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . Loader::parseName(str_replace('.', '\\', CONTROLLER_NAME), 1) . ' ] not exists'); - } try { // 操作方法开始监听 @@ -213,7 +211,10 @@ class App /** * URL调度 * @access public - * @return void + * + * @param $config + * + * @throws Exception */ public static function dispatch($config) { diff --git a/library/think/behavior.php b/library/think/behavior.php new file mode 100644 index 00000000..9b40a768 --- /dev/null +++ b/library/think/behavior.php @@ -0,0 +1,54 @@ + +// +---------------------------------------------------------------------- +namespace think; +/** + * ThinkPHP Behavior基础类 + * @category Think + * @package Think + * @subpackage Core + * @author liu21st + */ +abstract class Behavior { + + // 行为参数 和配置参数设置相同 + protected $options = array(); + + /** + * 架构函数 + * @access public + */ + public function __construct() { + if(!empty($this->options)) { + foreach ($this->options as $name=>$val){ + if(NULL !== C($name)) { // 参数已设置 则覆盖行为参数 + $this->options[$name] = C($name); + }else{ // 参数未设置 则传入默认值到配置 + C($name,$val); + } + } + array_change_key_case($this->options); + } + } + + // 获取行为参数 + public function __get($name){ + return $this->options[strtolower($name)]; + } + + /** + * 执行行为 run方法是Behavior唯一的接口 + * @access public + * @param mixed $params 行为参数 + * @return void + */ + abstract public function run(&$params); + +} \ No newline at end of file diff --git a/library/think/cache/driver/apc.php b/library/think/cache/driver/apc.php index b49c4166..554856e6 100644 --- a/library/think/cache/driver/apc.php +++ b/library/think/cache/driver/apc.php @@ -28,7 +28,10 @@ class Apc /** * 架构函数 + * * @param array $options 缓存参数 + * + * @throws Exception * @access public */ public function __construct($options = []) @@ -58,7 +61,7 @@ class Apc * @param string $name 缓存变量名 * @param mixed $value 存储数据 * @param integer $expire 有效时间(秒) - * @return boolen + * @return bool */ public function set($name, $value, $expire = null) { @@ -89,11 +92,12 @@ class Apc return $result; } - /** - * 删除缓存 + /**删除缓存 * @access public + * * @param string $name 缓存变量名 - * @return boolen + * + * @return bool|\string[] */ public function rm($name) { @@ -103,7 +107,7 @@ class Apc /** * 清除缓存 * @access public - * @return boolen + * @return bool */ public function clear() { diff --git a/library/think/cache/driver/memcache.php b/library/think/cache/driver/memcache.php index 8813fce5..b037ee38 100644 --- a/library/think/cache/driver/memcache.php +++ b/library/think/cache/driver/memcache.php @@ -72,7 +72,7 @@ class Memcache * @param string $name 缓存变量名 * @param mixed $value 存储数据 * @param integer $expire 有效时间(秒) - * @return boolen + * @return bool */ public function set($name, $value, $expire = null) { @@ -106,9 +106,11 @@ class Memcache /** * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolen + * + * @param string $name 缓存变量名 + * @param bool|false $ttl + * + * @return bool */ public function rm($name, $ttl = false) { @@ -121,7 +123,7 @@ class Memcache /** * 清除缓存 * @access public - * @return boolen + * @return bool */ public function clear() { diff --git a/library/think/cache/driver/redis.php b/library/think/cache/driver/redis.php index b79ff00d..8771b3df 100644 --- a/library/think/cache/driver/redis.php +++ b/library/think/cache/driver/redis.php @@ -67,7 +67,7 @@ class Redis * @param string $name 缓存变量名 * @param mixed $value 存储数据 * @param integer $expire 有效时间(秒) - * @return boolen + * @return boolean */ public function set($name, $value, $expire = null) { @@ -107,7 +107,7 @@ class Redis * 删除缓存 * @access public * @param string $name 缓存变量名 - * @return boolen + * @return boolean */ public function rm($name) { @@ -117,7 +117,7 @@ class Redis /** * 清除缓存 * @access public - * @return boolen + * @return boolean */ public function clear() { diff --git a/library/think/cache/driver/secache.php b/library/think/cache/driver/secache.php index 0309ec7f..5c7f541b 100644 --- a/library/think/cache/driver/secache.php +++ b/library/think/cache/driver/secache.php @@ -65,7 +65,7 @@ class Secache * @param string $name 缓存变量名 * @param mixed $value 存储数据 * @param integer $expire 有效时间(秒) - * @return boolen + * @return boolean */ public function set($name, $value) { diff --git a/library/think/cache/driver/simple.php b/library/think/cache/driver/simple.php index b7aade65..cd561072 100644 --- a/library/think/cache/driver/simple.php +++ b/library/think/cache/driver/simple.php @@ -26,6 +26,8 @@ class Simple /** * 架构函数 * @access public + * + * @param array $options */ public function __construct($options = []) { @@ -67,13 +69,15 @@ class Simple /** * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @param int $expire 有效时间 0为永久 - * @return boolen + * @access public + * + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * + * @return bool + * @internal param int $expire 有效时间 0为永久 */ - public function set($name, $value, $expire = null) + public function set($name, $value) { $filename = $this->filename($name); // 缓存数据 @@ -88,7 +92,7 @@ class Simple * 删除缓存 * @access public * @param string $name 缓存变量名 - * @return boolen + * @return boolean */ public function rm($name) { @@ -97,9 +101,9 @@ class Simple /** * 清除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolen + * @access public + * @return bool + * @internal param string $name 缓存变量名 */ public function clear() { diff --git a/library/think/cache/driver/sqlite.php b/library/think/cache/driver/sqlite.php index 50f42018..e4de8367 100644 --- a/library/think/cache/driver/sqlite.php +++ b/library/think/cache/driver/sqlite.php @@ -31,7 +31,10 @@ class Sqlite /** * 架构函数 + * * @param array $options 缓存参数 + * + * @throws Exception * @access public */ public function __construct($options = []) @@ -74,7 +77,7 @@ class Sqlite * @param string $name 缓存变量名 * @param mixed $value 存储数据 * @param integer $expire 有效时间(秒) - * @return boolen + * @return boolean */ public function set($name, $value, $expire = null) { @@ -103,7 +106,7 @@ class Sqlite * 删除缓存 * @access public * @param string $name 缓存变量名 - * @return boolen + * @return boolean */ public function rm($name) { @@ -116,7 +119,7 @@ class Sqlite /** * 清除缓存 * @access public - * @return boolen + * @return boolean */ public function clear() { diff --git a/library/think/cache/driver/wincache.php b/library/think/cache/driver/wincache.php index 9364f48d..99b5a87c 100644 --- a/library/think/cache/driver/wincache.php +++ b/library/think/cache/driver/wincache.php @@ -28,7 +28,10 @@ class Wincache /** * 架构函数 + * * @param array $options 缓存参数 + * + * @throws Exception * @access public */ public function __construct($options = []) @@ -59,7 +62,7 @@ class Wincache * @param string $name 缓存变量名 * @param mixed $value 存储数据 * @param integer $expire 有效时间(秒) - * @return boolen + * @return boolean */ public function set($name, $value, $expire = null) { @@ -95,7 +98,7 @@ class Wincache * 删除缓存 * @access public * @param string $name 缓存变量名 - * @return boolen + * @return boolean */ public function rm($name) { @@ -105,7 +108,7 @@ class Wincache /** * 清除缓存 * @access public - * @return boolen + * @return boolean */ public function clear() { diff --git a/library/think/cache/driver/xcache.php b/library/think/cache/driver/xcache.php index 2e0c16dc..f1f3fc0b 100644 --- a/library/think/cache/driver/xcache.php +++ b/library/think/cache/driver/xcache.php @@ -62,7 +62,7 @@ class Xcache * @param string $name 缓存变量名 * @param mixed $value 存储数据 * @param integer $expire 有效时间(秒) - * @return boolen + * @return boolean */ public function set($name, $value, $expire = null) { @@ -98,7 +98,7 @@ class Xcache * 删除缓存 * @access public * @param string $name 缓存变量名 - * @return boolen + * @return boolean */ public function rm($name) { @@ -108,7 +108,7 @@ class Xcache /** * 清除缓存 * @access public - * @return boolen + * @return boolean */ public function clear() { diff --git a/library/think/controller.php b/library/think/controller.php index db684151..98853d33 100644 --- a/library/think/controller.php +++ b/library/think/controller.php @@ -26,6 +26,8 @@ class Controller /** * 架构函数 初始化视图类 并采用内置模板引擎 * @access public + * + * @param array $config */ public function __construct($config = []) { @@ -63,8 +65,8 @@ class Controller $this->config[$key] = $config[$key]; } } - return $this; } + return $this; } /** diff --git a/library/think/controller/rest.php b/library/think/controller/rest.php index 4b6d2009..8ffca2ee 100644 --- a/library/think/controller/rest.php +++ b/library/think/controller/rest.php @@ -57,9 +57,12 @@ abstract class rest /** * REST 调用 * @access public + * * @param string $method 方法名 - * @param array $args 参数 + * @param array $args 参数 + * * @return mixed + * @throws \think\Exception */ public function _empty($method, $args) { diff --git a/library/think/cookie.php b/library/think/cookie.php index 879e03f1..9fa6e900 100644 --- a/library/think/cookie.php +++ b/library/think/cookie.php @@ -51,17 +51,19 @@ class Cookie { if (empty($prefix)) { return self::$config['prefix']; - } else { - self::$config['prefix'] = $prefix; } + self::$config['prefix'] = $prefix; } /** * Cookie 设置、获取、删除 - * @param string $name cookie名称 - * @param mixed $value cookie值 - * @param mixed $options cookie参数 + * + * @param string $name cookie名称 + * @param mixed $value cookie值 + * @param null $option + * * @return mixed + * @internal param mixed $options cookie参数 */ public static function set($name, $value = '', $option = null) { diff --git a/library/think/db/driver/mongo.php b/library/think/db/driver/mongo.php index 9430cc67..8eda7ea1 100644 --- a/library/think/db/driver/mongo.php +++ b/library/think/db/driver/mongo.php @@ -32,7 +32,10 @@ class Mongo extends Driver /** * 架构函数 读取数据库配置信息 * @access public - * @param array $config 数据库配置数组 + * + * @param array|string $config 数据库配置数组 + * + * @throws Exception */ public function __construct($config = '') { @@ -45,11 +48,18 @@ class Mongo extends Driver $this->config['params'] = []; } } + $this->config = $config; } /** * 连接数据库方法 * @access public + * + * @param string $config + * @param int $linkNum + * + * @return + * @throws Exception */ public function connect($config = '', $linkNum = 0) { @@ -71,10 +81,12 @@ class Mongo extends Driver /** * 切换当前操作的Db和Collection * @access public - * @param string $collection collection - * @param string $db db - * @param boolean $master 是否主服务器 - * @return void + * + * @param string $collection collection + * @param string $db db + * @param boolean $master 是否主服务器 + * + * @throws Exception */ public function switchCollection($collection, $db = '', $master = true) { @@ -137,9 +149,12 @@ class Mongo extends Driver /** * 执行语句 * @access public - * @param string $code sql指令 - * @param array $args 参数 + * + * @param string $code sql指令 + * @param array $args 参数 + * * @return mixed + * @throws Exception */ public function execute($code, $args = []) { @@ -185,10 +200,13 @@ class Mongo extends Driver /** * 插入记录 * @access public - * @param mixed $data 数据 - * @param array $options 参数表达式 + * + * @param mixed $data 数据 + * @param array $options 参数表达式 * @param boolean $replace 是否replace - * @return false | integer + * + * @return false|int + * @throws Exception */ public function insert($data, $options = [], $replace = false) { @@ -222,9 +240,12 @@ class Mongo extends Driver /** * 插入多条记录 * @access public + * * @param array $dataList 数据 - * @param array $options 参数表达式 + * @param array $options 参数表达式 + * * @return bool + * @throws Exception */ public function insertAll($dataList, $options = []) { @@ -246,8 +267,11 @@ class Mongo extends Driver /** * 生成下一条记录ID 用于自增非MongoId主键 * @access public + * * @param string $pk 主键名 - * @return integer + * + * @return int + * @throws Exception */ public function getMongoNextId($pk) { @@ -268,9 +292,12 @@ class Mongo extends Driver /** * 更新记录 * @access public - * @param mixed $data 数据 + * + * @param mixed $data 数据 * @param array $options 表达式 + * * @return bool + * @throws Exception */ public function update($data, $options) { diff --git a/library/think/db/driver/mysql.php b/library/think/db/driver/mysql.php index 83a1c8da..aa1434b6 100644 --- a/library/think/db/driver/mysql.php +++ b/library/think/db/driver/mysql.php @@ -42,6 +42,9 @@ class Mysql extends Driver /** * 取得数据表的字段信息 * @access public + * @param $tableName + * + * @return array */ public function getFields($tableName) { @@ -68,6 +71,10 @@ class Mysql extends Driver /** * 取得数据库的表信息 * @access public + * + * @param string $dbName + * + * @return array */ public function getTables($dbName = '') { diff --git a/library/think/db/driver/oracle.php b/library/think/db/driver/oracle.php index 0c9fe229..ce7d94eb 100644 --- a/library/think/db/driver/oracle.php +++ b/library/think/db/driver/oracle.php @@ -94,6 +94,10 @@ class Oracle extends Driver /** * 取得数据表的字段信息 * @access public + * + * @param $tableName + * + * @return array */ public function getFields($tableName) { @@ -120,9 +124,11 @@ class Oracle extends Driver /** * 取得数据库的表信息(暂时实现取得用户表信息) - * @access public + * @access public + * @return array + * @internal param string $dbName */ - public function getTables($dbName = '') + public function getTables() { $result = $this->query("select table_name from user_tables"); $info = []; @@ -151,10 +157,11 @@ class Oracle extends Driver } return $limitStr ? ' WHERE ' . $limitStr : ''; } - /** * 设置锁机制 * @access protected + * @param bool|false $lock + * * @return string */ protected function parseLock($lock = false) diff --git a/library/think/db/lite.php b/library/think/db/lite.php index 047cbb3b..0331fed8 100644 --- a/library/think/db/lite.php +++ b/library/think/db/lite.php @@ -332,6 +332,7 @@ class Lite * 并显示当前的SQL语句 * @access public * @return string + * @throws Exception */ public function error() { diff --git a/library/think/error.php b/library/think/error.php index 6a6e68ec..de02e734 100644 --- a/library/think/error.php +++ b/library/think/error.php @@ -84,9 +84,11 @@ class Error /** * 错误输出 + * * @param mixed $error 错误 - * @param int $errno 错误代码 - * @return void + * @param int $code + * + * @internal param int $errno 错误代码 */ public static function halt($error, $code = 1) { @@ -99,7 +101,8 @@ class Error $data['code'] = $code; $data['msg'] = $message; $data['time'] = NOW_TIME; - exit(Response::returnData($data)); + Response::returnData($data); + exit(); } $e = []; if (APP_DEBUG) { diff --git a/library/think/input.php b/library/think/input.php index 10917307..1f0c6dce 100644 --- a/library/think/input.php +++ b/library/think/input.php @@ -159,10 +159,16 @@ class Input /** * 获取系统变量 支持过滤和默认值 - * @access public - * @param string $method 输入数据类型 - * @param array $args 参数 [key,filter,default] + * @access public + * + * @param $name + * @param $input + * @param $filter + * @param $default + * * @return mixed + * @internal param string $method 输入数据类型 + * @internal param array $args 参数 [key,filter,default] */ private static function getData($name, $input, $filter, $default) { diff --git a/library/think/loader.php b/library/think/loader.php index 89664edf..fbb89de4 100644 --- a/library/think/loader.php +++ b/library/think/loader.php @@ -229,12 +229,14 @@ class Loader return false; } } - /** * 取得对象实例 支持调用类的静态方法 - * @param string $class 对象类名 + * + * @param string $class 对象类名 * @param string $method 类的静态方法名 - * @return object + * + * @return mixed + * @throws Exception */ public static function instance($class, $method = '') { @@ -244,7 +246,7 @@ class Loader if (class_exists($class)) { $o = new $class(); if (!empty($method) && method_exists($o, $method)) { - $_instance[$identify] = call_user_func_array([ & $o, $method]); + $_instance[$identify] = call_user_func_array([ & $o, $method],[]); } else { $_instance[$identify] = $o; } diff --git a/library/think/log.php b/library/think/log.php index 28403b38..ba0d7e94 100644 --- a/library/think/log.php +++ b/library/think/log.php @@ -29,11 +29,12 @@ class Log /** * 记录日志 并且会过滤未经设置的级别 - * @access public + * @access public + * * @param string $message 日志信息 - * @param string $level 日志级别 - * @param boolean $record 是否强制记录 - * @return void + * @param string $level 日志级别 + * + * @internal param bool $record 是否强制记录 */ public static function record($message, $level = 'INFO') { diff --git a/library/think/model/mongo_model.php b/library/think/model/mongo_model.php index e40845fe..6958e5c8 100644 --- a/library/think/model/mongo_model.php +++ b/library/think/model/mongo_model.php @@ -36,9 +36,12 @@ class MongoModel extends \Think\Model /** * 利用__call方法实现一些特殊的Model方法 * @access public + * * @param string $method 方法名称 - * @param array $args 调用参数 + * @param array $args 调用参数 + * * @return mixed + * @throws \think\Exception */ public function __call($method, $args) { @@ -54,7 +57,6 @@ class MongoModel extends \Think\Model return $this->where($where)->getField($args[1]); } else { throw new \think\Exception(__CLASS__ . ':' . $method . Lang::get('_METHOD_NOT_EXIST_')); - return; } } diff --git a/library/think/session.php b/library/think/session.php index b8574f14..6f4b1fbf 100644 --- a/library/think/session.php +++ b/library/think/session.php @@ -179,9 +179,12 @@ class Session /** * 判断session数据 + * * @param string $name session名称 - * @param mixed $value session值 - * @return boolean + * @param string $prefix + * + * @return bool + * @internal param mixed $value session值 */ public static function has($name, $prefix = '') { diff --git a/library/think/template/taglib.php b/library/think/template/taglib.php index 395ff5a1..7ee296ba 100644 --- a/library/think/template/taglib.php +++ b/library/think/template/taglib.php @@ -74,9 +74,14 @@ class TagLib /** * TagLib标签属性分析 返回标签属性数组 - * @access public - * @param string $tagStr 标签内容 + * @access public + * + * @param $attr + * @param $tag + * * @return array + * @throws Exception + * @internal param string $tagStr 标签内容 */ public function parseXmlAttr($attr, $tag) { @@ -92,25 +97,25 @@ class TagLib } $xml = (array) ($xml->tag->attributes()); $array = array_change_key_case($xml['@attributes']); - if ($array) { - $tag = strtolower($tag); - if (isset($this->tags[$tag]['attr'])) { - $attrs = explode(',', $this->tags[$tag]['attr']); - if (isset($this->tags[strtolower($tag)]['must'])) { - $must = explode(',', $this->tags[$tag]['must']); - } else { - $must = []; - } - foreach ($attrs as $name) { - if (isset($array[$name])) { - $array[$name] = str_replace('___', '&', $array[$name]); - } elseif (false !== array_search($name, $must)) { - throw new Exception('_PARAM_ERROR_:' . $name); - } + if (!is_array($array)) return []; + $tag = strtolower($tag); + if (isset($this->tags[$tag]['attr'])) { + $attrs = explode(',', $this->tags[$tag]['attr']); + if (isset($this->tags[strtolower($tag)]['must'])) { + $must = explode(',', $this->tags[$tag]['must']); + } else { + $must = []; + } + foreach ($attrs as $name) { + if (isset($array[$name])) { + $array[$name] = str_replace('___', '&', $array[$name]); + } elseif (false !== array_search($name, $must)) { + throw new Exception('_PARAM_ERROR_:' . $name); } } - return $array; } + + return $array; } /** diff --git a/library/think/view.php b/library/think/view.php index 5328ca2c..8b4cfb6d 100644 --- a/library/think/view.php +++ b/library/think/view.php @@ -113,10 +113,14 @@ class View /** * 解析和获取模板内容 用于输出 * @access public + * * @param string $template 模板文件名或者内容 * @param array $vars 模板输出变量 * @param string $cache_id 模板缓存标识 + * @param bool $renderContent + * * @return string + * @throws Exception */ public function fetch($template = '', $vars = [], $cache_id = '', $renderContent = false) {