更新tp5内核

This commit is contained in:
2018-01-02 23:03:31 +08:00
parent 590696a06b
commit 3818619504
99 changed files with 3362 additions and 2006 deletions
+22 -13
View File
@@ -2,7 +2,7 @@
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
@@ -15,31 +15,40 @@ use think\Exception;
trait Instance
{
/**
* @var null|static 实例对象
*/
protected static $instance = null;
/**
* @param array $options
* 获取示例
* @param array $options 实例配置
* @return static
*/
public static function instance($options = [])
{
if (is_null(self::$instance)) {
self::$instance = new self($options);
}
if (is_null(self::$instance)) self::$instance = new self($options);
return self::$instance;
}
// 静态调用
public static function __callStatic($method, $params)
/**
* 静态调用
* @param string $method 调用方法
* @param array $params 调用参数
* @return mixed
* @throws Exception
*/
public static function __callStatic($method, array $params)
{
if (is_null(self::$instance)) {
self::$instance = new self();
}
if (is_null(self::$instance)) self::$instance = new self();
$call = substr($method, 1);
if (0 === strpos($method, '_') && is_callable([self::$instance, $call])) {
return call_user_func_array([self::$instance, $call], $params);
} else {
if (0 !== strpos($method, '_') || !is_callable([self::$instance, $call])) {
throw new Exception("method not exists:" . $method);
}
return call_user_func_array([self::$instance, $call], $params);
}
}