mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
添加方法参数变量约束
This commit is contained in:
@@ -29,7 +29,7 @@ class Cache
|
||||
* @param array $options 配置数组
|
||||
* @return object
|
||||
*/
|
||||
public static function connect($options = [])
|
||||
public static function connect(array $options = [])
|
||||
{
|
||||
$type = !empty($options['type']) ? $options['type'] : 'File';
|
||||
$class = (!empty($options['namespace']) ? $options['namespace'] : '\\think\\cache\\driver\\') . ucwords($type);
|
||||
|
||||
@@ -16,17 +16,17 @@ class Cookie
|
||||
|
||||
protected static $config = [
|
||||
// cookie 名称前缀
|
||||
'prefix' => '',
|
||||
'prefix' => '',
|
||||
// cookie 保存时间
|
||||
'expire' => 0,
|
||||
'expire' => 0,
|
||||
// cookie 保存路径
|
||||
'path' => '/',
|
||||
'path' => '/',
|
||||
// cookie 有效域名
|
||||
'domain' => '',
|
||||
'domain' => '',
|
||||
// cookie 启用安全传输
|
||||
'secure' => false,
|
||||
'secure' => false,
|
||||
// httponly设置
|
||||
'httponly' => '',
|
||||
'httponly' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,7 @@ class Cookie
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
public static function init($config = [])
|
||||
public static function init(array $config = [])
|
||||
{
|
||||
self::$config = array_merge(self::$config, array_change_key_case($config));
|
||||
if (!empty(self::$config['httponly'])) {
|
||||
@@ -157,7 +157,7 @@ class Cookie
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
private static function jsonFormatProtect(&$val, $key, $type = 'encode')
|
||||
{
|
||||
if (!empty($val) && true !== $val) {
|
||||
|
||||
@@ -235,7 +235,7 @@ class Loader
|
||||
* @param array $options 模型参数
|
||||
* @return Model
|
||||
*/
|
||||
public static function table($name = '', $options = [])
|
||||
public static function table($name = '', array $options = [])
|
||||
{
|
||||
static $_model = [];
|
||||
if (strpos($name, ':')) {
|
||||
|
||||
@@ -30,7 +30,7 @@ class Log
|
||||
protected static $alarm = null;
|
||||
|
||||
// 日志初始化
|
||||
public static function init($config = [])
|
||||
public static function init(array $config = [])
|
||||
{
|
||||
$type = isset($config['type']) ? $config['type'] : 'File';
|
||||
$class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\log\\driver\\') . ucwords($type);
|
||||
@@ -39,7 +39,7 @@ class Log
|
||||
}
|
||||
|
||||
// 通知初始化
|
||||
public static function alarm($config = [])
|
||||
public static function alarm(array $config = [])
|
||||
{
|
||||
$type = isset($config['type']) ? $config['type'] : 'Email';
|
||||
$class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\log\\alarm\\') . ucwords($type);
|
||||
|
||||
@@ -57,7 +57,7 @@ class Model
|
||||
* @param string $name 模型名称
|
||||
* @param array $config 模型配置
|
||||
*/
|
||||
public function __construct($name = '', $config = [])
|
||||
public function __construct($name = '', array $config = [])
|
||||
{
|
||||
// 模型初始化
|
||||
$this->_initialize();
|
||||
@@ -740,10 +740,9 @@ class Model
|
||||
/**
|
||||
* 生成查询SQL 可用于子查询
|
||||
* @access public
|
||||
* @param array $options 表达式参数
|
||||
* @return string
|
||||
*/
|
||||
public function buildSql($options = [])
|
||||
public function buildSql()
|
||||
{
|
||||
return '( ' . $this->fetchSql(true)->select() . ' )';
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ class Session
|
||||
/**
|
||||
* 设置或者获取session作用域(前缀)
|
||||
*
|
||||
* @param string $prefix
|
||||
* @param string $prefix
|
||||
* @return string|void
|
||||
*/
|
||||
public static function prefix($prefix = '')
|
||||
{
|
||||
if (empty($prefix) && $prefix !== null) {
|
||||
if (empty($prefix) && null !== $prefix) {
|
||||
return self::$prefix;
|
||||
} else {
|
||||
self::$prefix = $prefix;
|
||||
@@ -33,28 +33,28 @@ class Session
|
||||
/**
|
||||
* session初始化
|
||||
*
|
||||
* @param array $config
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
public static function init($config = [])
|
||||
public static function init(array $config = [])
|
||||
{
|
||||
$isDoStart = false;
|
||||
if (isset($config['use_trans_sid'])) {
|
||||
ini_set('session.use_trans_sid', $config['use_trans_sid'] ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
// 启动session
|
||||
if (! empty($config['auto_start']) && PHP_SESSION_ACTIVE != session_status()) {
|
||||
if (!empty($config['auto_start']) && PHP_SESSION_ACTIVE != session_status()) {
|
||||
ini_set('session.auto_start', 0);
|
||||
$isDoStart = true;
|
||||
}
|
||||
|
||||
|
||||
if (isset($config['prefix'])) {
|
||||
self::$prefix = $config['prefix'];
|
||||
}
|
||||
if ($config['var_session_id'] && isset($_REQUEST[$config['var_session_id']])) {
|
||||
session_id($_REQUEST[$config['var_session_id']]);
|
||||
} elseif (isset($config['id']) && ! empty($config['id'])) {
|
||||
} elseif (isset($config['id']) && !empty($config['id'])) {
|
||||
session_id($config['id']);
|
||||
}
|
||||
if (isset($config['name'])) {
|
||||
@@ -70,7 +70,7 @@ class Session
|
||||
ini_set('session.gc_maxlifetime', $config['expire']);
|
||||
ini_set('session.cookie_lifetime', $config['expire']);
|
||||
}
|
||||
|
||||
|
||||
if (isset($config['use_cookies'])) {
|
||||
ini_set('session.use_cookies', $config['use_cookies'] ? 1 : 0);
|
||||
}
|
||||
@@ -80,12 +80,12 @@ class Session
|
||||
if (isset($config['cache_expire'])) {
|
||||
session_cache_expire($config['cache_expire']);
|
||||
}
|
||||
if (! empty($config['type'])) {
|
||||
if (!empty($config['type'])) {
|
||||
// 读取session驱动
|
||||
$class = (! empty($config['namespace']) ? $config['namespace'] : '\\think\\session\\driver\\') . ucwords($config['type']);
|
||||
|
||||
$class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\session\\driver\\') . ucwords($config['type']);
|
||||
|
||||
// 检查驱动类
|
||||
if (! class_exists($class) || ! session_set_save_handler(new $class())) {
|
||||
if (!class_exists($class) || !session_set_save_handler(new $class())) {
|
||||
throw new \think\Exception('error session handler', 11700);
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class Session
|
||||
$prefix = $prefix ? $prefix : self::$prefix;
|
||||
if (strpos($name, '.')) {
|
||||
// 二维数组赋值
|
||||
list ($name1, $name2) = explode('.', $name);
|
||||
list($name1, $name2) = explode('.', $name);
|
||||
if ($prefix) {
|
||||
$_SESSION[$prefix][$name1][$name2] = $value;
|
||||
} else {
|
||||
@@ -141,15 +141,15 @@ class Session
|
||||
} elseif ($prefix) {
|
||||
// 获取session
|
||||
if (strpos($name, '.')) {
|
||||
list ($name1, $name2) = explode('.', $name);
|
||||
$value = isset($_SESSION[$prefix][$name1][$name2]) ? $_SESSION[$prefix][$name1][$name2] : null;
|
||||
list($name1, $name2) = explode('.', $name);
|
||||
$value = isset($_SESSION[$prefix][$name1][$name2]) ? $_SESSION[$prefix][$name1][$name2] : null;
|
||||
} else {
|
||||
$value = isset($_SESSION[$prefix][$name]) ? $_SESSION[$prefix][$name] : null;
|
||||
}
|
||||
} else {
|
||||
if (strpos($name, '.')) {
|
||||
list ($name1, $name2) = explode('.', $name);
|
||||
$value = isset($_SESSION[$name1][$name2]) ? $_SESSION[$name1][$name2] : null;
|
||||
list($name1, $name2) = explode('.', $name);
|
||||
$value = isset($_SESSION[$name1][$name2]) ? $_SESSION[$name1][$name2] : null;
|
||||
} else {
|
||||
$value = isset($_SESSION[$name]) ? $_SESSION[$name] : null;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ class Session
|
||||
{
|
||||
$prefix = $prefix ? $prefix : self::$prefix;
|
||||
if (strpos($name, '.')) {
|
||||
list ($name1, $name2) = explode('.', $name);
|
||||
list($name1, $name2) = explode('.', $name);
|
||||
if ($prefix) {
|
||||
unset($_SESSION[$prefix][$name1][$name2]);
|
||||
} else {
|
||||
@@ -207,7 +207,7 @@ class Session
|
||||
*
|
||||
* @param string $name
|
||||
* session名称
|
||||
* @param string $prefix
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return bool
|
||||
* @internal param mixed $value session值
|
||||
@@ -217,7 +217,7 @@ class Session
|
||||
$prefix = $prefix ? $prefix : self::$prefix;
|
||||
if (strpos($name, '.')) {
|
||||
// 支持数组
|
||||
list ($name1, $name2) = explode('.', $name);
|
||||
list($name1, $name2) = explode('.', $name);
|
||||
return $prefix ? isset($_SESSION[$prefix][$name1][$name2]) : isset($_SESSION[$name1][$name2]);
|
||||
} else {
|
||||
return $prefix ? isset($_SESSION[$prefix][$name]) : isset($_SESSION[$name]);
|
||||
|
||||
Reference in New Issue
Block a user